Module: kamailio
Branch: 5.4
Commit: 4b5f5636143037ff6620b88e03e57c05a91eabc4
URL:
https://github.com/kamailio/kamailio/commit/4b5f5636143037ff6620b88e03e57c0…
Author: Henning Westerholt <hw(a)skalatan.de>
Committer: Henning Westerholt <hw(a)skalatan.de>
Date: 2020-11-09T12:53:36Z
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)
---
Modified: src/modules/crypto/crypto_aes.c
---
Diff:
https://github.com/kamailio/kamailio/commit/4b5f5636143037ff6620b88e03e57c0…
Patch:
https://github.com/kamailio/kamailio/commit/4b5f5636143037ff6620b88e03e57c0…
---
diff --git a/src/modules/crypto/crypto_aes.c b/src/modules/crypto/crypto_aes.c
index 8b80d62a29..f9aacf5410 100644
--- a/src/modules/crypto/crypto_aes.c
+++ b/src/modules/crypto/crypto_aes.c
@@ -76,7 +76,9 @@ int crypto_aes_init(unsigned char *key_data, int key_data_len,
{
int i, nrounds = 5;
int x;
- unsigned char key[32], iv[32];
+ unsigned char key[32], iv[32]; /* IV is only 16 bytes, but makes it easier */
+ memset(key, 0, sizeof(key));
+ memset(iv, 0, sizeof(iv));
/*
* Gen key & IV for AES 256 CBC mode. A SHA1 digest is used to hash