Skip to content

Commit 62764d0

Browse files
committed
Remove PQC-based buffer size increase for PreMasterSecret
The size of the PreMasterSecret buffer is based on the ENCRYPT_LEN constant, which has been increased to 5kB for PQC support (Dilithium and Falcon, as their signatures are that large). However, only in the TLS 1.2 case, the PreMasterSecret buffer is used to store signatures. In the TLS 1.3 path, only actual symmetric secrets are stored in that buffer, which are much smaller in size (the "old" size of the constant without the PQC increase). As PQC is only allowed in TLS 1.3 and NOT in TLS 1.2, we can revert that size increase, saving around 4,5kB of dynamic memory during the handshake.
1 parent 80c1228 commit 62764d0

2 files changed

Lines changed: 1 addition & 7 deletions

File tree

src/tls13.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10295,8 +10295,7 @@ static int DoTls13CertificateVerify(WOLFSSL* ssl, byte* input,
1029510295
args->idx += OPAQUE16_LEN;
1029610296

1029710297
/* Signature data. */
10298-
if ((args->idx - args->begin) + args->sz > totalSz ||
10299-
args->sz > ENCRYPT_LEN) {
10298+
if ((args->idx - args->begin) + args->sz > totalSz) {
1030010299
ERROR_OUT(BUFFER_ERROR, exit_dcv);
1030110300
}
1030210301

wolfssl/internal.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,15 +1526,10 @@ enum Misc {
15261526
MAXEARLYDATASZ_LEN = 4, /* maxEarlyDataSz size in ticket */
15271527
#endif
15281528
#endif
1529-
#if defined(HAVE_FALCON) || defined(HAVE_DILITHIUM)
1530-
ENCRYPT_LEN = 5120, /* Allow 5k byte buffer for dilithium and
1531-
* hybridization with other algs. */
1532-
#else
15331529
#ifndef NO_PSK
15341530
ENCRYPT_LEN = (ENCRYPT_BASE_BITS / 8) + MAX_PSK_KEY_LEN + 2,
15351531
#else
15361532
ENCRYPT_LEN = (ENCRYPT_BASE_BITS / 8),
1537-
#endif
15381533
#endif
15391534
SIZEOF_SENDER = 4, /* clnt or srvr */
15401535
FINISHED_SZ = 36, /* WC_MD5_DIGEST_SIZE + WC_SHA_DIGEST_SIZE */

0 commit comments

Comments
 (0)