Skip to content

Commit ee431d1

Browse files
authored
Merge pull request #146 from SparkiDev/ccm_def_ivlen
AES-CCM: default nonce size is 12 in OpenSSL
2 parents 35fd1e8 + 74ef50e commit ee431d1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/we_aes_ccm.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
#define CCM_NONCE_MIN_SZ 7
3232
#endif
3333

34+
/* Default OpenSSL size for nonce. */
35+
#define CCM_NONCE_DEF_SZ 12
36+
3437
/* Older versions of OpenSSL don't define these. */
3538
#ifndef EVP_CCM_TLS_EXPLICIT_IV_LEN
3639
#define EVP_CCM_TLS_EXPLICIT_IV_LEN EVP_GCM_TLS_EXPLICIT_IV_LEN
@@ -639,7 +642,7 @@ static int we_init_aesccm_meth(EVP_CIPHER *cipher)
639642

640643
WOLFENGINE_ENTER(WE_LOG_CIPHER, "we_init_aesccm_meth");
641644

642-
ret = EVP_CIPHER_meth_set_iv_length(cipher, CCM_NONCE_MAX_SZ);
645+
ret = EVP_CIPHER_meth_set_iv_length(cipher, CCM_NONCE_DEF_SZ);
643646
if (ret == 1) {
644647
ret = EVP_CIPHER_meth_set_flags(cipher, AES_CCM_FLAGS);
645648
}

0 commit comments

Comments
 (0)