summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libssl/ciphers/cipherstest.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/regress/lib/libssl/ciphers/cipherstest.c b/src/regress/lib/libssl/ciphers/cipherstest.c
index f3bd841130..c43939d4d5 100644
--- a/src/regress/lib/libssl/ciphers/cipherstest.c
+++ b/src/regress/lib/libssl/ciphers/cipherstest.c
@@ -20,6 +20,9 @@
20#include <stdio.h> 20#include <stdio.h>
21#include <string.h> 21#include <string.h>
22 22
23int ssl3_num_ciphers(void);
24const SSL_CIPHER *ssl3_get_cipher(unsigned int u);
25
23int ssl_parse_ciphersuites(STACK_OF(SSL_CIPHER) **out_ciphers, const char *str); 26int ssl_parse_ciphersuites(STACK_OF(SSL_CIPHER) **out_ciphers, const char *str);
24 27
25static inline int 28static inline int
@@ -33,6 +36,38 @@ ssl_aes_is_accelerated(void)
33} 36}
34 37
35static int 38static int
39check_cipher_order(void)
40{
41 unsigned long id, prev_id = 0;
42 const SSL_CIPHER *cipher;
43 int num_ciphers;
44 int i;
45
46 num_ciphers = ssl3_num_ciphers();
47
48 for (i = 1; i <= num_ciphers; i++) {
49 /*
50 * For some reason, ssl3_get_cipher() returns ciphers in
51 * reverse order.
52 */
53 if ((cipher = ssl3_get_cipher(num_ciphers - i)) == NULL) {
54 fprintf(stderr, "FAIL: ssl3_get_cipher(%d) returned "
55 "NULL\n", i);
56 return 1;
57 }
58 if ((id = SSL_CIPHER_get_id(cipher)) <= prev_id) {
59 fprintf(stderr, "FAIL: ssl3_ciphers is not sorted by "
60 "id - cipher %d (%lx) <= cipher %d (%lx)\n",
61 i, id, i - 1, prev_id);
62 return 1;
63 }
64 prev_id = id;
65 }
66
67 return 0;
68}
69
70static int
36cipher_find_test(void) 71cipher_find_test(void)
37{ 72{
38 STACK_OF(SSL_CIPHER) *ciphers; 73 STACK_OF(SSL_CIPHER) *ciphers;
@@ -484,6 +519,8 @@ main(int argc, char **argv)
484{ 519{
485 int failed = 0; 520 int failed = 0;
486 521
522 failed |= check_cipher_order();
523
487 failed |= cipher_find_test(); 524 failed |= cipher_find_test();
488 failed |= cipher_get_by_value_tests(); 525 failed |= cipher_get_by_value_tests();
489 526