@@ -16303,6 +16303,163 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
1630316303 ctx->certSetupCbArg = arg;
1630416304 }
1630516305
16306+ int wolfSSL_get_client_suites_sigalgs(const WOLFSSL* ssl,
16307+ const byte** suites, word16* suiteSz,
16308+ const byte** hashSigAlgo, word16* hashSigAlgoSz)
16309+ {
16310+ WOLFSSL_ENTER("wolfSSL_get_client_suites_sigalgs");
16311+
16312+ if (suites != NULL)
16313+ *suites = NULL;
16314+ if (suiteSz != NULL)
16315+ *suiteSz = 0;
16316+ if (hashSigAlgo != NULL)
16317+ *hashSigAlgo = NULL;
16318+ if (hashSigAlgoSz != NULL)
16319+ *hashSigAlgoSz = 0;
16320+
16321+ if (ssl != NULL && ssl->clSuites != NULL) {
16322+ if (suites != NULL && suiteSz != NULL) {
16323+ *suites = ssl->clSuites->suites;
16324+ *suiteSz = ssl->clSuites->suiteSz;
16325+ }
16326+ if (hashSigAlgo != NULL && hashSigAlgoSz != NULL) {
16327+ *hashSigAlgo = ssl->clSuites->hashSigAlgo;
16328+ *hashSigAlgoSz = ssl->clSuites->hashSigAlgoSz;
16329+ }
16330+ return WOLFSSL_SUCCESS;
16331+ }
16332+ return WOLFSSL_FAILURE;
16333+ }
16334+ WOLFSSL_CIPHERSUITE_INFO wolfSSL_get_ciphersuite_info(byte first,
16335+ byte second)
16336+ {
16337+ WOLFSSL_CIPHERSUITE_INFO info;
16338+ info.rsaAuth = (byte)(CipherRequires(first, second, REQUIRES_RSA) ||
16339+ CipherRequires(first, second, REQUIRES_RSA_SIG));
16340+ info.eccAuth = (byte)(CipherRequires(first, second, REQUIRES_ECC) ||
16341+ /* Static ECC ciphers may require RSA for authentication */
16342+ (CipherRequires(first, second, REQUIRES_ECC_STATIC) &&
16343+ !CipherRequires(first, second, REQUIRES_RSA_SIG)));
16344+ info.eccStatic =
16345+ (byte)CipherRequires(first, second, REQUIRES_ECC_STATIC);
16346+ info.psk = (byte)CipherRequires(first, second, REQUIRES_PSK);
16347+ return info;
16348+ }
16349+
16350+ /**
16351+ * @param first First byte of the hash and signature algorithm
16352+ * @param second Second byte of the hash and signature algorithm
16353+ * @param hashAlgo The enum wc_HashType of the MAC algorithm
16354+ * @param sigAlgo The enum Key_Sum of the authentication algorithm
16355+ */
16356+ int wolfSSL_get_sigalg_info(byte first, byte second,
16357+ int* hashAlgo, int* sigAlgo)
16358+ {
16359+ byte input[2];
16360+ byte hashType;
16361+ byte sigType;
16362+
16363+ if (hashAlgo == NULL || sigAlgo == NULL)
16364+ return BAD_FUNC_ARG;
16365+
16366+ input[0] = first;
16367+ input[1] = second;
16368+ DecodeSigAlg(input, &hashType, &sigType);
16369+
16370+ /* cast so that compiler reminds us of unimplemented values */
16371+ switch ((enum SignatureAlgorithm)sigType) {
16372+ case anonymous_sa_algo:
16373+ *sigAlgo = (enum Key_Sum)0;
16374+ break;
16375+ case rsa_sa_algo:
16376+ *sigAlgo = RSAk;
16377+ break;
16378+ case dsa_sa_algo:
16379+ *sigAlgo = DSAk;
16380+ break;
16381+ case ecc_dsa_sa_algo:
16382+ *sigAlgo = ECDSAk;
16383+ break;
16384+ case rsa_pss_sa_algo:
16385+ *sigAlgo = RSAPSSk;
16386+ break;
16387+ case ed25519_sa_algo:
16388+ *sigAlgo = ED25519k;
16389+ break;
16390+ case rsa_pss_pss_algo:
16391+ *sigAlgo = RSAPSSk;
16392+ break;
16393+ case ed448_sa_algo:
16394+ *sigAlgo = ED448k;
16395+ break;
16396+ case falcon_level1_sa_algo:
16397+ *sigAlgo = FALCON_LEVEL1k;
16398+ break;
16399+ case falcon_level5_sa_algo:
16400+ *sigAlgo = FALCON_LEVEL5k;
16401+ break;
16402+ case dilithium_level2_sa_algo:
16403+ *sigAlgo = DILITHIUM_LEVEL2k;
16404+ break;
16405+ case dilithium_level3_sa_algo:
16406+ *sigAlgo = DILITHIUM_LEVEL3k;
16407+ break;
16408+ case dilithium_level5_sa_algo:
16409+ *sigAlgo = DILITHIUM_LEVEL5k;
16410+ break;
16411+ case sm2_sa_algo:
16412+ *sigAlgo = SM2k;
16413+ break;
16414+ case invalid_sa_algo:
16415+ default:
16416+ *hashAlgo = WC_HASH_TYPE_NONE;
16417+ *sigAlgo = 0;
16418+ return BAD_FUNC_ARG;
16419+ }
16420+
16421+ /* cast so that compiler reminds us of unimplemented values */
16422+ switch((enum wc_MACAlgorithm)hashType) {
16423+ case no_mac:
16424+ case rmd_mac: /* Don't have a RIPEMD type in wc_HashType */
16425+ *hashAlgo = WC_HASH_TYPE_NONE;
16426+ break;
16427+ case md5_mac:
16428+ *hashAlgo = WC_HASH_TYPE_MD5;
16429+ break;
16430+ case sha_mac:
16431+ *hashAlgo = WC_HASH_TYPE_SHA;
16432+ break;
16433+ case sha224_mac:
16434+ *hashAlgo = WC_HASH_TYPE_SHA224;
16435+ break;
16436+ case sha256_mac:
16437+ *hashAlgo = WC_HASH_TYPE_SHA256;
16438+ break;
16439+ case sha384_mac:
16440+ *hashAlgo = WC_HASH_TYPE_SHA384;
16441+ break;
16442+ case sha512_mac:
16443+ *hashAlgo = WC_HASH_TYPE_SHA512;
16444+ break;
16445+ case blake2b_mac:
16446+ *hashAlgo = WC_HASH_TYPE_BLAKE2B;
16447+ break;
16448+ case sm3_mac:
16449+ #ifdef WOLFSSL_SM3
16450+ *hashAlgo = WC_HASH_TYPE_SM3;
16451+ #else
16452+ *hashAlgo = WC_HASH_TYPE_NONE;
16453+ #endif
16454+ break;
16455+ default:
16456+ *hashAlgo = WC_HASH_TYPE_NONE;
16457+ *sigAlgo = 0;
16458+ return BAD_FUNC_ARG;
16459+ }
16460+ return 0;
16461+ }
16462+
1630616463 /**
1630716464 * Internal wrapper for calling certSetupCb
1630816465 * @param ssl The SSL/TLS Object
0 commit comments