Here is the result of my first test of JceSecretCipher.java with the Blowfish algorithm. It is done with JDK 1.4.1. Here is the result of the encryption step:
java -cp . JceSecretCipher Blowfish encrypt bfish.key JceSecretCipher.java jce.cph KeySpec Object Info: Saved File = bfish.key Length = 7 toString = javax.crypto.spec.SecretKeySpec@2685020e SecretKey Object Info: Algorithm = Blowfish toString = javax.crypto.spec.SecretKeySpec@2685020e Cipher Object Info: Block Size = 8 Algorithm = Blowfish Provider = SunJCE version 1.4 toString = javax.crypto.Cipher@106082 Cipher Process Info: Input Size = 3684 Output Size = 3688
Here is the result of the decryption step:
java -cp . JceSecretCipher Blowfish decrypt bfish.key jce.cph jce.clr KeySpec Object Info: Saved File = bfish.key Length = 7 toString = javax.crypto.spec.SecretKeySpec@2685020e SecretKey Object Info: Algorithm = Blowfish toString = javax.crypto.spec.SecretKeySpec@2685020e Cipher Object Info: Block Size = 8 Algorithm = Blowfish Provider = SunJCE version 1.4 toString = javax.crypto.Cipher@106082 Cipher Process Info: Input Size = 3688 Output Size = 3684
Now checking the decryption output with the original text:
C:/herong/cr_20080000/cod>comp RSA_Input_53_Bytes.txt rsa.clr Comparing RSA_Input_53_Bytes.txt and rsa.clr... Files compare OK
Note that:
- bfish.key is the key file generated by KeyGenerator with the Blowfish algorithm.
- The last command confirms that the encryption process and the decryption process work correctly.
- The block size of Blowfish encryption algorithm is 8 bytes.
You can do more tests with DES and HmacMD5 keys.