Skip to content

Commit

Permalink
fix cipher test with -a option
Browse files Browse the repository at this point in the history
The null cipher does not need a key
  • Loading branch information
pabuhler committed Dec 12, 2023
1 parent 944b0e7 commit 31e13a2
Showing 1 changed file with 8 additions and 6 deletions.
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 31e13a2

Please sign in to comment.