forked from wolfSSL/wolfssl
build test covers leanpsk
This commit is contained in:
@@ -274,22 +274,37 @@ void client_test(void* args)
|
|||||||
if (CyaSSL_CTX_set_cipher_list(ctx, cipherList) != SSL_SUCCESS)
|
if (CyaSSL_CTX_set_cipher_list(ctx, cipherList) != SSL_SUCCESS)
|
||||||
err_sys("can't set cipher list");
|
err_sys("can't set cipher list");
|
||||||
|
|
||||||
#ifndef NO_PSK
|
#ifdef CYASSL_LEANPSK
|
||||||
if (usePsk)
|
usePsk = 1;
|
||||||
CyaSSL_CTX_set_psk_client_callback(ctx, my_psk_client_cb);
|
|
||||||
#else
|
|
||||||
(void)usePsk;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (usePsk) {
|
||||||
|
#ifndef NO_PSK
|
||||||
|
CyaSSL_CTX_set_psk_client_callback(ctx, my_psk_client_cb);
|
||||||
|
CyaSSL_CTX_use_psk_identity_hint(ctx, "cyassl_client");
|
||||||
|
if (cipherList == NULL) {
|
||||||
|
const char *defaultCipherList;
|
||||||
|
#ifdef HAVE_NULL_CIPHER
|
||||||
|
defaultCipherList = "PSK-NULL-SHA";
|
||||||
|
#else
|
||||||
|
defaultCipherList = "PSK-AES256-CBC-SHA";
|
||||||
|
#endif
|
||||||
|
if (CyaSSL_CTX_set_cipher_list(ctx,defaultCipherList) !=SSL_SUCCESS)
|
||||||
|
err_sys("can't set cipher list");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef OPENSSL_EXTRA
|
#ifdef OPENSSL_EXTRA
|
||||||
CyaSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
|
CyaSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CYASSL_SNIFFER) && !defined(HAVE_NTRU) && !defined(HAVE_ECC)
|
#if defined(CYASSL_SNIFFER) && !defined(HAVE_NTRU) && !defined(HAVE_ECC)
|
||||||
/* don't use EDH, can't sniff tmp keys */
|
|
||||||
if (cipherList == NULL) {
|
if (cipherList == NULL) {
|
||||||
if (CyaSSL_CTX_set_cipher_list(ctx, "AES256-SHA") != SSL_SUCCESS)
|
/* don't use EDH, can't sniff tmp keys */
|
||||||
|
if (CyaSSL_CTX_set_cipher_list(ctx, "AES256-SHA") != SSL_SUCCESS) {
|
||||||
err_sys("can't set cipher list");
|
err_sys("can't set cipher list");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -46,6 +46,7 @@ void echoclient_test(void* args)
|
|||||||
SSL* ssl = 0;
|
SSL* ssl = 0;
|
||||||
|
|
||||||
int doDTLS = 0;
|
int doDTLS = 0;
|
||||||
|
int doLeanPSK = 0;
|
||||||
int sendSz;
|
int sendSz;
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
char** argv = 0;
|
char** argv = 0;
|
||||||
@@ -70,6 +71,10 @@ void echoclient_test(void* args)
|
|||||||
doDTLS = 1;
|
doDTLS = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CYASSL_LEANPSK
|
||||||
|
doLeanPSK = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CYASSL_DTLS)
|
#if defined(CYASSL_DTLS)
|
||||||
method = DTLSv1_client_method();
|
method = DTLSv1_client_method();
|
||||||
#elif !defined(NO_TLS)
|
#elif !defined(NO_TLS)
|
||||||
@@ -87,13 +92,20 @@ void echoclient_test(void* args)
|
|||||||
err_sys("can't load ca file, Please run from CyaSSL home dir");
|
err_sys("can't load ca file, Please run from CyaSSL home dir");
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
load_buffer(ctx, caCert, CYASSL_CA);
|
if (!doLeanPSK)
|
||||||
|
load_buffer(ctx, caCert, CYASSL_CA);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CYASSL_SNIFFER) && !defined(HAVE_NTRU) && !defined(HAVE_ECC)
|
#if defined(CYASSL_SNIFFER) && !defined(HAVE_NTRU) && !defined(HAVE_ECC)
|
||||||
/* don't use EDH, can't sniff tmp keys */
|
/* don't use EDH, can't sniff tmp keys */
|
||||||
SSL_CTX_set_cipher_list(ctx, "AES256-SHA");
|
SSL_CTX_set_cipher_list(ctx, "AES256-SHA");
|
||||||
#endif
|
#endif
|
||||||
|
if (doLeanPSK) {
|
||||||
|
#ifdef CYASSL_LEANPSK
|
||||||
|
CyaSSL_CTX_set_psk_client_callback(ctx, my_psk_client_cb);
|
||||||
|
SSL_CTX_set_cipher_list(ctx, "PSK-NULL-SHA");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef OPENSSL_EXTRA
|
#ifdef OPENSSL_EXTRA
|
||||||
SSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
|
SSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
|
||||||
|
@@ -60,6 +60,7 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
|
|||||||
CYASSL_CTX* ctx = 0;
|
CYASSL_CTX* ctx = 0;
|
||||||
|
|
||||||
int doDTLS = 0;
|
int doDTLS = 0;
|
||||||
|
int doLeanPSK = 0;
|
||||||
int outCreated = 0;
|
int outCreated = 0;
|
||||||
int shutDown = 0;
|
int shutDown = 0;
|
||||||
int useAnyAddr = 0;
|
int useAnyAddr = 0;
|
||||||
@@ -84,6 +85,10 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
|
|||||||
doDTLS = 1;
|
doDTLS = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CYASSL_LEANPSK
|
||||||
|
doLeanPSK = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
tcp_listen(&sockfd, yasslPort, useAnyAddr, doDTLS);
|
tcp_listen(&sockfd, yasslPort, useAnyAddr, doDTLS);
|
||||||
|
|
||||||
#if defined(CYASSL_DTLS)
|
#if defined(CYASSL_DTLS)
|
||||||
@@ -136,8 +141,10 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
|
|||||||
"Please run from CyaSSL home dir");
|
"Please run from CyaSSL home dir");
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
load_buffer(ctx, svrCert, CYASSL_CERT);
|
if (!doLeanPSK) {
|
||||||
load_buffer(ctx, svrKey, CYASSL_KEY);
|
load_buffer(ctx, svrCert, CYASSL_CERT);
|
||||||
|
load_buffer(ctx, svrKey, CYASSL_KEY);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CYASSL_SNIFFER) && !defined(HAVE_NTRU) && !defined(HAVE_ECC)
|
#if defined(CYASSL_SNIFFER) && !defined(HAVE_NTRU) && !defined(HAVE_ECC)
|
||||||
@@ -145,6 +152,13 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args)
|
|||||||
CyaSSL_CTX_set_cipher_list(ctx, "AES256-SHA");
|
CyaSSL_CTX_set_cipher_list(ctx, "AES256-SHA");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (doLeanPSK) {
|
||||||
|
#ifdef CYASSL_LEANPSK
|
||||||
|
CyaSSL_CTX_set_psk_server_callback(ctx, my_psk_server_cb);
|
||||||
|
CyaSSL_CTX_set_cipher_list(ctx, "PSK-NULL-SHA");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
SignalReady(args);
|
SignalReady(args);
|
||||||
|
|
||||||
while (!shutDown) {
|
while (!shutDown) {
|
||||||
|
@@ -242,6 +242,10 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
|||||||
if (SSL_CTX_set_cipher_list(ctx, cipherList) != SSL_SUCCESS)
|
if (SSL_CTX_set_cipher_list(ctx, cipherList) != SSL_SUCCESS)
|
||||||
err_sys("can't set cipher list");
|
err_sys("can't set cipher list");
|
||||||
|
|
||||||
|
#ifdef CYASSL_LEANPSK
|
||||||
|
usePsk = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef NO_FILESYSTEM
|
#ifndef NO_FILESYSTEM
|
||||||
if (!usePsk) {
|
if (!usePsk) {
|
||||||
if (SSL_CTX_use_certificate_file(ctx, ourCert, SSL_FILETYPE_PEM)
|
if (SSL_CTX_use_certificate_file(ctx, ourCert, SSL_FILETYPE_PEM)
|
||||||
@@ -269,15 +273,22 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NO_PSK
|
|
||||||
if (usePsk) {
|
if (usePsk) {
|
||||||
|
#ifndef NO_PSK
|
||||||
SSL_CTX_set_psk_server_callback(ctx, my_psk_server_cb);
|
SSL_CTX_set_psk_server_callback(ctx, my_psk_server_cb);
|
||||||
SSL_CTX_use_psk_identity_hint(ctx, "cyassl server");
|
SSL_CTX_use_psk_identity_hint(ctx, "cyassl server");
|
||||||
if (cipherList == NULL)
|
if (cipherList == NULL) {
|
||||||
if (SSL_CTX_set_cipher_list(ctx,"PSK-AES256-CBC-SHA") !=SSL_SUCCESS)
|
const char *defaultCipherList;
|
||||||
|
#ifdef HAVE_NULL_CIPHER
|
||||||
|
defaultCipherList = "PSK-NULL-SHA";
|
||||||
|
#else
|
||||||
|
defaultCipherList = "PSK-AES256-CBC-SHA";
|
||||||
|
#endif
|
||||||
|
if (SSL_CTX_set_cipher_list(ctx, defaultCipherList) != SSL_SUCCESS)
|
||||||
err_sys("can't set cipher list");
|
err_sys("can't set cipher list");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef NO_FILESYSTEM
|
#ifndef NO_FILESYSTEM
|
||||||
/* if not using PSK, verify peer with certs */
|
/* if not using PSK, verify peer with certs */
|
||||||
|
Reference in New Issue
Block a user