libpurple/plugins/ssl/nss-prefs.c

Fri, 07 Nov 2014 14:27:01 -0500

author
Daniel Atallah <datallah@pidgin.im>
date
Fri, 07 Nov 2014 14:27:01 -0500
changeset 36237
47cc3f47592c
parent 36235
6f5e35bda0c9
child 37159
c6b3ecaaf2d4
permissions
-rw-r--r--

Fix merged NSS stuff for 3.0.0 (hopefully)

36228
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
1 /*
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
2 * Plugin to configure NSS
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
3 *
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2014, Daniel Atallah <datallah@pidgin.im>
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
5 *
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
8 * published by the Free Software Foundation; either version 2 of the
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
9 * License, or (at your option) any later version.
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
10 *
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful, but
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
14 * General Public License for more details.
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
15 *
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
19 * 02111-1301, USA.
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
20 */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
21 #include "internal.h"
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
22 #include "debug.h"
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
23 #include "plugin.h"
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
24 #include "version.h"
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
25
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
26 #ifdef _WIN32
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
27 # ifndef HAVE_LONG_LONG
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
28 #define HAVE_LONG_LONG
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
29 /* WINDDK_BUILD is defined because the checks around usage of
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
30 * intrisic functions are wrong in nspr */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
31 #define WINDDK_BUILD
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
32 # endif
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
33 #endif
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
34
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
35 #include <nspr.h>
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
36 #include <nss.h>
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
37 #include <nssb64.h>
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
38 #include <ocsp.h>
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
39 #include <pk11func.h>
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
40 #include <prio.h>
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
41 #include <secerr.h>
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
42 #include <secmod.h>
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
43 #include <ssl.h>
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
44 #include <sslerr.h>
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
45 #include <sslproto.h>
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
46
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
47 /* There's a bug in some versions of this header that requires that some of
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
48 the headers above be included first. This is true for at least libnss
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
49 3.15.4. */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
50 #include <certdb.h>
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
51
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
52 #define PLUGIN_ID "core-nss_prefs"
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
53
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
54 #define PREF_BASE "/plugins/core/nss_prefs"
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
55 #define CIPHERS_PREF PREF_BASE "/cipher_list"
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
56 #define CIPHER_TMP_ROOT PREF_BASE "/ciphers_dummy_ui"
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
57 #define CIPHER_TMP CIPHER_TMP_ROOT "/0x%04x"
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
58 #define MIN_TLS PREF_BASE "/min_tls"
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
59 #define MAX_TLS PREF_BASE "/max_tls"
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
60
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
61 static PurplePlugin *handle = NULL;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
62 static GList *tmp_prefs = NULL;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
63 static GList *default_ciphers = NULL;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
64 #if NSS_VMAJOR > 3 || ( NSS_VMAJOR == 3 && NSS_VMINOR >= 14 )
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
65 static SSLVersionRange *default_versions = NULL;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
66 #endif
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
67
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
68 static gchar *get_error_text(void)
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
69 {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
70 PRInt32 len = PR_GetErrorTextLength();
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
71 gchar *ret = NULL;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
72
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
73 if (len > 0) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
74 ret = g_malloc(len + 1);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
75 len = PR_GetErrorText(ret);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
76 ret[len] = '\0';
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
77 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
78
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
79 return ret;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
80 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
81
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
82 static GList *get_current_cipher_list(gboolean force_default) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
83 GList *conf_ciphers = NULL;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
84 if (!force_default) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
85 conf_ciphers = purple_prefs_get_string_list(CIPHERS_PREF);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
86 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
87
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
88 /* If we don't have any specifically configured ciphers, use the
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
89 * a copy of the defaults */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
90 if (!conf_ciphers) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
91 GList *tmp;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
92 for(tmp = default_ciphers; tmp; tmp = tmp->next) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
93 conf_ciphers = g_list_prepend(conf_ciphers, g_strdup(tmp->data));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
94 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
95 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
96
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
97 return conf_ciphers;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
98 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
99
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
100 static void
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
101 enable_ciphers(gboolean force_default) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
102 const PRUint16 *cipher;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
103 GList *conf_ciphers, *tmp;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
104 SECStatus rv;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
105
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
106 conf_ciphers = get_current_cipher_list(force_default);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
107
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
108 /** First disable everything */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
109 for (cipher = SSL_GetImplementedCiphers(); *cipher != 0; ++cipher) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
110 rv = SSL_CipherPrefSetDefault(*cipher, PR_FALSE);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
111 if (rv != SECSuccess) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
112 gchar *error_msg = get_error_text();
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
113 purple_debug_warning("nss-prefs",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
114 "Unable to disable 0x%04x: %s\n",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
115 *cipher, error_msg);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
116 g_free(error_msg);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
117 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
118 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
119
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
120 for (tmp = conf_ciphers; tmp; tmp = g_list_delete_link(tmp, tmp)) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
121 guint64 parsed = g_ascii_strtoull(tmp->data, NULL, 16);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
122
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
123 if (parsed == 0 || parsed > PR_UINT16_MAX) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
124 purple_debug_error("nss-prefs",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
125 "Cipher '%s' is not valid.\n",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
126 (const char *) tmp->data);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
127 g_free(tmp->data);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
128 continue;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
129 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
130
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
131 rv = SSL_CipherPrefSetDefault((PRUint16) parsed, PR_TRUE);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
132 if (rv != SECSuccess) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
133 gchar *error_msg = get_error_text();
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
134 purple_debug_warning("nss-prefs",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
135 "Unable to enable 0x%04x: %s\n",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
136 *cipher, error_msg);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
137 g_free(error_msg);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
138 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
139 purple_debug_info("nss-prefs",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
140 "Enabled Cipher 0x%04x.\n", (PRUint16) parsed);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
141
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
142 g_free(tmp->data);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
143 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
144 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
145
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
146 static void set_cipher_pref(const char *pref, PurplePrefType type,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
147 gconstpointer value, gpointer user_data) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
148 const PRUint16 *cipher = user_data;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
149 GList *conf_ciphers, *tmp;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
150 gboolean enabled = GPOINTER_TO_INT(value);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
151 gboolean found = FALSE;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
152
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
153 purple_debug_info("nss-prefs",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
154 "%s pref for Cipher 0x%04x.\n",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
155 enabled ? "Adding" : "Removing", *cipher);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
156
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
157 conf_ciphers = get_current_cipher_list(FALSE);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
158
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
159 for (tmp = conf_ciphers; tmp; tmp = tmp->next) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
160 guint64 parsed = g_ascii_strtoull(tmp->data, NULL, 16);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
161 if (parsed == 0 || parsed > PR_UINT16_MAX) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
162 purple_debug_error("nss-prefs",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
163 "Cipher '%s' is not valid to set_cipher_pref.\n",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
164 (const char *) tmp->data);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
165 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
166 if (parsed == *cipher) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
167 if (!enabled) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
168 g_free(tmp->data);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
169 conf_ciphers = g_list_delete_link(conf_ciphers, tmp);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
170 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
171 found = TRUE;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
172 break;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
173 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
174 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
175 if (!found) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
176 if (enabled) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
177 conf_ciphers = g_list_prepend(conf_ciphers,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
178 g_strdup_printf("0x%04x", *cipher));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
179 } else {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
180 purple_debug_info("nss-prefs",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
181 "Unable to find 0x%04x to disable.\n",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
182 *cipher);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
183 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
184 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
185
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
186 purple_prefs_set_string_list(CIPHERS_PREF, conf_ciphers);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
187
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
188 for (tmp = conf_ciphers; tmp; tmp = g_list_delete_link(tmp, tmp)) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
189 g_free(tmp->data);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
190 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
191
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
192 enable_ciphers(FALSE);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
193 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
194
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
195 static void set_versions(gboolean force_default) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
196 #if NSS_VMAJOR > 3 || ( NSS_VMAJOR == 3 && NSS_VMINOR >= 14 )
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
197 SSLVersionRange supported, enabled;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
198
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
199 /* Get the ranges of supported and enabled SSL versions */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
200 if ((SSL_VersionRangeGetSupported(ssl_variant_stream, &supported) == SECSuccess) &&
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
201 (SSL_VersionRangeGetDefault(ssl_variant_stream, &enabled) == SECSuccess)) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
202 PRUint16 tmp;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
203
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
204 /* Store the defaults if this is the first time we've encountered them */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
205 if (!default_versions) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
206 default_versions = g_new0(SSLVersionRange, 1);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
207 default_versions->min = enabled.min;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
208 default_versions->max = enabled.max;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
209 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
210
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
211 if (force_default) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
212 tmp = default_versions->min;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
213 } else {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
214 tmp = purple_prefs_get_int(MIN_TLS);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
215 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
216 if (tmp > 0) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
217 enabled.min = tmp;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
218 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
219
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
220 if (force_default) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
221 tmp = default_versions->max;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
222 } else {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
223 tmp = purple_prefs_get_int(MAX_TLS);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
224 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
225 if (tmp > 0) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
226 enabled.max = tmp;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
227 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
228
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
229 if (SSL_VersionRangeSetDefault(ssl_variant_stream, &enabled) == SECSuccess) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
230 purple_debug_info("nss-prefs", "Changed allowed TLS versions to "
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
231 "0x%04hx through 0x%04hx\n", enabled.min, enabled.max);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
232 } else {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
233 purple_debug_error("nss-prefs", "Error setting allowed TLS versions to "
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
234 "0x%04hx through 0x%04hx\n", enabled.min, enabled.max);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
235 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
236 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
237 #else
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
238 purple_debug_error("nss-prefs", "Unable set SSL/TLS Versions\n");
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
239 #endif /* NSS >= 3.14 */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
240 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
241
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
242 static void set_version_pref(const char *pref, PurplePrefType type,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
243 gconstpointer value, gpointer user_data) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
244 set_versions(FALSE);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
245 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
246
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
247 /* This is horrible, but is the only way I can think of to tie into the
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
248 * prefs UI. Add a bunch of temporary prefs that will be used to set
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
249 * the prefs list. They'll get cleaned up when the plugin is unloaded*/
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
250 static void init_tmp_prefs(void) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
251 GList *conf_ciphers, *tmp;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
252 const PRUint16 *cipher;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
253
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
254 if (tmp_prefs) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
255 return;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
256 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
257
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
258 conf_ciphers = get_current_cipher_list(FALSE);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
259
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
260 purple_prefs_add_none(CIPHER_TMP_ROOT);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
261 for (cipher = SSL_GetImplementedCiphers(); *cipher != 0; ++cipher) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
262 gboolean found = FALSE;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
263 gchar *pref_name = g_strdup_printf(CIPHER_TMP, *cipher);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
264
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
265 tmp_prefs = g_list_prepend(tmp_prefs, pref_name);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
266
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
267 tmp = conf_ciphers;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
268 while (tmp) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
269 guint64 parsed = g_ascii_strtoull(tmp->data, NULL, 16);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
270 if (parsed == 0 || parsed > PR_UINT16_MAX) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
271 purple_debug_error("nss-prefs",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
272 "Cipher '%s' is not valid to init_tmp_pref.\n",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
273 (const char *) tmp->data);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
274 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
275 if (parsed == *cipher) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
276 found = TRUE;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
277 /** Remove the entry since we're done with it */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
278 g_free(tmp->data);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
279 conf_ciphers = g_list_delete_link(conf_ciphers, tmp);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
280 break;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
281 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
282 tmp = tmp->next;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
283 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
284 purple_prefs_add_bool(pref_name, found);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
285 purple_prefs_set_bool(pref_name, found);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
286 purple_prefs_connect_callback(handle, pref_name,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
287 set_cipher_pref, (void *) cipher);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
288 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
289 tmp_prefs = g_list_reverse(tmp_prefs);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
290
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
291 for (tmp = conf_ciphers; tmp; tmp = g_list_delete_link(tmp, tmp)) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
292 g_free(tmp->data);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
293 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
294
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
295 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
296
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
297 static PurplePluginPrefFrame *
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
298 get_plugin_pref_frame(PurplePlugin *plugin) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
299 PurplePluginPrefFrame *frame;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
300 PurplePluginPref *ppref;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
301 int offset;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
302 GList *tmp;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
303 #if NSS_VMAJOR > 3 || ( NSS_VMAJOR == 3 && NSS_VMINOR >= 14 )
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
304 SSLVersionRange supported, enabled;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
305 #endif /* NSS >= 3.14 */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
306
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
307 frame = purple_plugin_pref_frame_new();
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
308
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
309 ppref = purple_plugin_pref_new_with_label(_("TLS/SSL Versions"));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
310 purple_plugin_pref_frame_add(frame, ppref);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
311 #if NSS_VMAJOR > 3 || ( NSS_VMAJOR == 3 && NSS_VMINOR >= 14 )
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
312 /* Get the ranges of supported and enabled SSL versions */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
313 if ((SSL_VersionRangeGetSupported(ssl_variant_stream, &supported) == SECSuccess) &&
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
314 (SSL_VersionRangeGetDefault(ssl_variant_stream, &enabled) == SECSuccess)) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
315 PRUint16 tmp_version;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
316 PurplePluginPref *ppref_max;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
317
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
318 ppref = purple_plugin_pref_new_with_name_and_label(MIN_TLS,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
319 _("Minimum Version"));
36237
47cc3f47592c Fix merged NSS stuff for 3.0.0 (hopefully)
Daniel Atallah <datallah@pidgin.im>
parents: 36235
diff changeset
320 purple_plugin_pref_set_pref_type(ppref, PURPLE_PLUGIN_PREF_CHOICE);
36228
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
321 ppref_max = purple_plugin_pref_new_with_name_and_label(MAX_TLS,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
322 _("Maximum Version"));
36237
47cc3f47592c Fix merged NSS stuff for 3.0.0 (hopefully)
Daniel Atallah <datallah@pidgin.im>
parents: 36235
diff changeset
323 purple_plugin_pref_set_pref_type(ppref_max, PURPLE_PLUGIN_PREF_CHOICE);
36228
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
324
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
325 for (tmp_version = supported.min; tmp_version <= supported.max; tmp_version++) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
326 gchar *ver;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
327 switch (tmp_version) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
328 case SSL_LIBRARY_VERSION_2:
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
329 ver = g_strdup(_("SSL 2"));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
330 break;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
331 case SSL_LIBRARY_VERSION_3_0:
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
332 ver = g_strdup(_("SSL 3"));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
333 break;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
334 case SSL_LIBRARY_VERSION_TLS_1_0:
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
335 ver = g_strdup(_("TLS 1.0"));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
336 break;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
337 case SSL_LIBRARY_VERSION_TLS_1_1:
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
338 ver = g_strdup(_("TLS 1.1"));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
339 break;
36235
6f5e35bda0c9 I guess there are NSS versions that support the SSL_VersionRange stuff, but not TLS 1.2 - I thought they came in at the same time.
Daniel Atallah <datallah@pidgin.im>
parents: 36231
diff changeset
340 #ifdef SSL_LIBRARY_VERSION_TLS_1_2
36228
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
341 case SSL_LIBRARY_VERSION_TLS_1_2:
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
342 ver = g_strdup(_("TLS 1.2"));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
343 break;
36235
6f5e35bda0c9 I guess there are NSS versions that support the SSL_VersionRange stuff, but not TLS 1.2 - I thought they came in at the same time.
Daniel Atallah <datallah@pidgin.im>
parents: 36231
diff changeset
344 #endif
36231
0223e88d7858 SSL_LIBRARY_VERSION_TLS_1_3 is a recent addition - yay buildbots
Daniel Atallah <datallah@pidgin.im>
parents: 36228
diff changeset
345 #ifdef SSL_LIBRARY_VERSION_TLS_1_3
36228
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
346 case SSL_LIBRARY_VERSION_TLS_1_3:
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
347 ver = g_strdup(_("TLS 1.3"));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
348 break;
36231
0223e88d7858 SSL_LIBRARY_VERSION_TLS_1_3 is a recent addition - yay buildbots
Daniel Atallah <datallah@pidgin.im>
parents: 36228
diff changeset
349 #endif
36228
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
350 default:
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
351 ver = g_strdup_printf("0x%04hx", tmp_version);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
352 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
353 purple_plugin_pref_add_choice(ppref, ver, GINT_TO_POINTER((gint) tmp_version));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
354 purple_plugin_pref_add_choice(ppref_max, ver, GINT_TO_POINTER((gint) tmp_version));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
355 g_free(ver);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
356 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
357 purple_plugin_pref_frame_add(frame, ppref);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
358 purple_plugin_pref_frame_add(frame, ppref_max);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
359 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
360 #else
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
361 /* TODO: look into how to do this for older versions? */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
362
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
363 ppref = purple_plugin_pref_new_with_label(_("Not Supported for NSS < 3.14"));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
364 purple_plugin_pref_frame_add(frame, ppref);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
365
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
366 #endif /* NSS >= 3.14 */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
367
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
368 ppref = purple_plugin_pref_new_with_label(_("Ciphers"));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
369 purple_plugin_pref_frame_add(frame, ppref);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
370
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
371 init_tmp_prefs();
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
372
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
373 offset = strlen(CIPHER_TMP_ROOT) + 1;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
374 for (tmp = tmp_prefs; tmp; tmp = tmp->next) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
375 guint64 parsed = g_ascii_strtoull( (char *) tmp->data + offset,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
376 NULL, 16);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
377 PRUint16 cipher;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
378 SECStatus rv;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
379 gchar **split;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
380 gchar *escaped_name;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
381 SSLCipherSuiteInfo info;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
382
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
383 if (parsed == 0 || parsed > PR_UINT16_MAX) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
384 purple_debug_error("nss-prefs",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
385 "Cipher '%s' is not valid to build pref frame.\n",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
386 (const char *) tmp->data + offset);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
387 continue;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
388 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
389
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
390 cipher = (PRUint16) parsed;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
391
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
392 rv = SSL_GetCipherSuiteInfo(cipher, &info, (int)(sizeof info));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
393 if (rv != SECSuccess) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
394 gchar *error_msg = get_error_text();
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
395 purple_debug_warning("nss-prefs",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
396 "SSL_GetCipherSuiteInfo didn't like value 0x%04x: %s\n",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
397 cipher, error_msg);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
398 g_free(error_msg);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
399 continue;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
400 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
401 escaped_name = g_strdup_printf("%s (0x%04x)",
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
402 info.cipherSuiteName, cipher);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
403 /** Escape the _ for the label */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
404 split = g_strsplit(escaped_name, "_", -1);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
405 g_free(escaped_name);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
406 escaped_name = g_strjoinv("__", split);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
407 g_strfreev(split);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
408 ppref = purple_plugin_pref_new_with_name_and_label(
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
409 (const char *) tmp->data, escaped_name);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
410 g_free(escaped_name);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
411 purple_plugin_pref_frame_add(frame, ppref);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
412 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
413
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
414 return frame;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
415 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
416
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
417 static gboolean
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
418 plugin_load(PurplePlugin *plugin) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
419 const PRUint16 *cipher;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
420
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
421 handle = plugin;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
422
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
423 tmp_prefs = NULL;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
424 default_ciphers = NULL;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
425
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
426 for (cipher = SSL_GetImplementedCiphers(); *cipher != 0; ++cipher) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
427 PRBool enabled;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
428 SECStatus rv = SSL_CipherPrefGetDefault(*cipher, &enabled);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
429 if (rv == SECSuccess && enabled) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
430 default_ciphers = g_list_prepend(default_ciphers,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
431 g_strdup_printf("0x%04x", *cipher));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
432 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
433 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
434
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
435 enable_ciphers(FALSE);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
436 set_versions(FALSE);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
437 purple_prefs_connect_callback(handle, MIN_TLS,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
438 set_version_pref, GINT_TO_POINTER(FALSE));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
439 purple_prefs_connect_callback(handle, MAX_TLS,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
440 set_version_pref, GINT_TO_POINTER(TRUE));
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
441
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
442 return TRUE;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
443 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
444
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
445 static gboolean
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
446 plugin_unload(PurplePlugin *plugin) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
447
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
448 /* Remove the temporary prefs */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
449 if (tmp_prefs) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
450 purple_prefs_remove(CIPHER_TMP_ROOT);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
451 while (tmp_prefs) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
452 g_free(tmp_prefs->data);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
453 tmp_prefs = g_list_delete_link(tmp_prefs, tmp_prefs);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
454 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
455 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
456
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
457 /* Restore the original ciphers */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
458 enable_ciphers(TRUE);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
459 while (default_ciphers) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
460 g_free(default_ciphers->data);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
461 default_ciphers = g_list_delete_link(default_ciphers,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
462 default_ciphers);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
463 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
464
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
465 set_versions(TRUE);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
466 #if NSS_VMAJOR > 3 || ( NSS_VMAJOR == 3 && NSS_VMINOR >= 14 )
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
467 g_free(default_versions);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
468 default_versions = NULL;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
469 #endif
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
470
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
471 return TRUE;
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
472 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
473
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
474
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
475 static PurplePluginUiInfo prefs_info = {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
476 get_plugin_pref_frame,
36237
47cc3f47592c Fix merged NSS stuff for 3.0.0 (hopefully)
Daniel Atallah <datallah@pidgin.im>
parents: 36235
diff changeset
477 NULL,
47cc3f47592c Fix merged NSS stuff for 3.0.0 (hopefully)
Daniel Atallah <datallah@pidgin.im>
parents: 36235
diff changeset
478
36228
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
479 /* Padding */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
480 NULL,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
481 NULL,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
482 NULL,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
483 NULL
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
484 };
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
485
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
486 static PurplePluginInfo info = {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
487 PURPLE_PLUGIN_MAGIC,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
488 PURPLE_MAJOR_VERSION,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
489 PURPLE_MINOR_VERSION,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
490 PURPLE_PLUGIN_STANDARD, /**< type */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
491 NULL, /**< ui_requirement */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
492 0, /**< flags */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
493 NULL, /**< dependencies */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
494 PURPLE_PRIORITY_DEFAULT, /**< priority */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
495
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
496 PLUGIN_ID, /**< id */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
497 N_("NSS Preferences"), /**< name */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
498 DISPLAY_VERSION, /**< version */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
499 /** summary */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
500 N_("Configure Ciphers and other Settings for "
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
501 "the NSS SSL/TLS Plugin"),
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
502 /** description */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
503 N_("Configure Ciphers and other Settings for "
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
504 "the NSS SSL/TLS Plugin"),
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
505 "Daniel Atallah <datallah@pidgin.im>", /**< author */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
506 PURPLE_WEBSITE, /**< homepage */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
507
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
508 plugin_load, /**< load */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
509 plugin_unload, /**< unload */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
510 NULL, /**< destroy */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
511
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
512 NULL, /**< ui_info */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
513 NULL, /**< extra_info */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
514 &prefs_info, /**< prefs_info */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
515 NULL,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
516 /* Padding */
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
517 NULL,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
518 NULL,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
519 NULL,
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
520 NULL
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
521 };
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
522
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
523 static void
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
524 init_plugin(PurplePlugin *plugin) {
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
525 info.dependencies = g_list_prepend(info.dependencies, "ssl-nss");
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
526
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
527 purple_prefs_add_none(PREF_BASE);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
528 purple_prefs_add_string_list(CIPHERS_PREF, NULL);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
529 purple_prefs_add_int(MIN_TLS, 0);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
530 purple_prefs_add_int(MAX_TLS, 0);
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
531 }
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
532
1cdc641d433e Add "NSS Preferences" plugin which allows configuration Min/Max TLS version and Ciphers.
Daniel Atallah <datallah@pidgin.im>
parents:
diff changeset
533 PURPLE_INIT_PLUGIN(nss_prefs, init_plugin, info)

mercurial