Skip to content

Commit 61b726f

Browse files
authored
Merge pull request #8088 from douzzer/20241016-dtls13-cleanup
20241016-dtls13-cleanup
2 parents abc6edf + 06de22e commit 61b726f

3 files changed

Lines changed: 19 additions & 16 deletions

File tree

src/dtls13.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -495,22 +495,25 @@ int Dtls13HashClientHello(const WOLFSSL* ssl, byte* hash, int* hashSz,
495495
wc_HashAlg hashCtx;
496496
int type = wolfSSL_GetHmacType_ex(specs);
497497

498+
if (type < 0)
499+
return type;
500+
498501
header[0] = (byte)client_hello;
499502
c32to24(length, header + 1);
500503

501-
ret = wc_HashInit_ex(&hashCtx, type, ssl->heap, ssl->devId);
504+
ret = wc_HashInit_ex(&hashCtx, (enum wc_HashType)type, ssl->heap, ssl->devId);
502505
if (ret == 0) {
503-
ret = wc_HashUpdate(&hashCtx, type, header, OPAQUE32_LEN);
506+
ret = wc_HashUpdate(&hashCtx, (enum wc_HashType)type, header, OPAQUE32_LEN);
504507
if (ret == 0)
505-
ret = wc_HashUpdate(&hashCtx, type, body, length);
508+
ret = wc_HashUpdate(&hashCtx, (enum wc_HashType)type, body, length);
506509
if (ret == 0)
507-
ret = wc_HashFinal(&hashCtx, type, hash);
510+
ret = wc_HashFinal(&hashCtx, (enum wc_HashType)type, hash);
508511
if (ret == 0) {
509-
*hashSz = wc_HashGetDigestSize(type);
512+
*hashSz = wc_HashGetDigestSize((enum wc_HashType)type);
510513
if (*hashSz < 0)
511514
ret = *hashSz;
512515
}
513-
wc_HashFree(&hashCtx, type);
516+
wc_HashFree(&hashCtx, (enum wc_HashType)type);
514517
}
515518
return ret;
516519
}
@@ -568,9 +571,6 @@ static int Dtls13SendFragment(WOLFSSL* ssl, byte* output, word16 output_size,
568571
else {
569572
msg = output + recordHeaderLength;
570573

571-
if (length <= recordHeaderLength)
572-
return BUFFER_ERROR;
573-
574574
if (hashOutput) {
575575
ret = Dtls13HashHandshake(ssl, msg, recordLength);
576576
if (ret != 0)
@@ -1713,7 +1713,7 @@ static int _Dtls13HandshakeRecv(WOLFSSL* ssl, byte* input, word32 size,
17131713
isFirst = fragOff == 0;
17141714
isComplete = isFirst && fragLength == messageLength;
17151715

1716-
if (!isComplete && !Dtls13AcceptFragmented(ssl, handshakeType)) {
1716+
if (!isComplete && !Dtls13AcceptFragmented(ssl, (enum HandShakeType)handshakeType)) {
17171717
#ifdef WOLFSSL_DTLS_CH_FRAG
17181718
byte tls13 = 0;
17191719
/* check if the first CH fragment contains a valid cookie */

src/internal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11471,8 +11471,8 @@ static int GetDtlsRecordHeader(WOLFSSL* ssl, word32* inOutIdx,
1147111471
if (ssl->options.tls1_3) {
1147211472
ret = GetDtls13RecordHeader(ssl, inOutIdx, rh, size);
1147311473
if (ret == 0 ||
11474-
ret != WC_NO_ERR_TRACE(SEQUENCE_ERROR) ||
11475-
ret != WC_NO_ERR_TRACE(DTLS_CID_ERROR))
11474+
((ret != WC_NO_ERR_TRACE(SEQUENCE_ERROR)) &&
11475+
(ret != WC_NO_ERR_TRACE(DTLS_CID_ERROR))))
1147611476
return ret;
1147711477
}
1147811478

tests/api.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87647,6 +87647,7 @@ static void test_AEAD_limit_client(WOLFSSL* ssl)
8764787647
/* Test the sending limit for AEAD ciphers */
8764887648
Dtls13GetEpoch(ssl, ssl->dtls13Epoch)->nextSeqNumber = sendLimit;
8764987649
test_AEAD_seq_num = 1;
87650+
XMEMSET(msgBuf, 0, sizeof(msgBuf));
8765087651
ret = wolfSSL_write(ssl, msgBuf, sizeof(msgBuf));
8765187652
AssertIntGT(ret, 0);
8765287653
didReKey = 0;
@@ -90812,12 +90813,13 @@ static int test_wolfSSL_dtls_stateless_maxfrag(void)
9081290813
XMEMSET(&test_ctx, 0, sizeof(test_ctx));
9081390814
ExpectIntEQ(test_memio_setup(&test_ctx, &ctx_c, &ctx_s, &ssl_c, &ssl_s,
9081490815
wolfDTLSv1_2_client_method, wolfDTLSv1_2_server_method), 0);
90816+
ExpectNotNull(ssl_s);
9081590817
ExpectNotNull(ssl_c2 = wolfSSL_new(ctx_c));
9081690818
ExpectIntEQ(wolfSSL_UseMaxFragment(ssl_c2, WOLFSSL_MFL_2_8),
9081790819
WOLFSSL_SUCCESS);
9081890820
wolfSSL_SetIOWriteCtx(ssl_c2, &test_ctx);
9081990821
wolfSSL_SetIOReadCtx(ssl_c2, &test_ctx);
90820-
if (ssl_s != NULL) {
90822+
if (EXPECT_SUCCESS()) {
9082190823
max_fragment = ssl_s->max_fragment;
9082290824
}
9082390825
/* send CH */
@@ -95173,11 +95175,12 @@ static int test_dtls_frag_ch(void)
9517395175
/* Limit options to make the CH a fixed length */
9517495176
/* See wolfSSL_parse_cipher_list for reason why we provide 1.3 AND 1.2
9517595177
* ciphersuite. This is only necessary when building with OPENSSL_EXTRA. */
95176-
ExpectTrue(wolfSSL_set_cipher_list(ssl_c, "TLS13-AES256-GCM-SHA384"
9517795178
#ifdef OPENSSL_EXTRA
95178-
":DHE-RSA-AES256-GCM-SHA384"
95179+
ExpectTrue(wolfSSL_set_cipher_list(ssl_c, "TLS13-AES256-GCM-SHA384"
95180+
":DHE-RSA-AES256-GCM-SHA384"));
95181+
#else
95182+
ExpectTrue(wolfSSL_set_cipher_list(ssl_c, "TLS13-AES256-GCM-SHA384"));
9517995183
#endif
95180-
));
9518195184

9518295185
/* CH1 */
9518395186
ExpectIntEQ(wolfSSL_negotiate(ssl_c), -1);

0 commit comments

Comments
 (0)