0
votes

Well I want to generate the AES key using java and mentioned is the specification based on ".NET" utility that need to follow while generating the key in JAVA program

Specification: "Generate AES key using AesCryptoServiceProvider with Mode = ECB, Padding = PKCS7, KeySize = 256 & BlockSize = 128."

I researched a lot but didn't get similar things that can be used in Java to generate the AES key.

Can anyone please guide me how to move ahead with the same to create the AES key with above specification mentioned?

1

1 Answers

0
votes

For an AES key either use random bytes obtained from a CSPRNG or derive the key from a passphrase with PBKFD2.

Do not use ECB mode in new work and update legacy work ASAP, it is not secure, see ECB mode, scroll down to the Penguin. Instead use CBC mode with a random IV, just prefix the encrypted data with the IV for use in decryption, it does not need to be secret.

Notes:

The Java base implementation limits the key size to 128-bits (which is fully secure), in order to use a larger key you need to you have to use Java Cryptography Extension:
Java 6 JRE, Java 7 JRE, Java 8 JRE
(Thanks to Robert for the versions info and links!)

AES only has one block size: 128-bits.

For Java see the Documentation Java Cryptography Architecture Reference Guide and in particular The Cipher Class.