I am trying to set a key using openssl. This code is generating a segmentation fault. Can someone help?
AES_KEY *aes_key;
unsigned char key[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
};
unsigned char iv[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
};
AES_set_encrypt_key(key, 128, aes_key);
I’m also getting a compiler error that aes_key may not be initialized, but from other code I’ve seen, initialization doesn’t seem necessary. ?
Just a random guess.
Try this:
I have never used OpenSSL but it might be that memory for AES_KEY (I’m guessing it’s a struct) needs to be initialized.
You only declared a pointer.