From b9da5149e2c4d443ef32e7edb8bc5b0e0ca6ee3b Mon Sep 17 00:00:00 2001 From: jfigus Date: Mon, 28 Apr 2014 10:06:17 -0400 Subject: [PATCH] Set the algorithm member on cipher_t when allocating AES crypto instance. Apply same fix to NULL cipher. --- libs/srtp/crypto/cipher/aes_icm.c | 11 +++++++++++ libs/srtp/crypto/cipher/null_cipher.c | 1 + 2 files changed, 12 insertions(+) diff --git a/libs/srtp/crypto/cipher/aes_icm.c b/libs/srtp/crypto/cipher/aes_icm.c index 7a8e56f850..cf316b1ffd 100644 --- a/libs/srtp/crypto/cipher/aes_icm.c +++ b/libs/srtp/crypto/cipher/aes_icm.c @@ -118,6 +118,17 @@ aes_icm_alloc_ismacryp(cipher_t **c, int key_len, int forIsmacryp) { /* set pointers */ *c = (cipher_t *)pointer; + switch (key_len) { + case 46: + (*c)->algorithm = AES_256_ICM; + break; + case 38: + (*c)->algorithm = AES_192_ICM; + break; + default: + (*c)->algorithm = AES_128_ICM; + break; + } (*c)->type = &aes_icm; (*c)->state = pointer + sizeof(cipher_t); diff --git a/libs/srtp/crypto/cipher/null_cipher.c b/libs/srtp/crypto/cipher/null_cipher.c index 001e20ff47..8c2f09f996 100644 --- a/libs/srtp/crypto/cipher/null_cipher.c +++ b/libs/srtp/crypto/cipher/null_cipher.c @@ -68,6 +68,7 @@ null_cipher_alloc(cipher_t **c, int key_len) { /* set pointers */ *c = (cipher_t *)pointer; + (*c)->algorithm = NULL_CIPHER; (*c)->type = &null_cipher; (*c)->state = pointer + sizeof(cipher_t);