Skip to content

Commit

Permalink
Merge pull request #663 from pabuhler/cipher_driver-fixes
Browse files Browse the repository at this point in the history
Some cipher_driver fixes
  • Loading branch information
pabuhler authored Dec 12, 2023
2 parents 2520129 + 9ed4042 commit 2d65fe7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crypto/include/cipher.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ typedef struct srtp_cipher_type_t {
srtp_cipher_init_func_t init;
srtp_cipher_set_aad_func_t set_aad;
srtp_cipher_encrypt_func_t encrypt;
srtp_cipher_encrypt_func_t decrypt;
srtp_cipher_decrypt_func_t decrypt;
srtp_cipher_set_iv_func_t set_iv;
srtp_cipher_get_tag_func_t get_tag;
const char *description;
Expand Down
14 changes: 8 additions & 6 deletions crypto/test/cipher_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ srtp_err_status_t cipher_array_alloc_init(srtp_cipher_t ***ca,
{
int i, j;
srtp_err_status_t status;
uint8_t *key;
uint8_t *key = NULL;
srtp_cipher_t **cipher_array;
/* pad klen allocation, to handle aes_icm reading 16 bytes for the
14-byte salt */
Expand All @@ -453,11 +453,13 @@ srtp_err_status_t cipher_array_alloc_init(srtp_cipher_t ***ca,
/* set ca to location of cipher_array */
*ca = cipher_array;

/* allocate key */
key = srtp_crypto_alloc(klen_pad);
if (key == NULL) {
srtp_crypto_free(cipher_array);
return srtp_err_status_alloc_fail;
/* allocate key , allow zero key for example null cipher */
if (klen_pad > 0) {
key = srtp_crypto_alloc(klen_pad);
if (key == NULL) {
srtp_crypto_free(cipher_array);
return srtp_err_status_alloc_fail;
}
}

/* allocate and initialize an array of ciphers */
Expand Down

0 comments on commit 2d65fe7

Please sign in to comment.