@@ -1696,6 +1696,38 @@ static int test_dual_alg_ecdsa_mldsa(void)
16961696 return EXPECT_RESULT();
16971697}
16981698
1699+ /* Test wolfSSL_use_AltPrivateKey_Id.
1700+ * Verify that a valid key ID can be set successfully. Guards against an
1701+ * inverted AllocDer return check (== 0 vs != 0) that would treat successful
1702+ * allocation as failure. */
1703+ static int test_wolfSSL_use_AltPrivateKey_Id(void)
1704+ {
1705+ EXPECT_DECLS;
1706+ #if defined(WOLFSSL_DUAL_ALG_CERTS) && !defined(NO_TLS) && \
1707+ !defined(NO_WOLFSSL_CLIENT)
1708+ WOLFSSL_CTX* ctx = NULL;
1709+ WOLFSSL* ssl = NULL;
1710+ const unsigned char id[] = { 0x01, 0x02, 0x03, 0x04 };
1711+
1712+ ExpectNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()));
1713+ ExpectNotNull(ssl = wolfSSL_new(ctx));
1714+
1715+ /* Negative tests. */
1716+ ExpectIntEQ(wolfSSL_use_AltPrivateKey_Id(NULL, id, sizeof(id),
1717+ INVALID_DEVID), 0);
1718+ ExpectIntEQ(wolfSSL_use_AltPrivateKey_Id(ssl, NULL, sizeof(id),
1719+ INVALID_DEVID), 0);
1720+
1721+ /* Positive test — valid ID should succeed. */
1722+ ExpectIntEQ(wolfSSL_use_AltPrivateKey_Id(ssl, id, sizeof(id),
1723+ INVALID_DEVID), 1);
1724+
1725+ wolfSSL_free(ssl);
1726+ wolfSSL_CTX_free(ctx);
1727+ #endif /* WOLFSSL_DUAL_ALG_CERTS && !NO_TLS && !NO_WOLFSSL_CLIENT */
1728+ return EXPECT_RESULT();
1729+ }
1730+
16991731
17001732/*----------------------------------------------------------------------------*
17011733 | Context
@@ -35313,6 +35345,8 @@ TEST_CASE testCases[] = {
3531335345
3531435346 TEST_DECL(test_dual_alg_ecdsa_mldsa),
3531535347
35348+ TEST_DECL(test_wolfSSL_use_AltPrivateKey_Id),
35349+
3531635350 /*********************************
3531735351 * OpenSSL compatibility API tests
3531835352 *********************************/
0 commit comments