diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2013-11-08 22:14:07 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2013-11-08 22:17:10 +0100 |
commit | 76c93d23c073ef8b885503b7d28a31ffe2add6d8 (patch) | |
tree | 1dd2d22a197bc40c5330e516969a7cb1ae9bc96f /tests/priorities.c | |
parent | 559a144f6bbcbb611453f82e655dd7438c14d1a7 (diff) | |
download | gnutls-76c93d23c073ef8b885503b7d28a31ffe2add6d8.tar.gz |
reindented code
Diffstat (limited to 'tests/priorities.c')
-rw-r--r-- | tests/priorities.c | 135 |
1 files changed, 66 insertions, 69 deletions
diff --git a/tests/priorities.c b/tests/priorities.c index 751cbfd19c..bf183fe164 100644 --- a/tests/priorities.c +++ b/tests/priorities.c @@ -32,83 +32,80 @@ #include "utils.h" static void -try_prio (const char* prio, unsigned expected_cs, unsigned expected_ciphers) +try_prio(const char *prio, unsigned expected_cs, unsigned expected_ciphers) { -int ret; -gnutls_priority_t p; -const char* err; -const unsigned int * t; -unsigned i, si, count = 0; + int ret; + gnutls_priority_t p; + const char *err; + const unsigned int *t; + unsigned i, si, count = 0; - /* this must be called once in the program - */ - global_init (); - - ret = gnutls_priority_init(&p, prio, &err); - if (ret < 0) - { - fprintf(stderr, "error: %s: %s\n", gnutls_strerror(ret), err); - exit(1); - } - - for (i=0;;i++) - { - ret = gnutls_priority_get_cipher_suite_index(p, i, &si); - if (ret == GNUTLS_E_UNKNOWN_CIPHER_SUITE) - continue; - else if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) - break; - else if (ret == 0) - { - count++; - /* fprintf(stderr, "%s\n", gnutls_cipher_suite_info(si, NULL, NULL, NULL, NULL, NULL)); */ - } + /* this must be called once in the program + */ + global_init(); - } - - ret = gnutls_priority_cipher_list (p, &t); - if ((unsigned)ret != expected_ciphers) - { + ret = gnutls_priority_init(&p, prio, &err); + if (ret < 0) { + fprintf(stderr, "error: %s: %s\n", gnutls_strerror(ret), + err); + exit(1); + } + + for (i = 0;; i++) { + ret = gnutls_priority_get_cipher_suite_index(p, i, &si); + if (ret == GNUTLS_E_UNKNOWN_CIPHER_SUITE) + continue; + else if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) + break; + else if (ret == 0) { + count++; + /* fprintf(stderr, "%s\n", gnutls_cipher_suite_info(si, NULL, NULL, NULL, NULL, NULL)); */ + } + + } + + ret = gnutls_priority_cipher_list(p, &t); + if ((unsigned) ret != expected_ciphers) { #if 0 -for (i=0;i<ret;i++) - fprintf(stderr, "%s\n", gnutls_cipher_get_name(t[i])); + for (i = 0; i < ret; i++) + fprintf(stderr, "%s\n", + gnutls_cipher_get_name(t[i])); #endif - fail("expected %d ciphers, found %d\n", expected_ciphers, ret); - exit(1); - } - - gnutls_priority_deinit(p); - - /* fprintf(stderr, "count: %d\n", count); */ + fail("expected %d ciphers, found %d\n", expected_ciphers, + ret); + exit(1); + } + + gnutls_priority_deinit(p); - if (debug) - success ("finished: %s\n", prio); - - if (count != expected_cs) - { - fail("expected %d ciphersuites, found %d\n", expected_cs, count); - exit(1); - } + /* fprintf(stderr, "count: %d\n", count); */ + + if (debug) + success("finished: %s\n", prio); + + if (count != expected_cs) { + fail("expected %d ciphersuites, found %d\n", expected_cs, + count); + exit(1); + } } -void -doit (void) +void doit(void) { -const int normal = 66; -const int null = 5; -const int sec128 = 56; + const int normal = 66; + const int null = 5; + const int sec128 = 56; - try_prio("NORMAL", normal, 10); - try_prio("NORMAL:-MAC-ALL:+MD5:+MAC-ALL", normal, 10); - try_prio("NORMAL:+CIPHER-ALL", normal, 10); /* all (except null) */ - try_prio("NORMAL:-CIPHER-ALL:+NULL", null, 1); /* null */ - try_prio("NORMAL:-CIPHER-ALL:+NULL:+CIPHER-ALL", normal+null, 11); /* should be null + all */ - try_prio("NORMAL:-CIPHER-ALL:+NULL:+CIPHER-ALL:-CIPHER-ALL:+AES-128-CBC", 10, 1); /* should be null + all */ - try_prio("PERFORMANCE", normal, 10); - try_prio("SECURE256", 20, 4); - try_prio("SECURE128", sec128, 8); - try_prio("SECURE128:+SECURE256", sec128, 8); /* should be the same as SECURE128 */ - try_prio("SECURE128:+SECURE256:+NORMAL", normal, 10); /* should be the same as NORMAL */ - try_prio("SUITEB192", 1, 1); + try_prio("NORMAL", normal, 10); + try_prio("NORMAL:-MAC-ALL:+MD5:+MAC-ALL", normal, 10); + try_prio("NORMAL:+CIPHER-ALL", normal, 10); /* all (except null) */ + try_prio("NORMAL:-CIPHER-ALL:+NULL", null, 1); /* null */ + try_prio("NORMAL:-CIPHER-ALL:+NULL:+CIPHER-ALL", normal + null, 11); /* should be null + all */ + try_prio("NORMAL:-CIPHER-ALL:+NULL:+CIPHER-ALL:-CIPHER-ALL:+AES-128-CBC", 10, 1); /* should be null + all */ + try_prio("PERFORMANCE", normal, 10); + try_prio("SECURE256", 20, 4); + try_prio("SECURE128", sec128, 8); + try_prio("SECURE128:+SECURE256", sec128, 8); /* should be the same as SECURE128 */ + try_prio("SECURE128:+SECURE256:+NORMAL", normal, 10); /* should be the same as NORMAL */ + try_prio("SUITEB192", 1, 1); } - |