@@ -19715,7 +19715,9 @@ static int DoDtlsHandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx,
1971519715#if (!defined(NO_PUBLIC_GCM_SET_IV) && \
1971619716 ((defined(HAVE_FIPS) || defined(HAVE_SELFTEST)) && \
1971719717 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)))) || \
19718- (defined(HAVE_POLY1305) && defined(HAVE_CHACHA))
19718+ (defined(HAVE_POLY1305) && defined(HAVE_CHACHA)) || \
19719+ defined(HAVE_ARIA) || \
19720+ defined(WOLFSSL_SM4_GCM) || defined(WOLFSSL_SM4_CCM)
1971919721static WC_INLINE void AeadIncrementExpIV(WOLFSSL* ssl)
1972019722{
1972119723 int i;
@@ -20702,10 +20704,9 @@ static WC_INLINE int Encrypt(WOLFSSL* ssl, byte* out, const byte* input,
2070220704 sizeof(ssl->encrypt.sanityCheck));
2070320705 #endif
2070420706
20705- #if defined(BUILD_AESGCM) || defined(HAVE_AESCCM) || defined(HAVE_ARIA)
20707+ #if defined(BUILD_AESGCM) || defined(HAVE_AESCCM)
2070620708 if (ssl->specs.bulk_cipher_algorithm == wolfssl_aes_ccm ||
20707- ssl->specs.bulk_cipher_algorithm == wolfssl_aes_gcm ||
20708- ssl->specs.bulk_cipher_algorithm == wolfssl_aria_gcm)
20709+ ssl->specs.bulk_cipher_algorithm == wolfssl_aes_gcm)
2070920710 {
2071020711 /* finalize authentication cipher */
2071120712#if !defined(NO_PUBLIC_GCM_SET_IV) && \
@@ -20716,7 +20717,17 @@ static WC_INLINE int Encrypt(WOLFSSL* ssl, byte* out, const byte* input,
2071620717 if (ssl->encrypt.nonce)
2071720718 ForceZero(ssl->encrypt.nonce, AESGCM_NONCE_SZ);
2071820719 }
20719- #endif /* BUILD_AESGCM || HAVE_AESCCM || HAVE_ARIA */
20720+ #endif /* BUILD_AESGCM || HAVE_AESCCM */
20721+ #ifdef HAVE_ARIA
20722+ if (ssl->specs.bulk_cipher_algorithm == wolfssl_aria_gcm)
20723+ {
20724+ /* finalize authentication cipher -- wc_AriaEncrypt is
20725+ * stateless, so the explicit IV must always advance */
20726+ AeadIncrementExpIV(ssl);
20727+ if (ssl->encrypt.nonce)
20728+ ForceZero(ssl->encrypt.nonce, AESGCM_NONCE_SZ);
20729+ }
20730+ #endif /* HAVE_ARIA */
2072020731 #if defined(WOLFSSL_SM4_GCM) || defined(WOLFSSL_SM4_CCM)
2072120732 if (ssl->specs.bulk_cipher_algorithm == wolfssl_sm4_ccm ||
2072220733 ssl->specs.bulk_cipher_algorithm == wolfssl_sm4_gcm)
0 commit comments