Browse code

crypto: properly initialize key and iv to 0, add comment regarding the size of IV

- 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

(cherry picked from commit e9624bc4823cfba0bd9536a70b9eeadecb2a537e)

Henning Westerholt authored on 09/11/2020 12:52:07
Showing 1 changed files
... ...
@@ -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