@@ -1683,6 +1683,38 @@ static int test_dual_alg_ecdsa_mldsa(void)
16831683 return EXPECT_RESULT();
16841684}
16851685
1686+ /* Test wolfSSL_use_AltPrivateKey_Id.
1687+ * Verify that a valid key ID can be set successfully. Guards against an
1688+ * inverted AllocDer return check (== 0 vs != 0) that would treat successful
1689+ * allocation as failure. */
1690+ static int test_wolfSSL_use_AltPrivateKey_Id(void)
1691+ {
1692+ EXPECT_DECLS;
1693+ #if defined(WOLFSSL_DUAL_ALG_CERTS) && !defined(NO_TLS) && \
1694+ !defined(NO_WOLFSSL_CLIENT)
1695+ WOLFSSL_CTX* ctx = NULL;
1696+ WOLFSSL* ssl = NULL;
1697+ const unsigned char id[] = { 0x01, 0x02, 0x03, 0x04 };
1698+
1699+ ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()));
1700+ ExpectNotNull(ssl = wolfSSL_new(ctx));
1701+
1702+ /* Negative tests. */
1703+ ExpectIntEQ(wolfSSL_use_AltPrivateKey_Id(NULL, id, sizeof(id),
1704+ INVALID_DEVID), 0);
1705+ ExpectIntEQ(wolfSSL_use_AltPrivateKey_Id(ssl, NULL, sizeof(id),
1706+ INVALID_DEVID), 0);
1707+
1708+ /* Positive test — valid ID should succeed. */
1709+ ExpectIntEQ(wolfSSL_use_AltPrivateKey_Id(ssl, id, sizeof(id),
1710+ INVALID_DEVID), 1);
1711+
1712+ wolfSSL_free(ssl);
1713+ wolfSSL_CTX_free(ctx);
1714+ #endif /* WOLFSSL_DUAL_ALG_CERTS && !NO_TLS && !NO_WOLFSSL_CLIENT */
1715+ return EXPECT_RESULT();
1716+ }
1717+
16861718
16871719/*----------------------------------------------------------------------------*
16881720 | Context
@@ -35125,6 +35157,8 @@ TEST_CASE testCases[] = {
3512535157
3512635158 TEST_DECL(test_dual_alg_ecdsa_mldsa),
3512735159
35160+ TEST_DECL(test_wolfSSL_use_AltPrivateKey_Id),
35161+
3512835162 /*********************************
3512935163 * OpenSSL compatibility API tests
3513035164 *********************************/
0 commit comments