diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2015-02-07 04:20:24 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2015-02-07 04:20:24 +0000 |
commit | 084d7988d49da5039c98224578ba885f4a4cae86 (patch) | |
tree | bcdd1d1df97c18f728cb98f13135ba479f6f37c7 /regress/lib | |
parent | c15009cc7fff9e8ec61c9cd9323b54a92dc8bbcc (diff) |
Add regress tests for SSL_CIPHER_get_by_value() and SSL_CIPHER_get_by_id().
Diffstat (limited to 'regress/lib')
-rw-r--r-- | regress/lib/libssl/ciphers/cipherstest.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/regress/lib/libssl/ciphers/cipherstest.c b/regress/lib/libssl/ciphers/cipherstest.c index f9c4cdc7c11..b20ec8bd528 100644 --- a/regress/lib/libssl/ciphers/cipherstest.c +++ b/regress/lib/libssl/ciphers/cipherstest.c @@ -110,10 +110,70 @@ cipher_get_put_tests(void) return failed; } +static int +cipher_get_by_value_tests(void) +{ + STACK_OF(SSL_CIPHER) *ciphers; + const SSL_CIPHER *cipher; + SSL_CTX *ssl_ctx = NULL; + SSL *ssl = NULL; + unsigned long id; + uint16_t value; + int ret = 1; + int i; + + if ((ssl_ctx = SSL_CTX_new(SSLv23_method())) == NULL) { + fprintf(stderr, "SSL_CTX_new() returned NULL\n"); + goto failure; + } + if ((ssl = SSL_new(ssl_ctx)) == NULL) { + fprintf(stderr, "SSL_new() returned NULL\n"); + goto failure; + } + + if ((ciphers = SSL_get_ciphers(ssl)) == NULL) { + fprintf(stderr, "no ciphers\n"); + goto failure; + } + + for (i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) { + cipher = sk_SSL_CIPHER_value(ciphers, i); + + id = SSL_CIPHER_get_id(cipher); + if (SSL_CIPHER_get_by_id(id) == NULL) { + fprintf(stderr, "SSL_CIPHER_get_by_id() failed " + "for %s (0x%lx)\n", SSL_CIPHER_get_name(cipher), + id); + goto failure; + } + + value = SSL_CIPHER_get_value(cipher); + if (SSL_CIPHER_get_by_value(value) == NULL) { + fprintf(stderr, "SSL_CIPHER_get_by_value() failed " + "for %s (0x%04hx)\n", SSL_CIPHER_get_name(cipher), + value); + goto failure; + } + } + + ret = 0; + +failure: + SSL_CTX_free(ssl_ctx); + SSL_free(ssl); + + return (ret); +} + int main(int argc, char **argv) { + int failed = 0; + SSL_library_init(); - return cipher_get_put_tests(); + failed |= cipher_get_put_tests(); + failed |= cipher_get_by_value_tests(); + + return (failed); } |