Question

As an exercise, I am implementing my own CBC and CTR modes. (e.g. for first block of CBC, E(k, IV xor message[0]).

For example, I tried the following thinking that I can use that as my E function (with BouncyCastle):

Cipher cipher = Cipher.getInstance("AES/NONE/PKCS5", "BC");

but 'NONE' isn't an option.

My question is how to use the Java AES functions for my purpose; how can I do E(k, ...)?

Was it helpful?

Solution

In general, to build your own ciphers you need to have access to the block mode operation. If you have only access to the higher level functions you should use ECB mode encryption with no padding specified. ECB mode independently transforms each block given a cipher and a key. Padding should only be performed for block mode operations, and even then only for the last block.

If you would use this within the Java Cryptographic Architecture you would use "AES/ECB/NoPadding" mode.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top