- properly initialize key and iv to 0, otherwise invalid data might be printed
- the initialization vector for AES will be always AES blocksize, e.g. 128 bits
... | ... |
@@ -76,7 +76,9 @@ int crypto_aes_init(unsigned char *key_data, int key_data_len, |
76 | 76 |
{ |
77 | 77 |
int i, nrounds = 5; |
78 | 78 |
int x; |
79 |
- unsigned char key[32], iv[32]; |
|
79 |
+ unsigned char key[32], iv[32]; /* IV is only 16 bytes, but makes it easier */ |
|
80 |
+ memset(key, 0, sizeof(key)); |
|
81 |
+ memset(iv, 0, sizeof(iv)); |
|
80 | 82 |
|
81 | 83 |
/* |
82 | 84 |
* Gen key & IV for AES 256 CBC mode. A SHA1 digest is used to hash |