@@ -66130,6 +66130,77 @@ static int test_extra_alerts_bad_psk(void)
6613066130}
6613166131#endif
6613266132
66133+ #if defined(WOLFSSL_TLS13) && defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES)\
66134+ && !defined(NO_PSK)
66135+ static unsigned int test_tls13_bad_psk_binder_client_cb(WOLFSSL* ssl,
66136+ const char* hint, char* identity, unsigned int id_max_len,
66137+ unsigned char* key, unsigned int key_max_len)
66138+ {
66139+ (void)ssl;
66140+ (void)hint;
66141+ (void)key_max_len;
66142+
66143+ /* see internal.h MAX_PSK_ID_LEN for PSK identity limit */
66144+ XSTRNCPY(identity, "Client_identity", id_max_len);
66145+
66146+ key[0] = 0x20;
66147+ return 1;
66148+ }
66149+
66150+ static unsigned int test_tls13_bad_psk_binder_server_cb(WOLFSSL* ssl,
66151+ const char* id, unsigned char* key, unsigned int key_max_len)
66152+ {
66153+ (void)ssl;
66154+ (void)id;
66155+ (void)key_max_len;
66156+ /* zero means error */
66157+ key[0] = 0x10;
66158+ return 1;
66159+ }
66160+ #endif
66161+
66162+ static int test_tls13_bad_psk_binder(void)
66163+ {
66164+ EXPECT_DECLS;
66165+ #if defined(WOLFSSL_TLS13) && defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES)\
66166+ && !defined(NO_PSK)
66167+ WOLFSSL_CTX *ctx_c = NULL;
66168+ WOLFSSL_CTX *ctx_s = NULL;
66169+ WOLFSSL *ssl_c = NULL;
66170+ WOLFSSL *ssl_s = NULL;
66171+ struct test_memio_ctx test_ctx;
66172+ WOLFSSL_ALERT_HISTORY h;
66173+
66174+ XMEMSET(&test_ctx, 0, sizeof(test_ctx));
66175+ ExpectIntEQ(test_memio_setup(&test_ctx, &ctx_c, &ctx_s, &ssl_c, &ssl_s,
66176+ wolfTLSv1_3_client_method, wolfTLSv1_3_server_method), 0);
66177+
66178+ wolfSSL_set_psk_client_callback(ssl_c, test_tls13_bad_psk_binder_client_cb);
66179+ wolfSSL_set_psk_server_callback(ssl_s, test_tls13_bad_psk_binder_server_cb);
66180+
66181+ ExpectIntNE(wolfSSL_connect(ssl_c), WOLFSSL_SUCCESS);
66182+ ExpectIntEQ(wolfSSL_get_error(ssl_c, WOLFSSL_FATAL_ERROR),
66183+ WOLFSSL_ERROR_WANT_READ);
66184+
66185+ ExpectIntNE(wolfSSL_accept(ssl_s), WOLFSSL_SUCCESS);
66186+ ExpectIntEQ( wolfSSL_get_error(ssl_s, WOLFSSL_FATAL_ERROR),
66187+ BAD_BINDER);
66188+
66189+ ExpectIntNE(wolfSSL_connect(ssl_c), WOLFSSL_SUCCESS);
66190+ ExpectIntEQ(wolfSSL_get_error(ssl_c, WOLFSSL_FATAL_ERROR),
66191+ FATAL_ERROR);
66192+ ExpectIntEQ(wolfSSL_get_alert_history(ssl_c, &h), WOLFSSL_SUCCESS);
66193+ ExpectIntEQ(h.last_rx.code, illegal_parameter);
66194+ ExpectIntEQ(h.last_rx.level, alert_fatal);
66195+
66196+ wolfSSL_free(ssl_c);
66197+ wolfSSL_CTX_free(ctx_c);
66198+ wolfSSL_free(ssl_s);
66199+ wolfSSL_CTX_free(ctx_s);
66200+ #endif
66201+ return EXPECT_RESULT();
66202+ }
66203+
6613366204#if defined(WOLFSSL_HARDEN_TLS) && !defined(WOLFSSL_NO_TLS12) && \
6613466205 defined(HAVE_IO_TESTS_DEPENDENCIES)
6613566206static int test_harden_no_secure_renegotiation_io_cb(WOLFSSL *ssl, char *buf,
@@ -70873,6 +70944,7 @@ TEST_CASE testCases[] = {
7087370944 TEST_DECL(test_extra_alerts_wrong_cs),
7087470945 TEST_DECL(test_extra_alerts_skip_hs),
7087570946 TEST_DECL(test_extra_alerts_bad_psk),
70947+ TEST_DECL(test_tls13_bad_psk_binder),
7087670948 /* Can't memory test as client/server Asserts. */
7087770949 TEST_DECL(test_harden_no_secure_renegotiation),
7087870950 TEST_DECL(test_override_alt_cert_chain),
0 commit comments