Skip to content

Commit fbe79d7

Browse files
committed
Code review
1 parent 3edfcfe commit fbe79d7

4 files changed

Lines changed: 33 additions & 21 deletions

File tree

doc/dox_comments/header_files/ssl.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14865,10 +14865,13 @@ int wolfSSL_dtls_cid_get_tx(WOLFSSL* ssl, unsigned char* buffer,
1486514865
ciphersuites and signature algorithms.
1486614866
1486714867
\param [in] ssl The WOLFSSL object to extract the lists from.
14868-
\param [out] suites Raw and unfiltered list of client ciphersuites
14869-
\param [out] suiteSz Size of suites in bytes
14870-
\param [out] hashSigAlgo Raw and unfiltered list of client signature algorithms
14871-
\param [out] hashSigAlgoSz Size of hashSigAlgo in bytes
14868+
\param [out] optional suites Raw and unfiltered list of client ciphersuites
14869+
\param [out] optional suiteSz Size of suites in bytes
14870+
\param [out] optional hashSigAlgo Raw and unfiltered list of client
14871+
signature algorithms
14872+
\param [out] optional hashSigAlgoSz Size of hashSigAlgo in bytes
14873+
\return WOLFSSL_SUCCESS when suites available
14874+
\return WOLFSSL_FAILURE when suites not available
1487214875
1487314876
_Example_
1487414877
\code
@@ -14893,7 +14896,7 @@ int wolfSSL_dtls_cid_get_tx(WOLFSSL* ssl, unsigned char* buffer,
1489314896
\sa wolfSSL_get_ciphersuite_info
1489414897
\sa wolfSSL_get_sigalg_info
1489514898
*/
14896-
void wolfSSL_get_client_suites_sigalgs(const WOLFSSL* ssl,
14899+
int wolfSSL_get_client_suites_sigalgs(const WOLFSSL* ssl,
1489714900
const byte** suites, word16* suiteSz,
1489814901
const byte** hashSigAlgo, word16* hashSigAlgoSz);
1489914902

@@ -14936,6 +14939,10 @@ WOLFSSL_CIPHERSUITE_INFO wolfSSL_get_ciphersuite_info(byte first,
1493614939
\param [out] hashAlgo The enum wc_HashType of the MAC algorithm
1493714940
\param [out] sigAlgo The enum Key_Sum of the authentication algorithm
1493814941
14942+
\return 0 when info was correctly set
14943+
\return BAD_FUNC_ARG when either input paramters are NULL or the bytes
14944+
are not a recognized sigalg suite
14945+
1493914946
_Example_
1494014947
\code
1494114948
enum wc_HashType hashAlgo;
@@ -14953,5 +14960,5 @@ WOLFSSL_CIPHERSUITE_INFO wolfSSL_get_ciphersuite_info(byte first,
1495314960
\sa wolfSSL_get_client_suites_sigalgs
1495414961
\sa wolfSSL_get_ciphersuite_info
1495514962
*/
14956-
void wolfSSL_get_sigalg_info(byte first, byte second,
14963+
int wolfSSL_get_sigalg_info(byte first, byte second,
1495714964
int* hashAlgo, int* sigAlgo);

src/ssl.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16296,7 +16296,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
1629616296
ctx->certSetupCbArg = arg;
1629716297
}
1629816298

16299-
void wolfSSL_get_client_suites_sigalgs(const WOLFSSL* ssl,
16299+
int wolfSSL_get_client_suites_sigalgs(const WOLFSSL* ssl,
1630016300
const byte** suites, word16* suiteSz,
1630116301
const byte** hashSigAlgo, word16* hashSigAlgoSz)
1630216302
{
@@ -16320,7 +16320,9 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
1632016320
*hashSigAlgo = ssl->clSuites->hashSigAlgo;
1632116321
*hashSigAlgoSz = ssl->clSuites->hashSigAlgoSz;
1632216322
}
16323+
return WOLFSSL_SUCCESS;
1632316324
}
16325+
return WOLFSSL_FAILURE;
1632416326
}
1632516327
WOLFSSL_CIPHERSUITE_INFO wolfSSL_get_ciphersuite_info(byte first,
1632616328
byte second)
@@ -16344,15 +16346,15 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
1634416346
* @param hashAlgo The enum wc_HashType of the MAC algorithm
1634516347
* @param sigAlgo The enum Key_Sum of the authentication algorithm
1634616348
*/
16347-
void wolfSSL_get_sigalg_info(byte first, byte second,
16349+
int wolfSSL_get_sigalg_info(byte first, byte second,
1634816350
int* hashAlgo, int* sigAlgo)
1634916351
{
1635016352
byte input[2];
1635116353
byte hashType;
1635216354
byte sigType;
1635316355

1635416356
if (hashAlgo == NULL || sigAlgo == NULL)
16355-
return;
16357+
return BAD_FUNC_ARG;
1635616358

1635716359
input[0] = first;
1635816360
input[1] = second;
@@ -16406,7 +16408,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
1640616408
default:
1640716409
*hashAlgo = WC_HASH_TYPE_NONE;
1640816410
*sigAlgo = 0;
16409-
return;
16411+
return BAD_FUNC_ARG;
1641016412
}
1641116413

1641216414
/* cast so that compiler reminds us of unimplemented values */
@@ -16446,8 +16448,9 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
1644616448
default:
1644716449
*hashAlgo = WC_HASH_TYPE_NONE;
1644816450
*sigAlgo = 0;
16449-
return;
16451+
return BAD_FUNC_ARG;
1645016452
}
16453+
return 0;
1645116454
}
1645216455

1645316456
/**

tests/api.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44843,8 +44843,9 @@ static int test_wolfSSL_cert_cb_dyn_ciphers_certCB(WOLFSSL* ssl, void* arg)
4484344843

4484444844
(void)arg;
4484544845

44846-
wolfSSL_get_client_suites_sigalgs(ssl, &suites, &suiteSz, &hashSigAlgo,
44847-
&hashSigAlgoSz);
44846+
if (wolfSSL_get_client_suites_sigalgs(ssl, &suites, &suiteSz, &hashSigAlgo,
44847+
&hashSigAlgoSz) != WOLFSSL_SUCCESS)
44848+
return 0;
4484844849
if (suites == NULL || suiteSz == 0 || hashSigAlgo == NULL ||
4484944850
hashSigAlgoSz == 0)
4485044851
return 0;
@@ -44868,8 +44869,9 @@ static int test_wolfSSL_cert_cb_dyn_ciphers_certCB(WOLFSSL* ssl, void* arg)
4486844869
int hashAlgo;
4486944870
int sigAlgo;
4487044871

44871-
wolfSSL_get_sigalg_info(hashSigAlgo[idx+0], hashSigAlgo[idx+1],
44872-
&hashAlgo, &sigAlgo);
44872+
if (wolfSSL_get_sigalg_info(hashSigAlgo[idx+0], hashSigAlgo[idx+1],
44873+
&hashAlgo, &sigAlgo) != 0)
44874+
return 0;
4487344875

4487444876
if (sigAlgo == RSAk || sigAlgo == RSAPSSk)
4487544877
haveRSA = 1;
@@ -45081,8 +45083,8 @@ static int test_wolfSSL_sigalg_info(void)
4508145083
int hashAlgo;
4508245084
int sigAlgo;
4508345085

45084-
wolfSSL_get_sigalg_info(hashSigAlgo[idx+0], hashSigAlgo[idx+1],
45085-
&hashAlgo, &sigAlgo);
45086+
ExpectIntEQ(wolfSSL_get_sigalg_info(hashSigAlgo[idx+0],
45087+
hashSigAlgo[idx+1], &hashAlgo, &sigAlgo), 0);
4508645088

4508745089
ExpectIntNE(hashAlgo, 0);
4508845090
ExpectIntNE(sigAlgo, 0);
@@ -45094,8 +45096,8 @@ static int test_wolfSSL_sigalg_info(void)
4509445096
int hashAlgo;
4509545097
int sigAlgo;
4509645098

45097-
wolfSSL_get_sigalg_info(hashSigAlgo[idx+0], hashSigAlgo[idx+1],
45098-
&hashAlgo, &sigAlgo);
45099+
ExpectIntEQ(wolfSSL_get_sigalg_info(hashSigAlgo[idx+0],
45100+
hashSigAlgo[idx+1], &hashAlgo, &sigAlgo), 0);
4509945101

4510045102
ExpectIntNE(hashAlgo, 0);
4510145103
}

wolfssl/ssl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,7 @@ WOLFSSL_API void wolfSSL_CTX_set_client_cert_cb(WOLFSSL_CTX *ctx, client_cert_cb
21212121
typedef int (*CertSetupCallback)(WOLFSSL* ssl, void*);
21222122
WOLFSSL_API void wolfSSL_CTX_set_cert_cb(WOLFSSL_CTX* ctx,
21232123
CertSetupCallback cb, void *arg);
2124-
WOLFSSL_API void wolfSSL_get_client_suites_sigalgs(const WOLFSSL* ssl,
2124+
WOLFSSL_API int wolfSSL_get_client_suites_sigalgs(const WOLFSSL* ssl,
21252125
const byte** suites, word16* suiteSz,
21262126
const byte** hashSigAlgo, word16* hashSigAlgoSz);
21272127
typedef struct WOLFSSL_CIPHERSUITE_INFO {
@@ -2132,7 +2132,7 @@ typedef struct WOLFSSL_CIPHERSUITE_INFO {
21322132
} WOLFSSL_CIPHERSUITE_INFO;
21332133
WOLFSSL_API WOLFSSL_CIPHERSUITE_INFO wolfSSL_get_ciphersuite_info(byte first,
21342134
byte second);
2135-
WOLFSSL_API void wolfSSL_get_sigalg_info(byte first,
2135+
WOLFSSL_API int wolfSSL_get_sigalg_info(byte first,
21362136
byte second, int* hashAlgo, int* sigAlgo);
21372137
WOLFSSL_LOCAL int CertSetupCbWrapper(WOLFSSL* ssl);
21382138

0 commit comments

Comments
 (0)