diff options
Diffstat (limited to '')
| -rw-r--r-- | src/regress/lib/libssl/Makefile | 3 | ||||
| -rw-r--r-- | src/regress/lib/libssl/ciphers/Makefile | 9 | ||||
| -rw-r--r-- | src/regress/lib/libssl/ciphers/cipherstest.c | 119 |
3 files changed, 130 insertions, 1 deletions
diff --git a/src/regress/lib/libssl/Makefile b/src/regress/lib/libssl/Makefile index 00bc860d8e..f13ebf0b47 100644 --- a/src/regress/lib/libssl/Makefile +++ b/src/regress/lib/libssl/Makefile | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.19 2014/07/13 16:03:54 jsing Exp $ | 1 | # $OpenBSD: Makefile,v 1.20 2015/02/06 08:48:39 jsing Exp $ |
| 2 | 2 | ||
| 3 | SUBDIR= \ | 3 | SUBDIR= \ |
| 4 | asn1 \ | 4 | asn1 \ |
| 5 | ciphers \ | ||
| 5 | ssl | 6 | ssl |
| 6 | 7 | ||
| 7 | install: | 8 | install: |
diff --git a/src/regress/lib/libssl/ciphers/Makefile b/src/regress/lib/libssl/ciphers/Makefile new file mode 100644 index 0000000000..c9a58a5e09 --- /dev/null +++ b/src/regress/lib/libssl/ciphers/Makefile | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2015/02/06 08:48:39 jsing Exp $ | ||
| 2 | |||
| 3 | PROG= cipherstest | ||
| 4 | LDADD= -lssl -lcrypto | ||
| 5 | DPADD= ${LIBSSL} ${LIBCRYPTO} | ||
| 6 | WARNINGS= Yes | ||
| 7 | CFLAGS+= -DLIBRESSL_INTERNAL -Werror | ||
| 8 | |||
| 9 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libssl/ciphers/cipherstest.c b/src/regress/lib/libssl/ciphers/cipherstest.c new file mode 100644 index 0000000000..f9c4cdc7c1 --- /dev/null +++ b/src/regress/lib/libssl/ciphers/cipherstest.c | |||
| @@ -0,0 +1,119 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2015 Joel Sing <jsing@openbsd.org> | ||
| 3 | * | ||
| 4 | * Permission to use, copy, modify, and distribute this software for any | ||
| 5 | * purpose with or without fee is hereby granted, provided that the above | ||
| 6 | * copyright notice and this permission notice appear in all copies. | ||
| 7 | * | ||
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include <openssl/ssl.h> | ||
| 18 | |||
| 19 | #include <err.h> | ||
| 20 | #include <stdio.h> | ||
| 21 | #include <string.h> | ||
| 22 | |||
| 23 | static int | ||
| 24 | get_put_test(const char *name, const SSL_METHOD *method) | ||
| 25 | { | ||
| 26 | STACK_OF(SSL_CIPHER) *ciphers; | ||
| 27 | const SSL_CIPHER *cipher; | ||
| 28 | unsigned char buf[2]; | ||
| 29 | SSL_CTX *ssl_ctx = NULL; | ||
| 30 | SSL *ssl = NULL; | ||
| 31 | int ret = 1; | ||
| 32 | int i, len; | ||
| 33 | |||
| 34 | if ((len = method->put_cipher_by_char(NULL, NULL)) != 2) { | ||
| 35 | fprintf(stderr, | ||
| 36 | "%s: put_cipher_by_char() returned len %i (want 2)\n", | ||
| 37 | name, len); | ||
| 38 | return (1); | ||
| 39 | } | ||
| 40 | |||
| 41 | if ((ssl_ctx = SSL_CTX_new(method)) == NULL) { | ||
| 42 | fprintf(stderr, "%s: SSL_CTX_new() returned NULL\n", name); | ||
| 43 | goto failure; | ||
| 44 | } | ||
| 45 | if ((ssl = SSL_new(ssl_ctx)) == NULL) { | ||
| 46 | fprintf(stderr, "%s: SSL_new() returned NULL\n", name); | ||
| 47 | goto failure; | ||
| 48 | } | ||
| 49 | |||
| 50 | if ((ciphers = SSL_get_ciphers(ssl)) == NULL) { | ||
| 51 | fprintf(stderr, "%s: no ciphers\n", name); | ||
| 52 | goto failure; | ||
| 53 | } | ||
| 54 | |||
| 55 | for (i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) { | ||
| 56 | cipher = sk_SSL_CIPHER_value(ciphers, i); | ||
| 57 | if ((len = method->put_cipher_by_char(cipher, buf)) != 2) { | ||
| 58 | fprintf(stderr, | ||
| 59 | "%s: put_cipher_by_char() returned len %i for %s " | ||
| 60 | "(want 2)\n", | ||
| 61 | name, len, SSL_CIPHER_get_name(cipher)); | ||
| 62 | goto failure; | ||
| 63 | } | ||
| 64 | if ((cipher = method->get_cipher_by_char(buf)) == NULL) { | ||
| 65 | fprintf(stderr, | ||
| 66 | "%s: get_cipher_by_char() returned NULL for %s\n", | ||
| 67 | name, SSL_CIPHER_get_name(cipher)); | ||
| 68 | goto failure; | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | ret = 0; | ||
| 73 | |||
| 74 | failure: | ||
| 75 | SSL_CTX_free(ssl_ctx); | ||
| 76 | SSL_free(ssl); | ||
| 77 | |||
| 78 | return (ret); | ||
| 79 | } | ||
| 80 | |||
| 81 | static int | ||
| 82 | cipher_get_put_tests(void) | ||
| 83 | { | ||
| 84 | int failed = 0; | ||
| 85 | |||
| 86 | failed |= get_put_test("SSLv23", SSLv23_method()); | ||
| 87 | failed |= get_put_test("SSLv23_client", SSLv23_client_method()); | ||
| 88 | failed |= get_put_test("SSLv23_server", SSLv23_server_method()); | ||
| 89 | |||
| 90 | failed |= get_put_test("SSLv3", SSLv3_method()); | ||
| 91 | failed |= get_put_test("SSLv3_client", SSLv3_client_method()); | ||
| 92 | failed |= get_put_test("SSLv3_server", SSLv3_server_method()); | ||
| 93 | |||
| 94 | failed |= get_put_test("TLSv1", TLSv1_method()); | ||
| 95 | failed |= get_put_test("TLSv1_client", TLSv1_client_method()); | ||
| 96 | failed |= get_put_test("TLSv1_server", TLSv1_server_method()); | ||
| 97 | |||
| 98 | failed |= get_put_test("TLSv1_1", TLSv1_1_method()); | ||
| 99 | failed |= get_put_test("TLSv1_1_client", TLSv1_1_client_method()); | ||
| 100 | failed |= get_put_test("TLSv1_1_server", TLSv1_1_server_method()); | ||
| 101 | |||
| 102 | failed |= get_put_test("TLSv1_2", TLSv1_2_method()); | ||
| 103 | failed |= get_put_test("TLSv1_2_client", TLSv1_2_client_method()); | ||
| 104 | failed |= get_put_test("TLSv1_2_server", TLSv1_2_server_method()); | ||
| 105 | |||
| 106 | failed |= get_put_test("DTLSv1", DTLSv1_method()); | ||
| 107 | failed |= get_put_test("DTLSv1_client", DTLSv1_client_method()); | ||
| 108 | failed |= get_put_test("DTLSv1_server", DTLSv1_server_method()); | ||
| 109 | |||
| 110 | return failed; | ||
| 111 | } | ||
| 112 | |||
| 113 | int | ||
| 114 | main(int argc, char **argv) | ||
| 115 | { | ||
| 116 | SSL_library_init(); | ||
| 117 | |||
| 118 | return cipher_get_put_tests(); | ||
| 119 | } | ||
