diff --git a/doc/dox_comments/header_files/ssl.h b/doc/dox_comments/header_files/ssl.h index 0c7302142..5965f11d3 100644 --- a/doc/dox_comments/header_files/ssl.h +++ b/doc/dox_comments/header_files/ssl.h @@ -14865,10 +14865,13 @@ int wolfSSL_dtls_cid_get_tx(WOLFSSL* ssl, unsigned char* buffer, ciphersuites and signature algorithms. \param [in] ssl The WOLFSSL object to extract the lists from. - \param [out] suites Raw and unfiltered list of client ciphersuites - \param [out] suiteSz Size of suites in bytes - \param [out] hashSigAlgo Raw and unfiltered list of client signature algorithms - \param [out] hashSigAlgoSz Size of hashSigAlgo in bytes + \param [out] optional suites Raw and unfiltered list of client ciphersuites + \param [out] optional suiteSz Size of suites in bytes + \param [out] optional hashSigAlgo Raw and unfiltered list of client + signature algorithms + \param [out] optional hashSigAlgoSz Size of hashSigAlgo in bytes + \return WOLFSSL_SUCCESS when suites available + \return WOLFSSL_FAILURE when suites not available _Example_ \code @@ -14893,7 +14896,7 @@ int wolfSSL_dtls_cid_get_tx(WOLFSSL* ssl, unsigned char* buffer, \sa wolfSSL_get_ciphersuite_info \sa wolfSSL_get_sigalg_info */ -void wolfSSL_get_client_suites_sigalgs(const WOLFSSL* ssl, +int wolfSSL_get_client_suites_sigalgs(const WOLFSSL* ssl, const byte** suites, word16* suiteSz, const byte** hashSigAlgo, word16* hashSigAlgoSz); @@ -14936,6 +14939,10 @@ WOLFSSL_CIPHERSUITE_INFO wolfSSL_get_ciphersuite_info(byte first, \param [out] hashAlgo The enum wc_HashType of the MAC algorithm \param [out] sigAlgo The enum Key_Sum of the authentication algorithm + \return 0 when info was correctly set + \return BAD_FUNC_ARG when either input paramters are NULL or the bytes + are not a recognized sigalg suite + _Example_ \code enum wc_HashType hashAlgo; @@ -14953,5 +14960,5 @@ WOLFSSL_CIPHERSUITE_INFO wolfSSL_get_ciphersuite_info(byte first, \sa wolfSSL_get_client_suites_sigalgs \sa wolfSSL_get_ciphersuite_info */ -void wolfSSL_get_sigalg_info(byte first, byte second, +int wolfSSL_get_sigalg_info(byte first, byte second, int* hashAlgo, int* sigAlgo); diff --git a/src/ssl.c b/src/ssl.c index 1b89cd65d..8a271c9d0 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -16296,7 +16296,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) ctx->certSetupCbArg = arg; } - void wolfSSL_get_client_suites_sigalgs(const WOLFSSL* ssl, + int wolfSSL_get_client_suites_sigalgs(const WOLFSSL* ssl, const byte** suites, word16* suiteSz, const byte** hashSigAlgo, word16* hashSigAlgoSz) { @@ -16320,7 +16320,9 @@ int wolfSSL_set_compression(WOLFSSL* ssl) *hashSigAlgo = ssl->clSuites->hashSigAlgo; *hashSigAlgoSz = ssl->clSuites->hashSigAlgoSz; } + return WOLFSSL_SUCCESS; } + return WOLFSSL_FAILURE; } WOLFSSL_CIPHERSUITE_INFO wolfSSL_get_ciphersuite_info(byte first, byte second) @@ -16344,7 +16346,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) * @param hashAlgo The enum wc_HashType of the MAC algorithm * @param sigAlgo The enum Key_Sum of the authentication algorithm */ - void wolfSSL_get_sigalg_info(byte first, byte second, + int wolfSSL_get_sigalg_info(byte first, byte second, int* hashAlgo, int* sigAlgo) { byte input[2]; @@ -16352,7 +16354,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) byte sigType; if (hashAlgo == NULL || sigAlgo == NULL) - return; + return BAD_FUNC_ARG; input[0] = first; input[1] = second; @@ -16406,7 +16408,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) default: *hashAlgo = WC_HASH_TYPE_NONE; *sigAlgo = 0; - return; + return BAD_FUNC_ARG; } /* cast so that compiler reminds us of unimplemented values */ @@ -16446,8 +16448,9 @@ int wolfSSL_set_compression(WOLFSSL* ssl) default: *hashAlgo = WC_HASH_TYPE_NONE; *sigAlgo = 0; - return; + return BAD_FUNC_ARG; } + return 0; } /** diff --git a/tests/api.c b/tests/api.c index 2acd9bc0f..0cc6e59dd 100644 --- a/tests/api.c +++ b/tests/api.c @@ -44843,8 +44843,9 @@ static int test_wolfSSL_cert_cb_dyn_ciphers_certCB(WOLFSSL* ssl, void* arg) (void)arg; - wolfSSL_get_client_suites_sigalgs(ssl, &suites, &suiteSz, &hashSigAlgo, - &hashSigAlgoSz); + if (wolfSSL_get_client_suites_sigalgs(ssl, &suites, &suiteSz, &hashSigAlgo, + &hashSigAlgoSz) != WOLFSSL_SUCCESS) + return 0; if (suites == NULL || suiteSz == 0 || hashSigAlgo == NULL || hashSigAlgoSz == 0) return 0; @@ -44868,8 +44869,9 @@ static int test_wolfSSL_cert_cb_dyn_ciphers_certCB(WOLFSSL* ssl, void* arg) int hashAlgo; int sigAlgo; - wolfSSL_get_sigalg_info(hashSigAlgo[idx+0], hashSigAlgo[idx+1], - &hashAlgo, &sigAlgo); + if (wolfSSL_get_sigalg_info(hashSigAlgo[idx+0], hashSigAlgo[idx+1], + &hashAlgo, &sigAlgo) != 0) + return 0; if (sigAlgo == RSAk || sigAlgo == RSAPSSk) haveRSA = 1; @@ -45081,8 +45083,8 @@ static int test_wolfSSL_sigalg_info(void) int hashAlgo; int sigAlgo; - wolfSSL_get_sigalg_info(hashSigAlgo[idx+0], hashSigAlgo[idx+1], - &hashAlgo, &sigAlgo); + ExpectIntEQ(wolfSSL_get_sigalg_info(hashSigAlgo[idx+0], + hashSigAlgo[idx+1], &hashAlgo, &sigAlgo), 0); ExpectIntNE(hashAlgo, 0); ExpectIntNE(sigAlgo, 0); @@ -45094,8 +45096,8 @@ static int test_wolfSSL_sigalg_info(void) int hashAlgo; int sigAlgo; - wolfSSL_get_sigalg_info(hashSigAlgo[idx+0], hashSigAlgo[idx+1], - &hashAlgo, &sigAlgo); + ExpectIntEQ(wolfSSL_get_sigalg_info(hashSigAlgo[idx+0], + hashSigAlgo[idx+1], &hashAlgo, &sigAlgo), 0); ExpectIntNE(hashAlgo, 0); } diff --git a/wolfssl/ssl.h b/wolfssl/ssl.h index a0263f28a..c78d6b6f7 100644 --- a/wolfssl/ssl.h +++ b/wolfssl/ssl.h @@ -2121,7 +2121,7 @@ WOLFSSL_API void wolfSSL_CTX_set_client_cert_cb(WOLFSSL_CTX *ctx, client_cert_cb typedef int (*CertSetupCallback)(WOLFSSL* ssl, void*); WOLFSSL_API void wolfSSL_CTX_set_cert_cb(WOLFSSL_CTX* ctx, CertSetupCallback cb, void *arg); -WOLFSSL_API void wolfSSL_get_client_suites_sigalgs(const WOLFSSL* ssl, +WOLFSSL_API int wolfSSL_get_client_suites_sigalgs(const WOLFSSL* ssl, const byte** suites, word16* suiteSz, const byte** hashSigAlgo, word16* hashSigAlgoSz); typedef struct WOLFSSL_CIPHERSUITE_INFO { @@ -2132,7 +2132,7 @@ typedef struct WOLFSSL_CIPHERSUITE_INFO { } WOLFSSL_CIPHERSUITE_INFO; WOLFSSL_API WOLFSSL_CIPHERSUITE_INFO wolfSSL_get_ciphersuite_info(byte first, byte second); -WOLFSSL_API void wolfSSL_get_sigalg_info(byte first, +WOLFSSL_API int wolfSSL_get_sigalg_info(byte first, byte second, int* hashAlgo, int* sigAlgo); WOLFSSL_LOCAL int CertSetupCbWrapper(WOLFSSL* ssl);