From c4674c0cc3c09b20fa0beb760177ce144ce9fa47 Mon Sep 17 00:00:00 2001 From: toddouska Date: Tue, 7 Aug 2012 17:18:56 -0700 Subject: [PATCH] add ntru cipher suite tests --- examples/server/server.c | 25 ++++++-- tests/include.am | 3 +- tests/suites.c | 11 ++++ tests/test-ntru.conf | 132 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 166 insertions(+), 5 deletions(-) create mode 100644 tests/test-ntru.conf diff --git a/examples/server/server.c b/examples/server/server.c index 5100b140d..a33a4efb9 100644 --- a/examples/server/server.c +++ b/examples/server/server.c @@ -101,6 +101,7 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args) int port = yasslPort; int usePsk = 0; int doDTLS = 0; + int useNtruKey = 0; char* cipherList = NULL; char* verifyCert = (char*)cliCert; char* ourCert = (char*)svrCert; @@ -110,7 +111,7 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args) ((func_args*)args)->return_code = -1; /* error state */ - while ((ch = mygetopt(argc, argv, "?dbsup:v:l:A:c:k:")) != -1) { + while ((ch = mygetopt(argc, argv, "?dbsnup:v:l:A:c:k:")) != -1) { switch (ch) { case '?' : Usage(); @@ -128,6 +129,10 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args) usePsk = 1; break; + case 'n' : + useNtruKey = 1; + break; + case 'u' : doDTLS = 1; version = -1; /* DTLS flag */ @@ -216,10 +221,22 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args) err_sys("can't load server cert file, check file and run from" " CyaSSL home dir"); - if (SSL_CTX_use_PrivateKey_file(ctx, ourKey, SSL_FILETYPE_PEM) - != SSL_SUCCESS) - err_sys("can't load server cert file, check file and run from" + +#ifdef HAVE_NTRU + if (useNtruKey) { + if (CyaSSL_CTX_use_NTRUPrivateKey_file(ctx, ourKey) + != SSL_SUCCESS) + err_sys("can't load ntru key file, " + "Please run from CyaSSL home dir"); + } +#endif + + if (!useNtruKey) { + if (SSL_CTX_use_PrivateKey_file(ctx, ourKey, SSL_FILETYPE_PEM) + != SSL_SUCCESS) + err_sys("can't load server cert file, check file and run from" " CyaSSL home dir"); + } #ifndef NO_PSK if (usePsk) { diff --git a/tests/include.am b/tests/include.am index 9c793239b..85c236e47 100644 --- a/tests/include.am +++ b/tests/include.am @@ -19,4 +19,5 @@ EXTRA_DIST += tests/unit.h EXTRA_DIST += tests/test.conf \ tests/test-openssl.conf \ tests/test-hc128.conf \ - tests/test-psk.conf + tests/test-psk.conf \ + tests/test-ntru.conf diff --git a/tests/suites.c b/tests/suites.c index 252b9e626..3c33da8cf 100644 --- a/tests/suites.c +++ b/tests/suites.c @@ -269,6 +269,17 @@ int SuiteTest(void) } #endif +#ifdef HAVE_NTRU + /* add ntru extra suites */ + strcpy(argv0[1], "tests/test-ntru.conf"); + printf("starting ntru extra cipher suite tests\n"); + test_harness(&args); + if (args.return_code != 0) { + printf("error from script %d\n", args.return_code); + exit(EXIT_FAILURE); + } +#endif + printf(" End Cipher Suite Tests\n"); return args.return_code; diff --git a/tests/test-ntru.conf b/tests/test-ntru.conf new file mode 100644 index 000000000..7674fb572 --- /dev/null +++ b/tests/test-ntru.conf @@ -0,0 +1,132 @@ +# server TLSv1 NTRU_RC4 +-v 1 +-l NTRU-RC4-SHA +-n +-c ./certs/ntru-cert.pem +-k ./certs/ntru-key.raw + +# client TLSv1 NTRU_RC4 +-v 1 +-l NTRU-RC4-SHA + +# server TLSv1 NTRU_DES3 +-v 1 +-l NTRU-DES-CBC3-SHA +-n +-c ./certs/ntru-cert.pem +-k ./certs/ntru-key.raw + +# client TLSv1 NTRU_DES3 +-v 1 +-l NTRU-DES-CBC3-SHA + +# server TLSv1 NTRU_AES128 +-v 1 +-l NTRU-AES128-SHA +-n +-c ./certs/ntru-cert.pem +-k ./certs/ntru-key.raw + +# client TLSv1 NTRU_AES128 +-v 1 +-l NTRU-AES128-SHA + +# server TLSv1 NTRU_AES256 +-v 1 +-l NTRU-AES256-SHA +-n +-c ./certs/ntru-cert.pem +-k ./certs/ntru-key.raw + +# client TLSv1 NTRU_AES256 +-v 1 +-l NTRU-AES256-SHA + +# server TLSv1.1 NTRU_RC4 +-v 2 +-l NTRU-RC4-SHA +-n +-c ./certs/ntru-cert.pem +-k ./certs/ntru-key.raw + +# client TLSv1.1 NTRU_RC4 +-v 2 +-l NTRU-RC4-SHA + +# server TLSv1.1 NTRU_DES3 +-v 2 +-l NTRU-DES-CBC3-SHA +-n +-c ./certs/ntru-cert.pem +-k ./certs/ntru-key.raw + +# client TLSv1.1 NTRU_DES3 +-v 2 +-l NTRU-DES-CBC3-SHA + +# server TLSv1.1 NTRU_AES128 +-v 2 +-l NTRU-AES128-SHA +-n +-c ./certs/ntru-cert.pem +-k ./certs/ntru-key.raw + +# client TLSv1.1 NTRU_AES128 +-v 2 +-l NTRU-AES128-SHA + +# server TLSv1.1 NTRU_AES256 +-v 2 +-l NTRU-AES256-SHA +-n +-c ./certs/ntru-cert.pem +-k ./certs/ntru-key.raw + +# client TLSv1.1 NTRU_AES256 +-v 2 +-l NTRU-AES256-SHA + +# server TLSv1.2 NTRU_RC4 +-v 3 +-l NTRU-RC4-SHA +-n +-c ./certs/ntru-cert.pem +-k ./certs/ntru-key.raw + +# client TLSv1.2 NTRU_RC4 +-v 3 +-l NTRU-RC4-SHA + +# server TLSv1.2 NTRU_DES3 +-v 3 +-l NTRU-DES-CBC3-SHA +-n +-c ./certs/ntru-cert.pem +-k ./certs/ntru-key.raw + +# client TLSv1.2 NTRU_DES3 +-v 3 +-l NTRU-DES-CBC3-SHA + +# server TLSv1.2 NTRU_AES128 +-v 3 +-l NTRU-AES128-SHA +-n +-c ./certs/ntru-cert.pem +-k ./certs/ntru-key.raw + +# client TLSv1.2 NTRU_AES128 +-v 3 +-l NTRU-AES128-SHA + +# server TLSv1.2 NTRU_AES256 +-v 3 +-l NTRU-AES256-SHA +-n +-c ./certs/ntru-cert.pem +-k ./certs/ntru-key.raw + +# client TLSv1.2 NTRU_AES256 +-v 3 +-l NTRU-AES256-SHA +