Skip to content

Commit 2496cc0

Browse files
authored
Merge pull request #7477 from julek-wolfssl/issue/7390-2
Fix quic header protect cipher return
2 parents e1bd4dd + 2328270 commit 2496cc0

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

src/quic.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,22 +1037,34 @@ const WOLFSSL_EVP_CIPHER* wolfSSL_quic_get_hp(WOLFSSL* ssl)
10371037
}
10381038

10391039
switch (cipher->cipherSuite) {
1040-
#if !defined(NO_AES) && defined(HAVE_AESGCM)
1040+
#if !defined(NO_AES) && defined(HAVE_AESGCM) && defined(WOLFSSL_AES_COUNTER)
1041+
/* This has to be CTR even though the spec says that ECB is used for
1042+
* mask generation. ngtcp2_crypto_hp_mask uses a hack where they pass
1043+
* in the "ECB" input as the IV for the CTR cipher and then the input
1044+
* is just a cleared buffer. They do this so that the EVP
1045+
* init-update-final cycle can be used without the padding that is added
1046+
* for EVP_aes_(128|256)_ecb. */
1047+
#if defined(WOLFSSL_AES_128)
10411048
case TLS_AES_128_GCM_SHA256:
1042-
evp_cipher = wolfSSL_EVP_aes_128_gcm();
1049+
evp_cipher = wolfSSL_EVP_aes_128_ctr();
10431050
break;
1051+
#endif
1052+
#if defined(WOLFSSL_AES_256)
10441053
case TLS_AES_256_GCM_SHA384:
1045-
evp_cipher = wolfSSL_EVP_aes_256_gcm();
1054+
evp_cipher = wolfSSL_EVP_aes_256_ctr();
10461055
break;
10471056
#endif
1057+
#endif
10481058
#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
10491059
case TLS_CHACHA20_POLY1305_SHA256:
10501060
evp_cipher = wolfSSL_EVP_chacha20();
10511061
break;
10521062
#endif
1053-
#if !defined(NO_AES) && defined(HAVE_AESCCM) && defined(WOLFSSL_AES_128)
1063+
#if !defined(NO_AES) && defined(HAVE_AESCCM) && defined(WOLFSSL_AES_128) && \
1064+
defined(WOLFSSL_AES_COUNTER)
1065+
/* This has to be CTR. See comment above. */
10541066
case TLS_AES_128_CCM_SHA256:
1055-
evp_cipher = wolfSSL_EVP_aes_128_ccm();
1067+
evp_cipher = wolfSSL_EVP_aes_128_ctr();
10561068
break;
10571069
case TLS_AES_128_CCM_8_SHA256:
10581070
WOLFSSL_MSG("wolfSSL_quic_get_hp: no CCM-8 support in EVP layer");

0 commit comments

Comments
 (0)