Module: kamailio
Branch: master
Commit: e9624bc4823cfba0bd9536a70b9eeadecb2a537e
URL:
https://github.com/kamailio/kamailio/commit/e9624bc4823cfba0bd9536a70b9eead…
Author: Henning Westerholt <hw(a)skalatan.de>
Committer: Henning Westerholt <hw(a)skalatan.de>
Date: 2020-11-09T12:52:07Z
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
---
Modified: src/modules/crypto/crypto_aes.c
---
Diff:
https://github.com/kamailio/kamailio/commit/e9624bc4823cfba0bd9536a70b9eead…
Patch:
https://github.com/kamailio/kamailio/commit/e9624bc4823cfba0bd9536a70b9eead…
---
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