OLD | NEW |
1 From 1ebf459243cea430614e1958ecab1ad10457ccc2 Mon Sep 17 00:00:00 2001 | 1 diff -upN a/src/net/third_party/nss/ssl/ssl.h b/src/net/third_party/nss/ssl/ssl.
h |
2 From: Adam Langley <agl@chromium.org> | 2 --- a/src/net/third_party/nss/ssl/ssl.h»2012-02-28 19:26:04.047351199 -0800 |
3 Date: Mon, 3 Oct 2011 12:44:48 -0400 | 3 +++ b/src/net/third_party/nss/ssl/ssl.h»2012-02-28 20:04:24.039351965 -0800 |
4 Subject: [PATCH] clientauth.patch | 4 @@ -421,6 +421,45 @@ typedef SECStatus (PR_CALLBACK *SSLGetCl |
5 | |
6 --- | |
7 mozilla/security/nss/lib/ssl/ssl.h | 39 +++ | |
8 mozilla/security/nss/lib/ssl/ssl3con.c | 163 ++++++++++--- | |
9 mozilla/security/nss/lib/ssl/ssl3ext.c | 2 +- | |
10 mozilla/security/nss/lib/ssl/sslauth.c | 22 ++ | |
11 mozilla/security/nss/lib/ssl/sslimpl.h | 45 ++++ | |
12 mozilla/security/nss/lib/ssl/sslplatf.c | 399 +++++++++++++++++++++++++++++++ | |
13 mozilla/security/nss/lib/ssl/sslsock.c | 14 + | |
14 7 files changed, 647 insertions(+), 37 deletions(-) | |
15 create mode 100644 mozilla/security/nss/lib/ssl/sslplatf.c | |
16 | |
17 diff --git a/mozilla/security/nss/lib/ssl/ssl.h b/mozilla/security/nss/lib/ssl/s
sl.h | |
18 index 7e748bd..03535f3 100644 | |
19 --- a/mozilla/security/nss/lib/ssl/ssl.h | |
20 +++ b/mozilla/security/nss/lib/ssl/ssl.h | |
21 @@ -353,6 +353,45 @@ typedef SECStatus (PR_CALLBACK *SSLGetClientAuthData)(void
*arg, | |
22 SSL_IMPORT SECStatus SSL_GetClientAuthDataHook(PRFileDesc *fd, | 5 SSL_IMPORT SECStatus SSL_GetClientAuthDataHook(PRFileDesc *fd, |
23 SSLGetClientAuthData f, void *a); | 6 SSLGetClientAuthData f, void *a); |
24 | 7 |
25 +/* | 8 +/* |
26 + * Prototype for SSL callback to get client auth data from the application, | 9 + * Prototype for SSL callback to get client auth data from the application, |
27 + * optionally using the underlying platform's cryptographic primitives. | 10 + * optionally using the underlying platform's cryptographic primitives. |
28 + * To use the platform cryptographic primitives, caNames and pRetCerts | 11 + * To use the platform cryptographic primitives, caNames and pRetCerts |
29 + * should be set. To use NSS, pRetNSSCert and pRetNSSKey should be set. | 12 + * should be set. To use NSS, pRetNSSCert and pRetNSSKey should be set. |
30 + * Returning SECFailure will cause the socket to send no client certificate. | 13 + * Returning SECFailure will cause the socket to send no client certificate. |
31 + * arg - application passed argument | 14 + * arg - application passed argument |
(...skipping 25 matching lines...) Expand all Loading... |
57 + * fd - the file descriptor for the connection in question | 40 + * fd - the file descriptor for the connection in question |
58 + * f - the application's callback that delivers the key and cert | 41 + * f - the application's callback that delivers the key and cert |
59 + * a - application specific data | 42 + * a - application specific data |
60 + */ | 43 + */ |
61 +SSL_IMPORT SECStatus | 44 +SSL_IMPORT SECStatus |
62 +SSL_GetPlatformClientAuthDataHook(PRFileDesc *fd, | 45 +SSL_GetPlatformClientAuthDataHook(PRFileDesc *fd, |
63 + SSLGetPlatformClientAuthData f, void *a); | 46 + SSLGetPlatformClientAuthData f, void *a); |
64 | 47 |
65 /* | 48 /* |
66 ** SNI extension processing callback function. | 49 ** SNI extension processing callback function. |
67 diff --git a/mozilla/security/nss/lib/ssl/ssl3con.c b/mozilla/security/nss/lib/s
sl/ssl3con.c | 50 diff -upN a/src/net/third_party/nss/ssl/ssl3con.c b/src/net/third_party/nss/ssl/
ssl3con.c |
68 index d372ee2..ad8f4cd 100644 | 51 --- a/src/net/third_party/nss/ssl/ssl3con.c» 2012-02-28 19:26:04.047351199 -0
800 |
69 --- a/mozilla/security/nss/lib/ssl/ssl3con.c | 52 +++ b/src/net/third_party/nss/ssl/ssl3con.c» 2012-02-28 20:07:04.101579541 -0
800 |
70 +++ b/mozilla/security/nss/lib/ssl/ssl3con.c | 53 @@ -2015,6 +2015,9 @@ ssl3_ClientAuthTokenPresent(sslSessionID |
71 @@ -2018,6 +2018,9 @@ ssl3_ClientAuthTokenPresent(sslSessionID *sid) { | |
72 PRBool isPresent = PR_TRUE; | 54 PRBool isPresent = PR_TRUE; |
73 | 55 |
74 /* we only care if we are doing client auth */ | 56 /* we only care if we are doing client auth */ |
75 + /* If NSS_PLATFORM_CLIENT_AUTH is defined and a platformClientKey is being | 57 + /* If NSS_PLATFORM_CLIENT_AUTH is defined and a platformClientKey is being |
76 + * used, u.ssl3.clAuthValid will be false and this function will always | 58 + * used, u.ssl3.clAuthValid will be false and this function will always |
77 + * return PR_TRUE. */ | 59 + * return PR_TRUE. */ |
78 if (!sid || !sid->u.ssl3.clAuthValid) { | 60 if (!sid || !sid->u.ssl3.clAuthValid) { |
79 return PR_TRUE; | 61 return PR_TRUE; |
80 } | 62 } |
81 @@ -4865,27 +4868,30 @@ ssl3_SendCertificateVerify(sslSocket *ss) | 63 @@ -4893,24 +4896,33 @@ ssl3_SendCertificateVerify(sslSocket *ss |
82 } | 64 } |
83 | 65 |
84 isTLS = (PRBool)(ss->ssl3.pwSpec->version > SSL_LIBRARY_VERSION_3_0); | 66 isTLS = (PRBool)(ss->ssl3.pwSpec->version > SSL_LIBRARY_VERSION_3_0); |
85 - rv = ssl3_SignHashes(&hashes, ss->ssl3.clientPrivateKey, &buf, isTLS); | 67 - rv = ssl3_SignHashes(&hashes, ss->ssl3.clientPrivateKey, &buf, isTLS); |
86 - if (rv == SECSuccess) { | 68 - if (rv == SECSuccess) { |
87 - PK11SlotInfo * slot; | 69 - PK11SlotInfo * slot; |
88 - sslSessionID * sid = ss->sec.ci.sid; | 70 - sslSessionID * sid = ss->sec.ci.sid; |
89 + if (ss->ssl3.platformClientKey) { | 71 + if (ss->ssl3.platformClientKey) { |
90 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 72 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
91 + rv = ssl3_PlatformSignHashes(&hashes, ss->ssl3.platformClientKey, | 73 + rv = ssl3_PlatformSignHashes(&hashes, ss->ssl3.platformClientKey, |
(...skipping 10 matching lines...) Expand all Loading... |
102 - /* Remember the info about the slot that did the signing. | 84 - /* Remember the info about the slot that did the signing. |
103 - ** Later, when doing an SSL restart handshake, verify this. | 85 - ** Later, when doing an SSL restart handshake, verify this. |
104 - ** These calls are mere accessors, and can't fail. | 86 - ** These calls are mere accessors, and can't fail. |
105 - */ | 87 - */ |
106 - slot = PK11_GetSlotFromPrivateKey(ss->ssl3.clientPrivateKey); | 88 - slot = PK11_GetSlotFromPrivateKey(ss->ssl3.clientPrivateKey); |
107 - sid->u.ssl3.clAuthSeries = PK11_GetSlotSeries(slot); | 89 - sid->u.ssl3.clAuthSeries = PK11_GetSlotSeries(slot); |
108 - sid->u.ssl3.clAuthSlotID = PK11_GetSlotID(slot); | 90 - sid->u.ssl3.clAuthSlotID = PK11_GetSlotID(slot); |
109 - sid->u.ssl3.clAuthModuleID = PK11_GetModuleID(slot); | 91 - sid->u.ssl3.clAuthModuleID = PK11_GetModuleID(slot); |
110 - sid->u.ssl3.clAuthValid = PR_TRUE; | 92 - sid->u.ssl3.clAuthValid = PR_TRUE; |
111 - PK11_FreeSlot(slot); | 93 - PK11_FreeSlot(slot); |
112 - } | |
113 - /* If we're doing RSA key exchange, we're all done with the private key | |
114 - * here. Diffie-Hellman key exchanges need the client's | |
115 - * private key for the key exchange. | |
116 - */ | |
117 - if (ss->ssl3.hs.kea_def->exchKeyType == kt_rsa) { | |
118 + /* Remember the info about the slot that did the signing. | 94 + /* Remember the info about the slot that did the signing. |
119 + ** Later, when doing an SSL restart handshake, verify this. | 95 + ** Later, when doing an SSL restart handshake, verify this. |
120 + ** These calls are mere accessors, and can't fail. | 96 + ** These calls are mere accessors, and can't fail. |
121 + */ | 97 + */ |
122 + slot = PK11_GetSlotFromPrivateKey(ss->ssl3.clientPrivateKey); | 98 + slot = PK11_GetSlotFromPrivateKey(ss->ssl3.clientPrivateKey); |
123 + sid->u.ssl3.clAuthSeries = PK11_GetSlotSeries(slot); | 99 + sid->u.ssl3.clAuthSeries = PK11_GetSlotSeries(slot); |
124 + sid->u.ssl3.clAuthSlotID = PK11_GetSlotID(slot); | 100 + sid->u.ssl3.clAuthSlotID = PK11_GetSlotID(slot); |
125 + sid->u.ssl3.clAuthModuleID = PK11_GetModuleID(slot); | 101 + sid->u.ssl3.clAuthModuleID = PK11_GetModuleID(slot); |
126 + sid->u.ssl3.clAuthValid = PR_TRUE; | 102 + sid->u.ssl3.clAuthValid = PR_TRUE; |
127 + PK11_FreeSlot(slot); | 103 + PK11_FreeSlot(slot); |
128 + } | 104 + } |
129 » SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey); | 105 +» SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey); |
130 » ss->ssl3.clientPrivateKey = NULL; | 106 +» ss->ssl3.clientPrivateKey = NULL; |
131 } | 107 } |
132 @@ -4943,6 +4949,26 @@ ssl3_HandleServerHello(sslSocket *ss, SSL3Opaque *b, PRUi
nt32 length) | 108 - SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey); |
133 » goto alert_loser; | 109 - ss->ssl3.clientPrivateKey = NULL; |
| 110 if (rv != SECSuccess) { |
| 111 » goto done;» /* err code was set by ssl3_SignHashes */ |
134 } | 112 } |
135 | 113 @@ -4978,6 +4990,12 @@ ssl3_HandleServerHello(sslSocket *ss, SS |
136 + /* clean up anything left from previous handshake. */ | 114 SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey); |
137 + if (ss->ssl3.clientCertChain != NULL) { | 115 ss->ssl3.clientPrivateKey = NULL; |
138 + CERT_DestroyCertificateList(ss->ssl3.clientCertChain); | 116 } |
139 + ss->ssl3.clientCertChain = NULL; | |
140 + } | |
141 + if (ss->ssl3.clientCertificate != NULL) { | |
142 + CERT_DestroyCertificate(ss->ssl3.clientCertificate); | |
143 + ss->ssl3.clientCertificate = NULL; | |
144 + } | |
145 + if (ss->ssl3.clientPrivateKey != NULL) { | |
146 + SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey); | |
147 + ss->ssl3.clientPrivateKey = NULL; | |
148 + } | |
149 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 117 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
150 + if (ss->ssl3.platformClientKey) { | 118 + if (ss->ssl3.platformClientKey) { |
151 + ssl_FreePlatformKey(ss->ssl3.platformClientKey); | 119 + ssl_FreePlatformKey(ss->ssl3.platformClientKey); |
152 + ss->ssl3.platformClientKey = (PlatformKey)NULL; | 120 + ss->ssl3.platformClientKey = (PlatformKey)NULL; |
153 + } | 121 + } |
154 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 122 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
155 + | 123 |
156 temp = ssl3_ConsumeHandshakeNumber(ss, 2, &b, &length); | 124 temp = ssl3_ConsumeHandshakeNumber(ss, 2, &b, &length); |
157 if (temp < 0) { | 125 if (temp < 0) { |
158 » goto loser; » /* alert has been sent */ | 126 @@ -5522,6 +5540,10 @@ ssl3_HandleCertificateRequest(sslSocket |
159 @@ -5485,6 +5511,10 @@ ssl3_HandleCertificateRequest(sslSocket *ss, SSL3Opaque *
b, PRUint32 length) | |
160 SSL3AlertDescription desc = illegal_parameter; | 127 SSL3AlertDescription desc = illegal_parameter; |
161 SECItem cert_types = {siBuffer, NULL, 0}; | 128 SECItem cert_types = {siBuffer, NULL, 0}; |
162 CERTDistNames ca_list; | 129 CERTDistNames ca_list; |
163 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 130 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
164 + CERTCertList * platform_cert_list = NULL; | 131 + CERTCertList * platform_cert_list = NULL; |
165 + CERTCertListNode * certNode = NULL; | 132 + CERTCertListNode * certNode = NULL; |
166 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 133 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
167 | 134 |
168 SSL_TRC(3, ("%d: SSL3[%d]: handle certificate_request handshake", | 135 SSL_TRC(3, ("%d: SSL3[%d]: handle certificate_request handshake", |
169 SSL_GETPID(), ss->fd)); | 136 SSL_GETPID(), ss->fd)); |
170 @@ -5498,19 +5528,10 @@ ssl3_HandleCertificateRequest(sslSocket *ss, SSL3Opaque
*b, PRUint32 length) | 137 @@ -5538,6 +5560,7 @@ ssl3_HandleCertificateRequest(sslSocket |
171 » goto alert_loser; | 138 PORT_Assert(ss->ssl3.clientCertChain == NULL); |
172 } | 139 PORT_Assert(ss->ssl3.clientCertificate == NULL); |
173 | 140 PORT_Assert(ss->ssl3.clientPrivateKey == NULL); |
174 - /* clean up anything left from previous handshake. */ | |
175 - if (ss->ssl3.clientCertChain != NULL) { | |
176 - CERT_DestroyCertificateList(ss->ssl3.clientCertChain); | |
177 - ss->ssl3.clientCertChain = NULL; | |
178 - } | |
179 - if (ss->ssl3.clientCertificate != NULL) { | |
180 - CERT_DestroyCertificate(ss->ssl3.clientCertificate); | |
181 - ss->ssl3.clientCertificate = NULL; | |
182 - } | |
183 - if (ss->ssl3.clientPrivateKey != NULL) { | |
184 - SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey); | |
185 - ss->ssl3.clientPrivateKey = NULL; | |
186 - } | |
187 + PORT_Assert(ss->ssl3.clientCertChain == NULL); | |
188 + PORT_Assert(ss->ssl3.clientCertificate == NULL); | |
189 + PORT_Assert(ss->ssl3.clientPrivateKey == NULL); | |
190 + PORT_Assert(ss->ssl3.platformClientKey == (PlatformKey)NULL); | 141 + PORT_Assert(ss->ssl3.platformClientKey == (PlatformKey)NULL); |
191 | 142 |
192 isTLS = (PRBool)(ss->ssl3.prSpec->version > SSL_LIBRARY_VERSION_3_0); | 143 isTLS = (PRBool)(ss->ssl3.prSpec->version > SSL_LIBRARY_VERSION_3_0); |
193 rv = ssl3_ConsumeHandshakeVariable(ss, &cert_types, 1, &b, &length); | 144 rv = ssl3_ConsumeHandshakeVariable(ss, &cert_types, 1, &b, &length); |
194 @@ -5577,6 +5598,20 @@ ssl3_HandleCertificateRequest(sslSocket *ss, SSL3Opaque *
b, PRUint32 length) | 145 @@ -5604,6 +5627,20 @@ ssl3_HandleCertificateRequest(sslSocket |
195 desc = no_certificate; | 146 desc = no_certificate; |
196 ss->ssl3.hs.ws = wait_hello_done; | 147 ss->ssl3.hs.ws = wait_hello_done; |
197 | 148 |
198 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 149 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
199 + if (ss->getPlatformClientAuthData == NULL) { | 150 + if (ss->getPlatformClientAuthData == NULL) { |
200 + rv = SECFailure; /* force it to send a no_certificate alert */ | 151 + rv = SECFailure; /* force it to send a no_certificate alert */ |
201 + } else { | 152 + } else { |
202 + /* XXX Should pass cert_types in this call!! */ | 153 + /* XXX Should pass cert_types in this call!! */ |
203 + rv = (SECStatus)(*ss->getPlatformClientAuthData)( | 154 + rv = (SECStatus)(*ss->getPlatformClientAuthData)( |
204 + ss->getPlatformClientAuthDataArg, | 155 + ss->getPlatformClientAuthDataArg, |
205 + ss->fd, &ca_list, | 156 + ss->fd, &ca_list, |
206 + &platform_cert_list, | 157 + &platform_cert_list, |
207 + (void**)&ss->ssl3.platformClientKey, | 158 + (void**)&ss->ssl3.platformClientKey, |
208 + &ss->ssl3.clientCertificate, | 159 + &ss->ssl3.clientCertificate, |
209 + &ss->ssl3.clientPrivateKey); | 160 + &ss->ssl3.clientPrivateKey); |
210 + } | 161 + } |
211 +#else | 162 +#else |
212 if (ss->getClientAuthData == NULL) { | 163 if (ss->getClientAuthData == NULL) { |
213 rv = SECFailure; /* force it to send a no_certificate alert */ | 164 rv = SECFailure; /* force it to send a no_certificate alert */ |
214 } else { | 165 } else { |
215 @@ -5586,12 +5621,52 @@ ssl3_HandleCertificateRequest(sslSocket *ss, SSL3Opaque
*b, PRUint32 length) | 166 @@ -5613,12 +5650,52 @@ ssl3_HandleCertificateRequest(sslSocket |
216 &ss->ssl3.clientCertificate, | 167 &ss->ssl3.clientCertificate, |
217 &ss->ssl3.clientPrivateKey); | 168 &ss->ssl3.clientPrivateKey); |
218 } | 169 } |
219 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 170 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
220 switch (rv) { | 171 switch (rv) { |
221 case SECWouldBlock: /* getClientAuthData has put up a dialog box. */ | 172 case SECWouldBlock: /* getClientAuthData has put up a dialog box. */ |
222 » ssl_SetAlwaysBlock(ss); | 173 » ssl3_SetAlwaysBlock(ss); |
223 break; /* not an error */ | 174 break; /* not an error */ |
224 | 175 |
225 case SECSuccess: | 176 case SECSuccess: |
226 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 177 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
227 + if (!platform_cert_list || CERT_LIST_EMPTY(platform_cert_list) || | 178 + if (!platform_cert_list || CERT_LIST_EMPTY(platform_cert_list) || |
228 + !ss->ssl3.platformClientKey) { | 179 + !ss->ssl3.platformClientKey) { |
229 + if (platform_cert_list) { | 180 + if (platform_cert_list) { |
230 + CERT_DestroyCertList(platform_cert_list); | 181 + CERT_DestroyCertList(platform_cert_list); |
231 + platform_cert_list = NULL; | 182 + platform_cert_list = NULL; |
232 + } | 183 + } |
(...skipping 25 matching lines...) Expand all Loading... |
258 + ss->ssl3.platformClientKey = (PlatformKey)NULL; | 209 + ss->ssl3.platformClientKey = (PlatformKey)NULL; |
259 + } | 210 + } |
260 + goto send_no_certificate; | 211 + goto send_no_certificate; |
261 + } | 212 + } |
262 + break; /* not an error */ | 213 + break; /* not an error */ |
263 + } | 214 + } |
264 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 215 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
265 /* check what the callback function returned */ | 216 /* check what the callback function returned */ |
266 if ((!ss->ssl3.clientCertificate) || (!ss->ssl3.clientPrivateKey)) { | 217 if ((!ss->ssl3.clientCertificate) || (!ss->ssl3.clientPrivateKey)) { |
267 /* we are missing either the key or cert */ | 218 /* we are missing either the key or cert */ |
268 @@ -5654,6 +5729,10 @@ loser: | 219 @@ -5681,6 +5758,10 @@ loser: |
269 done: | 220 done: |
270 if (arena != NULL) | 221 if (arena != NULL) |
271 PORT_FreeArena(arena, PR_FALSE); | 222 PORT_FreeArena(arena, PR_FALSE); |
272 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 223 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
273 + if (platform_cert_list) | 224 + if (platform_cert_list) |
274 + CERT_DestroyCertList(platform_cert_list); | 225 + CERT_DestroyCertList(platform_cert_list); |
275 +#endif | 226 +#endif |
276 return rv; | 227 return rv; |
277 } | 228 } |
278 | 229 |
279 @@ -5785,9 +5864,17 @@ ssl3_HandleServerHelloDone(sslSocket *ss) | 230 @@ -5755,7 +5836,8 @@ ssl3_SendClientSecondRound(sslSocket *ss |
280 » if (rv != SECSuccess) { | 231 |
281 » goto loser;»/* error code is set. */ | 232 sendClientCert = !ss->ssl3.sendEmptyCert && |
282 » } | 233 » » ss->ssl3.clientCertChain != NULL && |
283 - } else | 234 -» » ss->ssl3.clientPrivateKey != NULL; |
284 - if (ss->ssl3.clientCertChain != NULL && | 235 +» » (ss->ssl3.platformClientKey || |
285 -» ss->ssl3.clientPrivateKey != NULL) { | 236 +» » ss->ssl3.clientPrivateKey != NULL); |
286 + } else if (ss->ssl3.clientCertChain != NULL && | 237 |
287 + ss->ssl3.platformClientKey) { | 238 /* We must wait for the server's certificate to be authenticated before |
288 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 239 * sending the client certificate in order to disclosing the client |
289 + send_verify = PR_TRUE; | 240 @@ -9725,6 +9807,10 @@ ssl3_DestroySSL3Info(sslSocket *ss) |
290 + rv = ssl3_SendCertificate(ss); | |
291 + if (rv != SECSuccess) { | |
292 + goto loser; /* error code is set. */ | |
293 + } | |
294 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | |
295 + } else if (ss->ssl3.clientCertChain != NULL && | |
296 + ss->ssl3.clientPrivateKey != NULL) { | |
297 » send_verify = PR_TRUE; | |
298 » rv = ssl3_SendCertificate(ss); | |
299 » if (rv != SECSuccess) { | |
300 @@ -9856,6 +9943,10 @@ ssl3_DestroySSL3Info(sslSocket *ss) | |
301 | 241 |
302 if (ss->ssl3.clientPrivateKey != NULL) | 242 if (ss->ssl3.clientPrivateKey != NULL) |
303 SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey); | 243 SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey); |
304 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 244 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
305 + if (ss->ssl3.platformClientKey) | 245 + if (ss->ssl3.platformClientKey) |
306 + ssl_FreePlatformKey(ss->ssl3.platformClientKey); | 246 + ssl_FreePlatformKey(ss->ssl3.platformClientKey); |
307 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 247 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
308 | 248 |
309 if (ss->ssl3.peerCertArena != NULL) | 249 if (ss->ssl3.peerCertArena != NULL) |
310 ssl3_CleanupPeerCerts(ss); | 250 ssl3_CleanupPeerCerts(ss); |
311 diff --git a/mozilla/security/nss/lib/ssl/ssl3ext.c b/mozilla/security/nss/lib/s
sl/ssl3ext.c | 251 diff -upN a/src/net/third_party/nss/ssl/ssl3ext.c b/src/net/third_party/nss/ssl/
ssl3ext.c |
312 index 887344b..e54b4fd 100644 | 252 --- a/src/net/third_party/nss/ssl/ssl3ext.c» 2012-02-28 19:26:04.047351199 -0
800 |
313 --- a/mozilla/security/nss/lib/ssl/ssl3ext.c | 253 +++ b/src/net/third_party/nss/ssl/ssl3ext.c» 2012-02-28 20:20:35.392842118 -0
800 |
314 +++ b/mozilla/security/nss/lib/ssl/ssl3ext.c | |
315 @@ -46,8 +46,8 @@ | 254 @@ -46,8 +46,8 @@ |
316 #include "nssrenam.h" | 255 #include "nssrenam.h" |
317 #include "nss.h" | 256 #include "nss.h" |
318 #include "ssl.h" | 257 #include "ssl.h" |
319 -#include "sslproto.h" | 258 -#include "sslproto.h" |
320 #include "sslimpl.h" | 259 #include "sslimpl.h" |
321 +#include "sslproto.h" | 260 +#include "sslproto.h" |
322 #include "pk11pub.h" | 261 #include "pk11pub.h" |
323 #include "blapi.h" | 262 #include "blapi.h" |
324 #include "prinit.h" | 263 #include "prinit.h" |
325 diff --git a/mozilla/security/nss/lib/ssl/sslauth.c b/mozilla/security/nss/lib/s
sl/sslauth.c | 264 diff -upN a/src/net/third_party/nss/ssl/sslauth.c b/src/net/third_party/nss/ssl/
sslauth.c |
326 index fcd15ca..8da5c66 100644 | 265 --- a/src/net/third_party/nss/ssl/sslauth.c» 2012-02-28 18:34:23.263186340 -0
800 |
327 --- a/mozilla/security/nss/lib/ssl/sslauth.c | 266 +++ b/src/net/third_party/nss/ssl/sslauth.c» 2012-02-28 20:04:24.039351965 -0
800 |
328 +++ b/mozilla/security/nss/lib/ssl/sslauth.c | 267 @@ -251,6 +251,28 @@ SSL_GetClientAuthDataHook(PRFileDesc *s, |
329 @@ -292,6 +292,28 @@ SSL_GetClientAuthDataHook(PRFileDesc *s, SSLGetClientAuthDa
ta func, | |
330 return SECSuccess; | 268 return SECSuccess; |
331 } | 269 } |
332 | 270 |
333 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 271 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
334 +/* NEED LOCKS IN HERE. */ | 272 +/* NEED LOCKS IN HERE. */ |
335 +SECStatus | 273 +SECStatus |
336 +SSL_GetPlatformClientAuthDataHook(PRFileDesc *s, | 274 +SSL_GetPlatformClientAuthDataHook(PRFileDesc *s, |
337 + SSLGetPlatformClientAuthData func, | 275 + SSLGetPlatformClientAuthData func, |
338 + void *arg) | 276 + void *arg) |
339 +{ | 277 +{ |
340 + sslSocket *ss; | 278 + sslSocket *ss; |
341 + | 279 + |
342 + ss = ssl_FindSocket(s); | 280 + ss = ssl_FindSocket(s); |
343 + if (!ss) { | 281 + if (!ss) { |
344 + SSL_DBG(("%d: SSL[%d]: bad socket in GetPlatformClientAuthDataHook", | 282 + SSL_DBG(("%d: SSL[%d]: bad socket in GetPlatformClientAuthDataHook", |
345 + SSL_GETPID(), s)); | 283 + SSL_GETPID(), s)); |
346 + return SECFailure; | 284 + return SECFailure; |
347 + } | 285 + } |
348 + | 286 + |
349 + ss->getPlatformClientAuthData = func; | 287 + ss->getPlatformClientAuthData = func; |
350 + ss->getPlatformClientAuthDataArg = arg; | 288 + ss->getPlatformClientAuthDataArg = arg; |
351 + return SECSuccess; | 289 + return SECSuccess; |
352 +} | 290 +} |
353 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 291 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
354 + | 292 + |
355 /* NEED LOCKS IN HERE. */ | 293 /* NEED LOCKS IN HERE. */ |
356 SECStatus | 294 SECStatus |
357 SSL_SetPKCS11PinArg(PRFileDesc *s, void *arg) | 295 SSL_SetPKCS11PinArg(PRFileDesc *s, void *arg) |
358 diff --git a/mozilla/security/nss/lib/ssl/sslimpl.h b/mozilla/security/nss/lib/s
sl/sslimpl.h | 296 diff -upN a/src/net/third_party/nss/ssl/sslimpl.h b/src/net/third_party/nss/ssl/
sslimpl.h |
359 index 70ff4c3..d73a0e3 100644 | 297 --- a/src/net/third_party/nss/ssl/sslimpl.h» 2012-02-28 19:26:04.047351199 -0
800 |
360 --- a/mozilla/security/nss/lib/ssl/sslimpl.h | 298 +++ b/src/net/third_party/nss/ssl/sslimpl.h» 2012-02-28 20:04:24.039351965 -0
800 |
361 +++ b/mozilla/security/nss/lib/ssl/sslimpl.h | |
362 @@ -65,6 +65,15 @@ | 299 @@ -65,6 +65,15 @@ |
363 | 300 |
364 #include "sslt.h" /* for some formerly private types, now public */ | 301 #include "sslt.h" /* for some formerly private types, now public */ |
365 | 302 |
366 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 303 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
367 +#if defined(XP_WIN32) | 304 +#if defined(XP_WIN32) |
368 +#include <windows.h> | 305 +#include <windows.h> |
369 +#include <wincrypt.h> | 306 +#include <wincrypt.h> |
370 +#elif defined(XP_MACOSX) | 307 +#elif defined(XP_MACOSX) |
371 +#include <Security/Security.h> | 308 +#include <Security/Security.h> |
372 +#endif | 309 +#endif |
373 +#endif | 310 +#endif |
374 + | 311 + |
375 /* to make some of these old enums public without namespace pollution, | 312 /* to make some of these old enums public without namespace pollution, |
376 ** it was necessary to prepend ssl_ to the names. | 313 ** it was necessary to prepend ssl_ to the names. |
377 ** These #defines preserve compatibility with the old code here in libssl. | 314 ** These #defines preserve compatibility with the old code here in libssl. |
378 @@ -464,6 +473,14 @@ typedef SECStatus (*SSLCompressor)(void * con
text, | 315 @@ -462,6 +471,14 @@ typedef SECStatus (*SSLCompressor)(void |
379 int inlen); | 316 int inlen); |
380 typedef SECStatus (*SSLDestroy)(void *context, PRBool freeit); | 317 typedef SECStatus (*SSLDestroy)(void *context, PRBool freeit); |
381 | 318 |
382 +#if defined(NSS_PLATFORM_CLIENT_AUTH) && defined(XP_WIN32) | 319 +#if defined(NSS_PLATFORM_CLIENT_AUTH) && defined(XP_WIN32) |
383 +typedef PCERT_KEY_CONTEXT PlatformKey; | 320 +typedef PCERT_KEY_CONTEXT PlatformKey; |
384 +#elif defined(NSS_PLATFORM_CLIENT_AUTH) && defined(XP_MACOSX) | 321 +#elif defined(NSS_PLATFORM_CLIENT_AUTH) && defined(XP_MACOSX) |
385 +typedef SecKeyRef PlatformKey; | 322 +typedef SecKeyRef PlatformKey; |
386 +#else | 323 +#else |
387 +typedef void *PlatformKey; | 324 +typedef void *PlatformKey; |
388 +#endif | 325 +#endif |
389 + | 326 + |
390 | 327 |
391 | 328 |
392 /* | 329 /* |
393 @@ -836,6 +853,10 @@ struct ssl3StateStr { | 330 @@ -836,6 +853,10 @@ struct ssl3StateStr { |
394 | 331 |
395 CERTCertificate * clientCertificate; /* used by client */ | 332 CERTCertificate * clientCertificate; /* used by client */ |
396 SECKEYPrivateKey * clientPrivateKey; /* used by client */ | 333 SECKEYPrivateKey * clientPrivateKey; /* used by client */ |
397 + /* platformClientKey is present even when NSS_PLATFORM_CLIENT_AUTH is not | 334 + /* platformClientKey is present even when NSS_PLATFORM_CLIENT_AUTH is not |
398 + * defined in order to allow cleaner conditional code. | 335 + * defined in order to allow cleaner conditional code. |
399 + * At most one of clientPrivateKey and platformClientKey may be set. */ | 336 + * At most one of clientPrivateKey and platformClientKey may be set. */ |
400 + PlatformKey platformClientKey; /* used by client */ | 337 + PlatformKey platformClientKey; /* used by client */ |
401 CERTCertificateList *clientCertChain; /* used by client */ | 338 CERTCertificateList *clientCertChain; /* used by client */ |
402 PRBool sendEmptyCert; /* used by client */ | 339 PRBool sendEmptyCert; /* used by client */ |
403 | 340 |
404 @@ -1097,6 +1118,10 @@ const unsigned char * preferredCipher; | 341 @@ -1082,6 +1103,10 @@ const unsigned char * preferredCipher; |
405 void *authCertificateArg; | 342 void *authCertificateArg; |
406 SSLGetClientAuthData getClientAuthData; | 343 SSLGetClientAuthData getClientAuthData; |
407 void *getClientAuthDataArg; | 344 void *getClientAuthDataArg; |
408 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 345 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
409 + SSLGetPlatformClientAuthData getPlatformClientAuthData; | 346 + SSLGetPlatformClientAuthData getPlatformClientAuthData; |
410 + void *getPlatformClientAuthDataArg; | 347 + void *getPlatformClientAuthDataArg; |
411 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 348 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
412 SSLSNISocketConfig sniSocketConfig; | 349 SSLSNISocketConfig sniSocketConfig; |
413 void *sniSocketConfigArg; | 350 void *sniSocketConfigArg; |
414 SSLBadCertHandler handleBadCert; | 351 SSLBadCertHandler handleBadCert; |
415 @@ -1663,6 +1688,26 @@ extern SECStatus ssl_InitSessionCacheLocks(PRBool lazyIni
t); | 352 @@ -1644,6 +1669,26 @@ extern SECStatus ssl_InitSessionCacheLoc |
416 | 353 |
417 extern SECStatus ssl_FreeSessionCacheLocks(void); | 354 extern SECStatus ssl_FreeSessionCacheLocks(void); |
418 | 355 |
419 +/***************** platform client auth ****************/ | 356 +/***************** platform client auth ****************/ |
420 + | 357 + |
421 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 358 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
422 +// Releases the platform key. | 359 +// Releases the platform key. |
423 +extern void ssl_FreePlatformKey(PlatformKey key); | 360 +extern void ssl_FreePlatformKey(PlatformKey key); |
424 + | 361 + |
425 +// Implement the client CertificateVerify message for SSL3/TLS1.0 | 362 +// Implement the client CertificateVerify message for SSL3/TLS1.0 |
426 +extern SECStatus ssl3_PlatformSignHashes(SSL3Hashes *hash, | 363 +extern SECStatus ssl3_PlatformSignHashes(SSL3Hashes *hash, |
427 + PlatformKey key, SECItem *buf, | 364 + PlatformKey key, SECItem *buf, |
428 + PRBool isTLS); | 365 + PRBool isTLS); |
429 + | 366 + |
430 +// Converts a CERTCertList* (A collection of CERTCertificates) into a | 367 +// Converts a CERTCertList* (A collection of CERTCertificates) into a |
431 +// CERTCertificateList* (A collection of SECItems), or returns NULL if | 368 +// CERTCertificateList* (A collection of SECItems), or returns NULL if |
432 +// it cannot be converted. | 369 +// it cannot be converted. |
433 +// This is to allow the platform-supplied chain to be created with purely | 370 +// This is to allow the platform-supplied chain to be created with purely |
434 +// public API functions, using the preferred CERTCertList mutators, rather | 371 +// public API functions, using the preferred CERTCertList mutators, rather |
435 +// pushing this hack to clients. | 372 +// pushing this hack to clients. |
436 +extern CERTCertificateList* hack_NewCertificateListFromCertList( | 373 +extern CERTCertificateList* hack_NewCertificateListFromCertList( |
437 + CERTCertList* list); | 374 + CERTCertList* list); |
438 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 375 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
439 | 376 |
440 /********************** misc calls *********************/ | 377 /********************** misc calls *********************/ |
441 | 378 |
442 diff --git a/mozilla/security/nss/lib/ssl/sslplatf.c b/mozilla/security/nss/lib/
ssl/sslplatf.c | 379 diff -upN a/src/net/third_party/nss/ssl/sslplatf.c b/src/net/third_party/nss/ssl
/sslplatf.c |
443 new file mode 100644 | 380 --- a/src/net/third_party/nss/ssl/sslplatf.c» 1969-12-31 16:00:00.000000000 -0
800 |
444 index 0000000..208956f | 381 +++ b/src/net/third_party/nss/ssl/sslplatf.c» 2012-02-28 20:04:24.039351965 -0
800 |
445 --- /dev/null | |
446 +++ b/mozilla/security/nss/lib/ssl/sslplatf.c | |
447 @@ -0,0 +1,399 @@ | 382 @@ -0,0 +1,399 @@ |
448 +/* | 383 +/* |
449 + * Platform specific crypto wrappers | 384 + * Platform specific crypto wrappers |
450 + * | 385 + * |
451 + * ***** BEGIN LICENSE BLOCK ***** | 386 + * ***** BEGIN LICENSE BLOCK ***** |
452 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 387 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
453 + * | 388 + * |
454 + * The contents of this file are subject to the Mozilla Public License Version | 389 + * The contents of this file are subject to the Mozilla Public License Version |
455 + * 1.1 (the "License"); you may not use this file except in compliance with | 390 + * 1.1 (the "License"); you may not use this file except in compliance with |
456 + * the License. You may obtain a copy of the License at | 391 + * the License. You may obtain a copy of the License at |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 +SECStatus | 772 +SECStatus |
838 +ssl3_PlatformSignHashes(SSL3Hashes *hash, PlatformKey key, SECItem *buf, | 773 +ssl3_PlatformSignHashes(SSL3Hashes *hash, PlatformKey key, SECItem *buf, |
839 + PRBool isTLS) | 774 + PRBool isTLS) |
840 +{ | 775 +{ |
841 + PORT_SetError(PR_NOT_IMPLEMENTED_ERROR); | 776 + PORT_SetError(PR_NOT_IMPLEMENTED_ERROR); |
842 + return SECFailure; | 777 + return SECFailure; |
843 +} | 778 +} |
844 +#endif | 779 +#endif |
845 + | 780 + |
846 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 781 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
847 diff --git a/mozilla/security/nss/lib/ssl/sslsock.c b/mozilla/security/nss/lib/s
sl/sslsock.c | 782 diff -upN a/src/net/third_party/nss/ssl/sslsock.c b/src/net/third_party/nss/ssl/
sslsock.c |
848 index 7d12bfe..68fd3cb 100644 | 783 --- a/src/net/third_party/nss/ssl/sslsock.c» 2012-02-28 19:26:04.057351342 -0
800 |
849 --- a/mozilla/security/nss/lib/ssl/sslsock.c | 784 +++ b/src/net/third_party/nss/ssl/sslsock.c» 2012-02-28 20:04:24.049352104 -0
800 |
850 +++ b/mozilla/security/nss/lib/ssl/sslsock.c | |
851 @@ -339,6 +339,10 @@ ssl_DupSocket(sslSocket *os) | 785 @@ -339,6 +339,10 @@ ssl_DupSocket(sslSocket *os) |
852 ss->authCertificateArg = os->authCertificateArg; | 786 ss->authCertificateArg = os->authCertificateArg; |
853 ss->getClientAuthData = os->getClientAuthData; | 787 ss->getClientAuthData = os->getClientAuthData; |
854 ss->getClientAuthDataArg = os->getClientAuthDataArg; | 788 ss->getClientAuthDataArg = os->getClientAuthDataArg; |
855 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 789 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
856 + ss->getPlatformClientAuthData = os->getPlatformClientAuthData; | 790 + ss->getPlatformClientAuthData = os->getPlatformClientAuthData; |
857 + ss->getPlatformClientAuthDataArg = os->getPlatformClientAuthDataArg; | 791 + ss->getPlatformClientAuthDataArg = os->getPlatformClientAuthDataArg; |
858 +#endif | 792 +#endif |
859 ss->sniSocketConfig = os->sniSocketConfig; | 793 ss->sniSocketConfig = os->sniSocketConfig; |
860 ss->sniSocketConfigArg = os->sniSocketConfigArg; | 794 ss->sniSocketConfigArg = os->sniSocketConfigArg; |
861 ss->handleBadCert = os->handleBadCert; | 795 ss->handleBadCert = os->handleBadCert; |
862 @@ -1468,6 +1472,12 @@ SSL_ReconfigFD(PRFileDesc *model, PRFileDesc *fd) | 796 @@ -1530,6 +1534,12 @@ SSL_ReconfigFD(PRFileDesc *model, PRFile |
863 ss->getClientAuthData = sm->getClientAuthData; | 797 ss->getClientAuthData = sm->getClientAuthData; |
864 if (sm->getClientAuthDataArg) | 798 if (sm->getClientAuthDataArg) |
865 ss->getClientAuthDataArg = sm->getClientAuthDataArg; | 799 ss->getClientAuthDataArg = sm->getClientAuthDataArg; |
866 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 800 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
867 + if (sm->getPlatformClientAuthData) | 801 + if (sm->getPlatformClientAuthData) |
868 + ss->getPlatformClientAuthData = sm->getPlatformClientAuthData; | 802 + ss->getPlatformClientAuthData = sm->getPlatformClientAuthData; |
869 + if (sm->getPlatformClientAuthDataArg) | 803 + if (sm->getPlatformClientAuthDataArg) |
870 + ss->getPlatformClientAuthDataArg = sm->getPlatformClientAuthDataArg; | 804 + ss->getPlatformClientAuthDataArg = sm->getPlatformClientAuthDataArg; |
871 +#endif | 805 +#endif |
872 if (sm->sniSocketConfig) | 806 if (sm->sniSocketConfig) |
873 ss->sniSocketConfig = sm->sniSocketConfig; | 807 ss->sniSocketConfig = sm->sniSocketConfig; |
874 if (sm->sniSocketConfigArg) | 808 if (sm->sniSocketConfigArg) |
875 @@ -2525,6 +2535,10 @@ ssl_NewSocket(PRBool makeLocks) | 809 @@ -2617,6 +2627,10 @@ ssl_NewSocket(PRBool makeLocks) |
876 ss->sniSocketConfig = NULL; | 810 ss->sniSocketConfig = NULL; |
877 ss->sniSocketConfigArg = NULL; | 811 ss->sniSocketConfigArg = NULL; |
878 ss->getClientAuthData = NULL; | 812 ss->getClientAuthData = NULL; |
879 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 813 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
880 + ss->getPlatformClientAuthData = NULL; | 814 + ss->getPlatformClientAuthData = NULL; |
881 + ss->getPlatformClientAuthDataArg = NULL; | 815 + ss->getPlatformClientAuthDataArg = NULL; |
882 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 816 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
883 ss->handleBadCert = NULL; | 817 ss->handleBadCert = NULL; |
884 ss->badCertArg = NULL; | 818 ss->badCertArg = NULL; |
885 ss->pkcs11PinArg = NULL; | 819 ss->pkcs11PinArg = NULL; |
OLD | NEW |