summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2015-02-07 04:20:23 +0000
committerjsing <>2015-02-07 04:20:23 +0000
commit8be6550862be7d914bef6a13291d7b523db088da (patch)
treed15bc71e5251d3a58710795be4420aedc087c9fa
parentbe1d02917370f48d43c5e741fbb7b49e6aaa7484 (diff)
downloadopenbsd-8be6550862be7d914bef6a13291d7b523db088da.tar.gz
openbsd-8be6550862be7d914bef6a13291d7b523db088da.tar.bz2
openbsd-8be6550862be7d914bef6a13291d7b523db088da.zip
Add regress tests for SSL_CIPHER_get_by_value() and SSL_CIPHER_get_by_id().
-rw-r--r--src/regress/lib/libssl/ciphers/cipherstest.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/src/regress/lib/libssl/ciphers/cipherstest.c b/src/regress/lib/libssl/ciphers/cipherstest.c
index f9c4cdc7c1..b20ec8bd52 100644
--- a/src/regress/lib/libssl/ciphers/cipherstest.c
+++ b/src/regress/lib/libssl/ciphers/cipherstest.c
@@ -110,10 +110,70 @@ cipher_get_put_tests(void)
110 return failed; 110 return failed;
111} 111}
112 112
113static int
114cipher_get_by_value_tests(void)
115{
116 STACK_OF(SSL_CIPHER) *ciphers;
117 const SSL_CIPHER *cipher;
118 SSL_CTX *ssl_ctx = NULL;
119 SSL *ssl = NULL;
120 unsigned long id;
121 uint16_t value;
122 int ret = 1;
123 int i;
124
125 if ((ssl_ctx = SSL_CTX_new(SSLv23_method())) == NULL) {
126 fprintf(stderr, "SSL_CTX_new() returned NULL\n");
127 goto failure;
128 }
129 if ((ssl = SSL_new(ssl_ctx)) == NULL) {
130 fprintf(stderr, "SSL_new() returned NULL\n");
131 goto failure;
132 }
133
134 if ((ciphers = SSL_get_ciphers(ssl)) == NULL) {
135 fprintf(stderr, "no ciphers\n");
136 goto failure;
137 }
138
139 for (i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) {
140 cipher = sk_SSL_CIPHER_value(ciphers, i);
141
142 id = SSL_CIPHER_get_id(cipher);
143 if (SSL_CIPHER_get_by_id(id) == NULL) {
144 fprintf(stderr, "SSL_CIPHER_get_by_id() failed "
145 "for %s (0x%lx)\n", SSL_CIPHER_get_name(cipher),
146 id);
147 goto failure;
148 }
149
150 value = SSL_CIPHER_get_value(cipher);
151 if (SSL_CIPHER_get_by_value(value) == NULL) {
152 fprintf(stderr, "SSL_CIPHER_get_by_value() failed "
153 "for %s (0x%04hx)\n", SSL_CIPHER_get_name(cipher),
154 value);
155 goto failure;
156 }
157 }
158
159 ret = 0;
160
161failure:
162 SSL_CTX_free(ssl_ctx);
163 SSL_free(ssl);
164
165 return (ret);
166}
167
113int 168int
114main(int argc, char **argv) 169main(int argc, char **argv)
115{ 170{
171 int failed = 0;
172
116 SSL_library_init(); 173 SSL_library_init();
117 174
118 return cipher_get_put_tests(); 175 failed |= cipher_get_put_tests();
176 failed |= cipher_get_by_value_tests();
177
178 return (failed);
119} 179}