Skip to content

Commit cf2f58b

Browse files
authored
Merge pull request #7395 from douzzer/20240403-RPK-cleanups
20240403-RPK-cleanups
2 parents 3908bc3 + 747755b commit cf2f58b

3 files changed

Lines changed: 17 additions & 11 deletions

File tree

src/internal.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12454,7 +12454,8 @@ void CopyDecodedName(WOLFSSL_X509_NAME* name, DecodedCert* dCert, int nameType)
1245412454
name->sz = (int)XSTRLEN(name->name) + 1;
1245512455
#if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(HAVE_LIGHTY)
1245612456
name->rawLen = min(dCert->subjectRawLen, ASN_NAME_MAX);
12457-
XMEMCPY(name->raw, dCert->subjectRaw, name->rawLen);
12457+
if (name->rawLen > 0)
12458+
XMEMCPY(name->raw, dCert->subjectRaw, name->rawLen);
1245812459
#endif
1245912460
}
1246012461
else {
@@ -12464,7 +12465,7 @@ void CopyDecodedName(WOLFSSL_X509_NAME* name, DecodedCert* dCert, int nameType)
1246412465
#if (defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(HAVE_LIGHTY)) \
1246512466
&& (defined(HAVE_PKCS7) || defined(WOLFSSL_CERT_EXT))
1246612467
name->rawLen = min(dCert->issuerRawLen, ASN_NAME_MAX);
12467-
if (name->rawLen) {
12468+
if (name->rawLen > 0) {
1246812469
XMEMCPY(name->raw, dCert->issuerRaw, name->rawLen);
1246912470
}
1247012471
#endif

src/tls.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11212,8 +11212,10 @@ static int TLSX_ClientCertificateType_GetSize(WOLFSSL* ssl, byte msgType)
1121211212
ret = (int)(OPAQUE8_LEN + cnt * OPAQUE8_LEN);
1121311213
}
1121411214
else if (msgType == server_hello || msgType == encrypted_extensions) {
11215-
/* sever side */
11215+
/* server side */
1121611216
cnt = ssl->options.rpkState.sending_ClientCertTypeCnt;/* must be one */
11217+
if (cnt != 1)
11218+
return SANITY_MSG_E;
1121711219
ret = OPAQUE8_LEN;
1121811220
}
1121911221
else {

tests/api.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67498,7 +67498,7 @@ static int test_tls13_rpk_handshake(void)
6749867498
certType_s[1] = WOLFSSL_CERT_TYPE_X509;
6749967499
typeCnt_s = 2;
6750067500

67501-
/* both clien and server do not call client/server_cert_type APIs,
67501+
/* both client and server do not call client/server_cert_type APIs,
6750267502
* expecting default settings works and no negotiation performed.
6750367503
*/
6750467504

@@ -67520,6 +67520,9 @@ static int test_tls13_rpk_handshake(void)
6752067520
WOLFSSL_SUCCESS);
6752167521
ExpectIntEQ(tp, WOLFSSL_CERT_TYPE_UNKNOWN);
6752267522

67523+
(void)typeCnt_c;
67524+
(void)typeCnt_s;
67525+
6752367526
wolfSSL_free(ssl_c);
6752467527
wolfSSL_CTX_free(ctx_c);
6752567528
wolfSSL_free(ssl_s);
@@ -67551,7 +67554,7 @@ static int test_tls13_rpk_handshake(void)
6755167554
certType_s[1] = WOLFSSL_CERT_TYPE_X509;
6755267555
typeCnt_s = 2;
6755367556

67554-
/* both clien and server do not call client/server_cert_type APIs,
67557+
/* both client and server do not call client/server_cert_type APIs,
6755567558
* expecting default settings works and no negotiation performed.
6755667559
*/
6755767560

@@ -67575,6 +67578,9 @@ static int test_tls13_rpk_handshake(void)
6757567578
WOLFSSL_SUCCESS);
6757667579
ExpectIntEQ(tp, WOLFSSL_CERT_TYPE_UNKNOWN);
6757767580

67581+
(void)typeCnt_c;
67582+
(void)typeCnt_s;
67583+
6757867584
wolfSSL_free(ssl_c);
6757967585
wolfSSL_CTX_free(ctx_c);
6758067586
wolfSSL_free(ssl_s);
@@ -67733,12 +67739,9 @@ static int test_tls13_rpk_handshake(void)
6773367739
svrKeyFile, WOLFSSL_FILETYPE_PEM )
6773467740
, 0);
6773567741

67736-
/* set client certificate type in client end */
67737-
certType_c[0] = WOLFSSL_CERT_TYPE_RPK;
67738-
certType_c[1] = WOLFSSL_CERT_TYPE_X509;
67739-
typeCnt_c = 2;
67740-
67741-
/* client indicates both RPK and x509 certs are available but loaded RPK
67742+
/* set client certificate type in client end
67743+
*
67744+
* client indicates both RPK and x509 certs are available but loaded RPK
6774267745
* cert only. It does not have client add client-cert-type extension in CH.
6774367746
*/
6774467747
certType_c[0] = WOLFSSL_CERT_TYPE_RPK;

0 commit comments

Comments
 (0)