@@ -20743,6 +20743,23 @@ static int test_EccSigFailure_cm(void)
2074320743#endif /* !NO_RSA || HAVE_ECC */
2074420744#endif /* NO_CERTS */
2074520745
20746+ static int test_wc_CheckPrivateKey_RSA_pub_only(void)
20747+ {
20748+ EXPECT_DECLS;
20749+ #if !defined(NO_RSA) && !defined(NO_ASN_CRYPT) && \
20750+ !defined(NO_CHECK_PRIVATE_KEY) && \
20751+ (defined(WOLFSSL_RSA_PUBLIC_ONLY) || defined(WOLFSSL_RSA_VERIFY_ONLY))
20752+ /* With RSA public-only or verify-only, wc_CheckPrivateKey should return
20753+ * NOT_COMPILED_IN for RSA key types since private key operations are not
20754+ * available. */
20755+ ExpectIntEQ(wc_CheckPrivateKey(server_key_der_2048,
20756+ sizeof_server_key_der_2048, server_cert_der_2048,
20757+ sizeof_server_cert_der_2048, RSAk, NULL),
20758+ WC_NO_ERR_TRACE(NOT_COMPILED_IN));
20759+ #endif
20760+ return EXPECT_RESULT();
20761+ }
20762+
2074620763#if defined(HAVE_PK_CALLBACKS) && !defined(WOLFSSL_NO_TLS12)
2074720764#if !defined(NO_FILESYSTEM) && !defined(NO_DH) && \
2074820765 !defined(NO_AES) && defined(HAVE_AES_CBC) && \
@@ -31782,6 +31799,7 @@ TEST_CASE testCases[] = {
3178231799 TEST_DECL(test_EccSigFailure_cm),
3178331800 TEST_DECL(test_RsaSigFailure_cm),
3178431801#endif
31802+ TEST_DECL(test_wc_CheckPrivateKey_RSA_pub_only),
3178531803
3178631804 /* PKCS8 testing */
3178731805 TEST_DECL(test_wolfSSL_no_password_cb),
0 commit comments