2 * Copyright (C) 2012 Free Software Foundation, Inc.
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of GnuTLS.
8 * GnuTLS is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * GnuTLS is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with GnuTLS; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
30 #include <gnutls/gnutls.h>
34 #if defined(ENABLE_FIPS140) || defined(ENABLE_ARCFOUR128)
43 try_prio(const char *prio, unsigned expected_cs, unsigned expected_ciphers)
48 const unsigned int *t;
49 unsigned i, si, count = 0;
51 /* this must be called once in the program
55 ret = gnutls_priority_init(&p, prio, &err);
57 fprintf(stderr, "error: %s: %s\n", gnutls_strerror(ret),
63 ret = gnutls_priority_get_cipher_suite_index(p, i, &si);
64 if (ret == GNUTLS_E_UNKNOWN_CIPHER_SUITE)
66 else if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
70 /* fprintf(stderr, "%s\n", gnutls_cipher_suite_info(si, NULL, NULL, NULL, NULL, NULL)); */
75 ret = gnutls_priority_cipher_list(p, &t);
76 if ((unsigned) ret != expected_ciphers) {
78 for (i = 0; i < ret; i++)
79 fprintf(stderr, "%s\n",
80 gnutls_cipher_get_name(t[i]));
82 fail("expected %d ciphers, found %d\n", expected_ciphers,
87 gnutls_priority_deinit(p);
89 /* fprintf(stderr, "count: %d\n", count); */
92 success("finished: %s\n", prio);
94 if (count != expected_cs) {
95 fail("expected %d ciphersuites, found %d\n", expected_cs,
103 const int normal = 61;
105 const int sec128 = 56;
107 try_prio("NORMAL", normal, 9);
108 try_prio("NORMAL:-MAC-ALL:+MD5:+MAC-ALL", normal, 9);
109 try_prio("NORMAL:+CIPHER-ALL", normal, 9); /* all (except null) */
110 try_prio("NORMAL:-CIPHER-ALL:+NULL", null, 1); /* null */
111 try_prio("NORMAL:-CIPHER-ALL:+NULL:+CIPHER-ALL", normal + null, 10); /* should be null + all */
112 try_prio("NORMAL:-CIPHER-ALL:+NULL:+CIPHER-ALL:-CIPHER-ALL:+AES-128-CBC", 10, 1); /* should be null + all */
113 try_prio("PERFORMANCE", normal, 9);
114 try_prio("SECURE256", 20, 4);
115 try_prio("SECURE128", sec128, 8);
116 try_prio("SECURE128:+SECURE256", sec128, 8); /* should be the same as SECURE128 */
117 try_prio("SECURE128:+SECURE256:+NORMAL", normal, 9); /* should be the same as NORMAL */
118 try_prio("SUITEB192", 1, 1);