mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 20:24:39 +02:00
AEAD additional data for encrypt and decrypt should be AEAD_AUTH_DATA_SZ
This commit is contained in:
@@ -4189,11 +4189,11 @@ static INLINE int Encrypt(CYASSL* ssl, byte* out, const byte* input, word16 sz)
|
|||||||
#ifdef BUILD_AESGCM
|
#ifdef BUILD_AESGCM
|
||||||
case cyassl_aes_gcm:
|
case cyassl_aes_gcm:
|
||||||
{
|
{
|
||||||
byte additional[AES_BLOCK_SIZE];
|
byte additional[AEAD_AUTH_DATA_SZ];
|
||||||
byte nonce[AEAD_NONCE_SZ];
|
byte nonce[AEAD_NONCE_SZ];
|
||||||
const byte* additionalSrc = input - 5;
|
const byte* additionalSrc = input - 5;
|
||||||
|
|
||||||
XMEMSET(additional, 0, AES_BLOCK_SIZE);
|
XMEMSET(additional, 0, AEAD_AUTH_DATA_SZ);
|
||||||
|
|
||||||
/* sequence number field is 64-bits, we only use 32-bits */
|
/* sequence number field is 64-bits, we only use 32-bits */
|
||||||
c32toa(GetSEQIncrement(ssl, 0),
|
c32toa(GetSEQIncrement(ssl, 0),
|
||||||
@@ -4222,8 +4222,8 @@ static INLINE int Encrypt(CYASSL* ssl, byte* out, const byte* input, word16 sz)
|
|||||||
sz - AEAD_EXP_IV_SZ - ssl->specs.aead_mac_size,
|
sz - AEAD_EXP_IV_SZ - ssl->specs.aead_mac_size,
|
||||||
nonce, AEAD_NONCE_SZ,
|
nonce, AEAD_NONCE_SZ,
|
||||||
out + sz - ssl->specs.aead_mac_size,
|
out + sz - ssl->specs.aead_mac_size,
|
||||||
ssl->specs.aead_mac_size, additional,
|
ssl->specs.aead_mac_size,
|
||||||
AEAD_AUTH_DATA_SZ);
|
additional, AEAD_AUTH_DATA_SZ);
|
||||||
AeadIncrementExpIV(ssl);
|
AeadIncrementExpIV(ssl);
|
||||||
XMEMSET(nonce, 0, AEAD_NONCE_SZ);
|
XMEMSET(nonce, 0, AEAD_NONCE_SZ);
|
||||||
}
|
}
|
||||||
@@ -4233,11 +4233,11 @@ static INLINE int Encrypt(CYASSL* ssl, byte* out, const byte* input, word16 sz)
|
|||||||
#ifdef HAVE_AESCCM
|
#ifdef HAVE_AESCCM
|
||||||
case cyassl_aes_ccm:
|
case cyassl_aes_ccm:
|
||||||
{
|
{
|
||||||
byte additional[AES_BLOCK_SIZE];
|
byte additional[AEAD_AUTH_DATA_SZ];
|
||||||
byte nonce[AEAD_NONCE_SZ];
|
byte nonce[AEAD_NONCE_SZ];
|
||||||
const byte* additionalSrc = input - 5;
|
const byte* additionalSrc = input - 5;
|
||||||
|
|
||||||
XMEMSET(additional, 0, AES_BLOCK_SIZE);
|
XMEMSET(additional, 0, AEAD_AUTH_DATA_SZ);
|
||||||
|
|
||||||
/* sequence number field is 64-bits, we only use 32-bits */
|
/* sequence number field is 64-bits, we only use 32-bits */
|
||||||
c32toa(GetSEQIncrement(ssl, 0),
|
c32toa(GetSEQIncrement(ssl, 0),
|
||||||
@@ -4270,9 +4270,8 @@ static INLINE int Encrypt(CYASSL* ssl, byte* out, const byte* input, word16 sz)
|
|||||||
additional, AEAD_AUTH_DATA_SZ);
|
additional, AEAD_AUTH_DATA_SZ);
|
||||||
AeadIncrementExpIV(ssl);
|
AeadIncrementExpIV(ssl);
|
||||||
XMEMSET(nonce, 0, AEAD_NONCE_SZ);
|
XMEMSET(nonce, 0, AEAD_NONCE_SZ);
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CAMELLIA
|
#ifdef HAVE_CAMELLIA
|
||||||
@@ -4341,10 +4340,10 @@ static INLINE int Decrypt(CYASSL* ssl, byte* plain, const byte* input,
|
|||||||
#ifdef BUILD_AESGCM
|
#ifdef BUILD_AESGCM
|
||||||
case cyassl_aes_gcm:
|
case cyassl_aes_gcm:
|
||||||
{
|
{
|
||||||
byte additional[AES_BLOCK_SIZE];
|
byte additional[AEAD_AUTH_DATA_SZ];
|
||||||
byte nonce[AEAD_NONCE_SZ];
|
byte nonce[AEAD_NONCE_SZ];
|
||||||
|
|
||||||
XMEMSET(additional, 0, AES_BLOCK_SIZE);
|
XMEMSET(additional, 0, AEAD_AUTH_DATA_SZ);
|
||||||
|
|
||||||
/* sequence number field is 64-bits, we only use 32-bits */
|
/* sequence number field is 64-bits, we only use 32-bits */
|
||||||
c32toa(GetSEQIncrement(ssl, 1), additional + AEAD_SEQ_OFFSET);
|
c32toa(GetSEQIncrement(ssl, 1), additional + AEAD_SEQ_OFFSET);
|
||||||
@@ -4375,17 +4374,17 @@ static INLINE int Decrypt(CYASSL* ssl, byte* plain, const byte* input,
|
|||||||
return VERIFY_MAC_ERROR;
|
return VERIFY_MAC_ERROR;
|
||||||
}
|
}
|
||||||
XMEMSET(nonce, 0, AEAD_NONCE_SZ);
|
XMEMSET(nonce, 0, AEAD_NONCE_SZ);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_AESCCM
|
#ifdef HAVE_AESCCM
|
||||||
case cyassl_aes_ccm:
|
case cyassl_aes_ccm:
|
||||||
{
|
{
|
||||||
byte additional[AES_BLOCK_SIZE];
|
byte additional[AEAD_AUTH_DATA_SZ];
|
||||||
byte nonce[AEAD_NONCE_SZ];
|
byte nonce[AEAD_NONCE_SZ];
|
||||||
|
|
||||||
XMEMSET(additional, 0, AES_BLOCK_SIZE);
|
XMEMSET(additional, 0, AEAD_AUTH_DATA_SZ);
|
||||||
|
|
||||||
/* sequence number field is 64-bits, we only use 32-bits */
|
/* sequence number field is 64-bits, we only use 32-bits */
|
||||||
c32toa(GetSEQIncrement(ssl, 1), additional + AEAD_SEQ_OFFSET);
|
c32toa(GetSEQIncrement(ssl, 1), additional + AEAD_SEQ_OFFSET);
|
||||||
@@ -4416,8 +4415,8 @@ static INLINE int Decrypt(CYASSL* ssl, byte* plain, const byte* input,
|
|||||||
return VERIFY_MAC_ERROR;
|
return VERIFY_MAC_ERROR;
|
||||||
}
|
}
|
||||||
XMEMSET(nonce, 0, AEAD_NONCE_SZ);
|
XMEMSET(nonce, 0, AEAD_NONCE_SZ);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CAMELLIA
|
#ifdef HAVE_CAMELLIA
|
||||||
|
Reference in New Issue
Block a user