forked from wolfSSL/wolfssl
Fix for TLS v1.3 PSK tests work with additional cipher suites (not just TLS13-AES128-GCM-SHA256
) and the echo server/client.
This commit is contained in:
@ -2305,16 +2305,17 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
||||
|
||||
if (usePsk) {
|
||||
#ifndef NO_PSK
|
||||
const char *defaultCipherList = cipherList;
|
||||
|
||||
wolfSSL_CTX_set_psk_client_callback(ctx, my_psk_client_cb);
|
||||
#ifdef WOLFSSL_TLS13
|
||||
wolfSSL_CTX_set_psk_client_tls13_callback(ctx, my_psk_client_tls13_cb);
|
||||
#endif
|
||||
if (cipherList == NULL) {
|
||||
const char *defaultCipherList;
|
||||
if (defaultCipherList == NULL) {
|
||||
#if defined(HAVE_AESGCM) && !defined(NO_DH)
|
||||
#ifdef WOLFSSL_TLS13
|
||||
defaultCipherList = "DHE-PSK-AES128-GCM-SHA256:"
|
||||
"TLS13-AES128-GCM-SHA256";
|
||||
defaultCipherList = "TLS13-AES128-GCM-SHA256:"
|
||||
"DHE-PSK-AES128-GCM-SHA256:";
|
||||
#else
|
||||
defaultCipherList = "DHE-PSK-AES128-GCM-SHA256";
|
||||
#endif
|
||||
@ -2323,12 +2324,13 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
||||
#else
|
||||
defaultCipherList = "PSK-AES128-CBC-SHA256";
|
||||
#endif
|
||||
if (wolfSSL_CTX_set_cipher_list(ctx,defaultCipherList)
|
||||
if (wolfSSL_CTX_set_cipher_list(ctx, defaultCipherList)
|
||||
!=WOLFSSL_SUCCESS) {
|
||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||
err_sys("client can't set cipher list 2");
|
||||
}
|
||||
}
|
||||
wolfSSL_CTX_set_psk_callback_ctx(ctx, (void*)defaultCipherList);
|
||||
#endif
|
||||
if (useClientCert) {
|
||||
useClientCert = 0;
|
||||
|
@ -164,12 +164,18 @@ void echoclient_test(void* args)
|
||||
#ifdef HAVE_NULL_CIPHER
|
||||
defaultCipherList = "PSK-NULL-SHA256";
|
||||
#elif defined(HAVE_AESGCM) && !defined(NO_DH)
|
||||
#ifdef WOLFSSL_TLS13
|
||||
defaultCipherList = "TLS13-AES128-GCM-SHA256:"
|
||||
"DHE-PSK-AES128-GCM-SHA256:";
|
||||
#else
|
||||
defaultCipherList = "DHE-PSK-AES128-GCM-SHA256";
|
||||
#endif
|
||||
#else
|
||||
defaultCipherList = "PSK-AES128-CBC-SHA256";
|
||||
#endif
|
||||
if (CyaSSL_CTX_set_cipher_list(ctx,defaultCipherList) !=WOLFSSL_SUCCESS)
|
||||
err_sys("client can't set cipher list 2");
|
||||
wolfSSL_CTX_set_psk_callback_ctx(ctx, (void*)defaultCipherList);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -243,12 +243,18 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
|
||||
#ifdef HAVE_NULL_CIPHER
|
||||
defaultCipherList = "PSK-NULL-SHA256";
|
||||
#elif defined(HAVE_AESGCM) && !defined(NO_DH)
|
||||
#ifdef WOLFSSL_TLS13
|
||||
defaultCipherList = "TLS13-AES128-GCM-SHA256:"
|
||||
"DHE-PSK-AES128-GCM-SHA256";
|
||||
#else
|
||||
defaultCipherList = "DHE-PSK-AES128-GCM-SHA256";
|
||||
#endif
|
||||
#else
|
||||
defaultCipherList = "PSK-AES128-CBC-SHA256";
|
||||
#endif
|
||||
if (CyaSSL_CTX_set_cipher_list(ctx, defaultCipherList) != WOLFSSL_SUCCESS)
|
||||
err_sys("server can't set cipher list 2");
|
||||
wolfSSL_CTX_set_psk_callback_ctx(ctx, (void*)defaultCipherList);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1731,20 +1731,20 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
|
||||
if (usePsk || usePskPlus) {
|
||||
#ifndef NO_PSK
|
||||
const char *defaultCipherList = cipherList;
|
||||
|
||||
SSL_CTX_set_psk_server_callback(ctx, my_psk_server_cb);
|
||||
#ifdef WOLFSSL_TLS13
|
||||
wolfSSL_CTX_set_psk_server_tls13_callback(ctx, my_psk_server_tls13_cb);
|
||||
#endif
|
||||
|
||||
if (sendPskIdentityHint == 1)
|
||||
SSL_CTX_use_psk_identity_hint(ctx, "cyassl server");
|
||||
|
||||
if (cipherList == NULL && !usePskPlus) {
|
||||
const char *defaultCipherList;
|
||||
if (defaultCipherList == NULL && !usePskPlus) {
|
||||
#if defined(HAVE_AESGCM) && !defined(NO_DH)
|
||||
#ifdef WOLFSSL_TLS13
|
||||
defaultCipherList = "DHE-PSK-AES128-GCM-SHA256:"
|
||||
"TLS13-AES128-GCM-SHA256";
|
||||
defaultCipherList = "TLS13-AES128-GCM-SHA256:"
|
||||
"DHE-PSK-AES128-GCM-SHA256";
|
||||
#else
|
||||
defaultCipherList = "DHE-PSK-AES128-GCM-SHA256";
|
||||
#endif
|
||||
@ -1758,7 +1758,8 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
!= WOLFSSL_SUCCESS)
|
||||
err_sys_ex(runWithErrors, "server can't set cipher list 2");
|
||||
}
|
||||
#endif
|
||||
wolfSSL_CTX_set_psk_callback_ctx(ctx, (void*)defaultCipherList);
|
||||
#endif /* !NO_PSK */
|
||||
}
|
||||
#ifndef NO_CERTS
|
||||
if (mutualAuth)
|
||||
|
@ -1302,7 +1302,7 @@ static WC_INLINE unsigned int my_psk_client_cb(WOLFSSL* ssl, const char* hint,
|
||||
(void)key_max_len;
|
||||
|
||||
/* see internal.h MAX_PSK_ID_LEN for PSK identity limit */
|
||||
strncpy(identity, kIdentityStr, id_max_len);
|
||||
XSTRNCPY(identity, kIdentityStr, id_max_len);
|
||||
|
||||
if (wolfSSL_GetVersion(ssl) < WOLFSSL_TLSV1_3) {
|
||||
/* test key in hex is 0x1a2b3c4d , in decimal 439,041,101 , we're using
|
||||
@ -1336,7 +1336,7 @@ static WC_INLINE unsigned int my_psk_server_cb(WOLFSSL* ssl, const char* identit
|
||||
(void)key_max_len;
|
||||
|
||||
/* see internal.h MAX_PSK_ID_LEN for PSK identity limit */
|
||||
if (strncmp(identity, kIdentityStr, strlen(kIdentityStr)) != 0)
|
||||
if (XSTRNCMP(identity, kIdentityStr, XSTRLEN(kIdentityStr)) != 0)
|
||||
return 0;
|
||||
|
||||
if (wolfSSL_GetVersion(ssl) < WOLFSSL_TLSV1_3) {
|
||||
@ -1370,13 +1370,14 @@ static WC_INLINE unsigned int my_psk_client_tls13_cb(WOLFSSL* ssl,
|
||||
{
|
||||
int i;
|
||||
int b = 0x01;
|
||||
const char* userCipher = (const char*)wolfSSL_get_psk_callback_ctx(ssl);
|
||||
|
||||
(void)ssl;
|
||||
(void)hint;
|
||||
(void)key_max_len;
|
||||
|
||||
/* see internal.h MAX_PSK_ID_LEN for PSK identity limit */
|
||||
strncpy(identity, kIdentityStr, id_max_len);
|
||||
XSTRNCPY(identity, kIdentityStr, id_max_len);
|
||||
|
||||
for (i = 0; i < 32; i++, b += 0x22) {
|
||||
if (b >= 0x100)
|
||||
@ -1384,7 +1385,7 @@ static WC_INLINE unsigned int my_psk_client_tls13_cb(WOLFSSL* ssl,
|
||||
key[i] = b;
|
||||
}
|
||||
|
||||
*ciphersuite = "TLS13-AES128-GCM-SHA256";
|
||||
*ciphersuite = userCipher ? userCipher : "TLS13-AES128-GCM-SHA256";
|
||||
|
||||
return 32; /* length of key in octets or 0 for error */
|
||||
}
|
||||
@ -1396,12 +1397,13 @@ static WC_INLINE unsigned int my_psk_server_tls13_cb(WOLFSSL* ssl,
|
||||
{
|
||||
int i;
|
||||
int b = 0x01;
|
||||
const char* userCipher = (const char*)wolfSSL_get_psk_callback_ctx(ssl);
|
||||
|
||||
(void)ssl;
|
||||
(void)key_max_len;
|
||||
|
||||
/* see internal.h MAX_PSK_ID_LEN for PSK identity limit */
|
||||
if (strncmp(identity, kIdentityStr, strlen(kIdentityStr)) != 0)
|
||||
if (XSTRNCMP(identity, kIdentityStr, XSTRLEN(kIdentityStr)) != 0)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < 32; i++, b += 0x22) {
|
||||
@ -1410,12 +1412,12 @@ static WC_INLINE unsigned int my_psk_server_tls13_cb(WOLFSSL* ssl,
|
||||
key[i] = b;
|
||||
}
|
||||
|
||||
*ciphersuite = "TLS13-AES128-GCM-SHA256";
|
||||
*ciphersuite = userCipher ? userCipher : "TLS13-AES128-GCM-SHA256";
|
||||
|
||||
return 32; /* length of key in octets or 0 for error */
|
||||
}
|
||||
|
||||
#endif /* NO_PSK */
|
||||
#endif /* !NO_PSK */
|
||||
|
||||
|
||||
#if defined(WOLFSSL_USER_CURRTIME)
|
||||
|
Reference in New Issue
Block a user