Java – Serpent Algorithm thats implement Cipher

algorithmsjava

How must i change the Standard Implemplementation of the Serpent Algorithm that i can use it with the javax.crypto.CipherInputStream or javax.crypto.CipherOutputStream?

I must implement/extends the Cipher class and when i do it, what must i change?

The Original Implementation of the Serpent Algorithm is here http://www.cl.cam.ac.uk/~rja14/serpent.html

Exist a Implementation of the Serpent Algorithm that's implement Cipher? I found the Java implementation of the Algorithm on the Page of its Creator. The Problem in this is: i can't use it with javax.crypto.CipherInputStream or javax.crypto.CipherOutputStream.

I try to use the ObjectOutputStream to write a Configuration File, but i would like to encrypt it with the Serpent Algorithm. The same is with the reading of this Configuration file.

I don't want to use API's like the BouncyCastle and flexiprovider because they create a to heavy boilerplate which i don't need.

What is the best practice to use a finished (final and tested) Algorithm that dont extends/implements Cipher and it should be used in javax.crypto.CipherXxxStream?

Best Answer

Here is a walkthrough of how to implement a cipher for Java: Writing your own JCA extensions - a full cipher

The key points from the article are:

Create key classes

We will create a Caesar cipher implementation. You could also do ROT13 with it. As ciphers are about encryption/decryption we need some keys. Our key class will be very simple as we just need to store an offset for shifting our letters later on.

Start by creating a new Java Project named com.example.jce.cipher.

Implement the cipher

Ciphers are implemented extending CipherSpi (as all JCA extensions extend a WhateverSpi class).

Create a JCE provider

As for the digest, we need to usa a provider to register our digest in the JRE.

Using our provider

Create a new Java project com.example.jce.cipher.consumer. Create a subfolder libs and store your signed JAR file there. Then add this JAR to the Java Build Path.

Now everything is in place to use our cipher.

The article also mentions that you must have a certificate from Oracle to sign your cipher or the process cannot be completed.

Related Topic