Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /* This program demonstrates the use of SSL_GetCipherSuiteInfo to avoid
6 * all compiled-in knowledge of SSL cipher suites.
7 *
8 * Try: ./listsuites | grep -v : | sort -b +4rn -5 +1 -2 +2 -3 +3 -4 +5r -6
9 */
11 #include <errno.h>
12 #include <stdio.h>
13 #include "secport.h"
14 #include "ssl.h"
16 int main(int argc, char **argv)
17 {
18 const PRUint16 *cipherSuites = SSL_ImplementedCiphers;
19 int i;
20 int errCount = 0;
22 fputs("This version of libSSL supports these cipher suites:\n\n", stdout);
24 /* disable all the SSL3 cipher suites */
25 for (i = 0; i < SSL_NumImplementedCiphers; i++) {
26 PRUint16 suite = cipherSuites[i];
27 SECStatus rv;
28 PRBool enabled;
29 PRErrorCode err;
30 SSLCipherSuiteInfo info;
32 rv = SSL_CipherPrefGetDefault(suite, &enabled);
33 if (rv != SECSuccess) {
34 err = PR_GetError();
35 ++errCount;
36 fprintf(stderr,
37 "SSL_CipherPrefGetDefault didn't like value 0x%04x (i = %d): %s\n",
38 suite, i, PORT_ErrorToString(err));
39 continue;
40 }
41 rv = SSL_GetCipherSuiteInfo(suite, &info, (int)(sizeof info));
42 if (rv != SECSuccess) {
43 err = PR_GetError();
44 ++errCount;
45 fprintf(stderr,
46 "SSL_GetCipherSuiteInfo didn't like value 0x%04x (i = %d): %s\n",
47 suite, i, PORT_ErrorToString(err));
48 continue;
49 }
50 fprintf(stdout,
51 "%s:\n" /* up to 37 spaces */
52 " 0x%04hx %-5s %-5s %-8s %3hd %-6s %-8s %-4s %-8s %-11s\n",
53 info.cipherSuiteName, info.cipherSuite,
54 info.keaTypeName, info.authAlgorithmName, info.symCipherName,
55 info.effectiveKeyBits, info.macAlgorithmName,
56 enabled ? "Enabled" : "Disabled",
57 info.isFIPS ? "FIPS" :
58 (SSL_IS_SSL2_CIPHER(info.cipherSuite) ? "SSL2" : ""),
59 info.isExportable ? "Export" : "Domestic",
60 info.nonStandard ? "nonStandard" : "");
61 }
62 return errCount;
63 }