J
jimgardener
hi
I encoded a byte array using AES/CTR/NoPadding scheme using a key
created with KeyGenerator.However when i checked the ciphertext byte
array I found that it is longer than the plaintext bytes.A block of
zero bytes seem to have been appended to it
this is how it went
Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding", "BC");
KeyGenerator generator = KeyGenerator.getInstance("AES", "BC");
generator.init(192);
Key encryptionKey = generator.generateKey();
cipher.init(Cipher.ENCRYPT_MODE, encryptionKey, new IvParameterSpec
(ivBytes));
byte[] cipherText = new byte[cipher.getOutputSize(input.length)];
System.out.println("input : " + Utils.toHex(input)
+"\nbytes="+input.length);
System.out.println("cipherText : " + Utils.toHex(cipherText) +
"\nbytes: " + cipherText.length);
--------------------------------------
these are the hex of the plaintext and ciphertext bytes>>
input :
000102030405060708090a0b0c0d0e0f0001020304050607
bytes=24
cipherText :
263f5032cf8346031e77dce0eb1d91b7c3c9b9ca17e52d8b0000000000000000
bytes=32
should there be this additional block even when NoPadding is
mentioned?
thanks
jim
I encoded a byte array using AES/CTR/NoPadding scheme using a key
created with KeyGenerator.However when i checked the ciphertext byte
array I found that it is longer than the plaintext bytes.A block of
zero bytes seem to have been appended to it
this is how it went
Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding", "BC");
KeyGenerator generator = KeyGenerator.getInstance("AES", "BC");
generator.init(192);
Key encryptionKey = generator.generateKey();
cipher.init(Cipher.ENCRYPT_MODE, encryptionKey, new IvParameterSpec
(ivBytes));
byte[] cipherText = new byte[cipher.getOutputSize(input.length)];
System.out.println("input : " + Utils.toHex(input)
+"\nbytes="+input.length);
System.out.println("cipherText : " + Utils.toHex(cipherText) +
"\nbytes: " + cipherText.length);
--------------------------------------
these are the hex of the plaintext and ciphertext bytes>>
input :
000102030405060708090a0b0c0d0e0f0001020304050607
bytes=24
cipherText :
263f5032cf8346031e77dce0eb1d91b7c3c9b9ca17e52d8b0000000000000000
bytes=32
should there be this additional block even when NoPadding is
mentioned?
thanks
jim