java - Where do I get AES Key Schedule encryption key? -


i have implemented aes key schedule in java there 1 thing confused about. in wikipedia (http://en.wikipedia.org/wiki/rijndael_key_schedule#key_schedule_description) says:

the first n bytes of expanded key encryption key.

where "encryption key" come from? generated randomly , if constraints should generate etc?

at moment have method generates random array of 16 bytes:

public int[][] initvec() {     int[][] key = new int[4][nk];     (int = 0; < 4; i++) {         (int j = 0; j < nk; j++) {             key[i][j] = mrnd.nextint(255) % (0xff + 1);             int keyval = key[i][j];             // system.out.printf("%x,",keyval);         }         // system.out.println("");     }     return key; } 

i print key out java has signed bytes if use number larger 127 (currently 255) negative numbers can't represented in string using outputbyte byte[] , has integers converted bytes , stored inside it:

string output = new string(outputbyte, standardcharsets.utf_8); 

is using 127 instead acceptable?

where "encryption key" come from?

it's key user supplies when needs encrypted.

is generated randomly , if constraints should generate etc?

it may generated randomly. challenge make known other side. 1 example send key encrypted through public-key crypto. called hybrid encryption.

often key exchange protocol such diffie-hellman used negotiate secret without being sent assembled on wire. achieves forward secrecy, because every party calculate secret key on own.

is using 127 instead acceptable?

no, isn't, because you're doing whole thing wrong. bytes 0x00 through 0x1f not printable characters. when try print bytes reduced byte domain of 127, won't see actual key. also, restricting domain, attackers, because don't need brute-force complete domain every byte of key.

you need utilize full capacity of key byte when generating random key. when want see key, can encode base 64 or hex.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -