| OLD | NEW |
| 1 diff -pu a/nss/lib/ssl/ssl3con.c b/nss/lib/ssl/ssl3con.c | 1 diff -pu a/nss/lib/ssl/ssl3con.c b/nss/lib/ssl/ssl3con.c |
| 2 --- a/nss/lib/ssl/ssl3con.c» 2013-07-31 12:31:45.326118409 -0700 | 2 --- a/nss/lib/ssl/ssl3con.c» 2014-01-03 19:30:40.073373382 -0800 |
| 3 +++ b/nss/lib/ssl/ssl3con.c» 2013-07-31 12:35:27.189373289 -0700 | 3 +++ b/nss/lib/ssl/ssl3con.c» 2014-01-03 19:30:52.653579045 -0800 |
| 4 @@ -2284,6 +2284,9 @@ ssl3_ClientAuthTokenPresent(sslSessionID | 4 @@ -2471,6 +2471,9 @@ ssl3_ClientAuthTokenPresent(sslSessionID |
| 5 PRBool isPresent = PR_TRUE; | 5 PRBool isPresent = PR_TRUE; |
| 6 | 6 |
| 7 /* we only care if we are doing client auth */ | 7 /* we only care if we are doing client auth */ |
| 8 + /* If NSS_PLATFORM_CLIENT_AUTH is defined and a platformClientKey is being | 8 + /* If NSS_PLATFORM_CLIENT_AUTH is defined and a platformClientKey is being |
| 9 + * used, u.ssl3.clAuthValid will be false and this function will always | 9 + * used, u.ssl3.clAuthValid will be false and this function will always |
| 10 + * return PR_TRUE. */ | 10 + * return PR_TRUE. */ |
| 11 if (!sid || !sid->u.ssl3.clAuthValid) { | 11 if (!sid || !sid->u.ssl3.clAuthValid) { |
| 12 return PR_TRUE; | 12 return PR_TRUE; |
| 13 } | 13 } |
| 14 @@ -5768,25 +5771,36 @@ ssl3_SendCertificateVerify(sslSocket *ss | 14 @@ -6080,25 +6083,36 @@ ssl3_SendCertificateVerify(sslSocket *ss |
| 15 | 15 |
| 16 isTLS = (PRBool)(ss->ssl3.pwSpec->version > SSL_LIBRARY_VERSION_3_0); | 16 isTLS = (PRBool)(ss->ssl3.pwSpec->version > SSL_LIBRARY_VERSION_3_0); |
| 17 isTLS12 = (PRBool)(ss->ssl3.pwSpec->version >= SSL_LIBRARY_VERSION_TLS_1_2)
; | 17 isTLS12 = (PRBool)(ss->ssl3.pwSpec->version >= SSL_LIBRARY_VERSION_TLS_1_2)
; |
| 18 - keyType = ss->ssl3.clientPrivateKey->keyType; | 18 - keyType = ss->ssl3.clientPrivateKey->keyType; |
| 19 - rv = ssl3_SignHashes(&hashes, ss->ssl3.clientPrivateKey, &buf, isTLS); | 19 - rv = ssl3_SignHashes(&hashes, ss->ssl3.clientPrivateKey, &buf, isTLS); |
| 20 - if (rv == SECSuccess) { | 20 - if (rv == SECSuccess) { |
| 21 - PK11SlotInfo * slot; | 21 - PK11SlotInfo * slot; |
| 22 - sslSessionID * sid = ss->sec.ci.sid; | 22 - sslSessionID * sid = ss->sec.ci.sid; |
| 23 + if (ss->ssl3.platformClientKey) { | 23 + if (ss->ssl3.platformClientKey) { |
| 24 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 24 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 + PK11_FreeSlot(slot); | 58 + PK11_FreeSlot(slot); |
| 59 + } | 59 + } |
| 60 + SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey); | 60 + SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey); |
| 61 + ss->ssl3.clientPrivateKey = NULL; | 61 + ss->ssl3.clientPrivateKey = NULL; |
| 62 } | 62 } |
| 63 - SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey); | 63 - SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey); |
| 64 - ss->ssl3.clientPrivateKey = NULL; | 64 - ss->ssl3.clientPrivateKey = NULL; |
| 65 if (rv != SECSuccess) { | 65 if (rv != SECSuccess) { |
| 66 goto done; /* err code was set by ssl3_SignHashes */ | 66 goto done; /* err code was set by ssl3_SignHashes */ |
| 67 } | 67 } |
| 68 @@ -5870,6 +5884,12 @@ ssl3_HandleServerHello(sslSocket *ss, SS | 68 @@ -6177,6 +6191,12 @@ ssl3_HandleServerHello(sslSocket *ss, SS |
| 69 SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey); | 69 SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey); |
| 70 ss->ssl3.clientPrivateKey = NULL; | 70 ss->ssl3.clientPrivateKey = NULL; |
| 71 } | 71 } |
| 72 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 72 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
| 73 + if (ss->ssl3.platformClientKey) { | 73 + if (ss->ssl3.platformClientKey) { |
| 74 + ssl_FreePlatformKey(ss->ssl3.platformClientKey); | 74 + ssl_FreePlatformKey(ss->ssl3.platformClientKey); |
| 75 + ss->ssl3.platformClientKey = (PlatformKey)NULL; | 75 + ss->ssl3.platformClientKey = (PlatformKey)NULL; |
| 76 + } | 76 + } |
| 77 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 77 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
| 78 | 78 |
| 79 temp = ssl3_ConsumeHandshakeNumber(ss, 2, &b, &length); | 79 temp = ssl3_ConsumeHandshakeNumber(ss, 2, &b, &length); |
| 80 if (temp < 0) { | 80 if (temp < 0) { |
| 81 @@ -6496,6 +6516,10 @@ ssl3_HandleCertificateRequest(sslSocket | 81 @@ -6804,6 +6824,18 @@ ssl3_ExtractClientKeyInfo(sslSocket *ss, |
| 82 » goto done; |
| 83 } |
| 84 |
| 85 +#if defined(NSS_PLATFORM_CLIENT_AUTH) && defined(_WIN32) |
| 86 + /* If the key is in CAPI, assume conservatively that the CAPI service |
| 87 + * provider may be unable to sign SHA-256 hashes. |
| 88 + */ |
| 89 + if (ss->ssl3.platformClientKey->dwKeySpec != CERT_NCRYPT_KEY_SPEC) { |
| 90 +» /* CAPI only supports RSA and DSA signatures, so we don't need to |
| 91 +» * check the key type. */ |
| 92 +» *preferSha1 = PR_TRUE; |
| 93 +» goto done; |
| 94 + } |
| 95 +#endif /* NSS_PLATFORM_CLIENT_AUTH && _WIN32 */ |
| 96 + |
| 97 /* If the key is a 1024-bit RSA or DSA key, assume conservatively that |
| 98 * it may be unable to sign SHA-256 hashes. This is the case for older |
| 99 * Estonian ID cards that have 1024-bit RSA keys. In FIPS 186-2 and |
| 100 @@ -6902,6 +6934,10 @@ ssl3_HandleCertificateRequest(sslSocket |
| 82 SECItem cert_types = {siBuffer, NULL, 0}; | 101 SECItem cert_types = {siBuffer, NULL, 0}; |
| 83 SECItem algorithms = {siBuffer, NULL, 0}; | 102 SECItem algorithms = {siBuffer, NULL, 0}; |
| 84 CERTDistNames ca_list; | 103 CERTDistNames ca_list; |
| 85 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 104 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
| 86 + CERTCertList * platform_cert_list = NULL; | 105 + CERTCertList * platform_cert_list = NULL; |
| 87 + CERTCertListNode * certNode = NULL; | 106 + CERTCertListNode * certNode = NULL; |
| 88 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 107 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
| 89 | 108 |
| 90 SSL_TRC(3, ("%d: SSL3[%d]: handle certificate_request handshake", | 109 SSL_TRC(3, ("%d: SSL3[%d]: handle certificate_request handshake", |
| 91 SSL_GETPID(), ss->fd)); | 110 SSL_GETPID(), ss->fd)); |
| 92 @@ -6512,6 +6536,7 @@ ssl3_HandleCertificateRequest(sslSocket | 111 @@ -6918,6 +6954,7 @@ ssl3_HandleCertificateRequest(sslSocket |
| 93 PORT_Assert(ss->ssl3.clientCertChain == NULL); | 112 PORT_Assert(ss->ssl3.clientCertChain == NULL); |
| 94 PORT_Assert(ss->ssl3.clientCertificate == NULL); | 113 PORT_Assert(ss->ssl3.clientCertificate == NULL); |
| 95 PORT_Assert(ss->ssl3.clientPrivateKey == NULL); | 114 PORT_Assert(ss->ssl3.clientPrivateKey == NULL); |
| 96 + PORT_Assert(ss->ssl3.platformClientKey == (PlatformKey)NULL); | 115 + PORT_Assert(ss->ssl3.platformClientKey == (PlatformKey)NULL); |
| 97 | 116 |
| 98 isTLS = (PRBool)(ss->ssl3.prSpec->version > SSL_LIBRARY_VERSION_3_0); | 117 isTLS = (PRBool)(ss->ssl3.prSpec->version > SSL_LIBRARY_VERSION_3_0); |
| 99 isTLS12 = (PRBool)(ss->ssl3.prSpec->version >= SSL_LIBRARY_VERSION_TLS_1_2)
; | 118 isTLS12 = (PRBool)(ss->ssl3.prSpec->version >= SSL_LIBRARY_VERSION_TLS_1_2)
; |
| 100 @@ -6591,6 +6616,18 @@ ssl3_HandleCertificateRequest(sslSocket | 119 @@ -6997,6 +7034,18 @@ ssl3_HandleCertificateRequest(sslSocket |
| 101 desc = no_certificate; | 120 desc = no_certificate; |
| 102 ss->ssl3.hs.ws = wait_hello_done; | 121 ss->ssl3.hs.ws = wait_hello_done; |
| 103 | 122 |
| 104 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 123 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
| 105 + if (ss->getPlatformClientAuthData != NULL) { | 124 + if (ss->getPlatformClientAuthData != NULL) { |
| 106 + /* XXX Should pass cert_types and algorithms in this call!! */ | 125 + /* XXX Should pass cert_types and algorithms in this call!! */ |
| 107 + rv = (SECStatus)(*ss->getPlatformClientAuthData)( | 126 + rv = (SECStatus)(*ss->getPlatformClientAuthData)( |
| 108 + ss->getPlatformClientAuthDataArg, | 127 + ss->getPlatformClientAuthDataArg, |
| 109 + ss->fd, &ca_list, | 128 + ss->fd, &ca_list, |
| 110 + &platform_cert_list, | 129 + &platform_cert_list, |
| 111 + (void**)&ss->ssl3.platformClientKey, | 130 + (void**)&ss->ssl3.platformClientKey, |
| 112 + &ss->ssl3.clientCertificate, | 131 + &ss->ssl3.clientCertificate, |
| 113 + &ss->ssl3.clientPrivateKey); | 132 + &ss->ssl3.clientPrivateKey); |
| 114 + } else | 133 + } else |
| 115 +#endif | 134 +#endif |
| 116 if (ss->getClientAuthData != NULL) { | 135 if (ss->getClientAuthData != NULL) { |
| 117 /* XXX Should pass cert_types and algorithms in this call!! */ | 136 /* XXX Should pass cert_types and algorithms in this call!! */ |
| 118 rv = (SECStatus)(*ss->getClientAuthData)(ss->getClientAuthDataArg, | 137 rv = (SECStatus)(*ss->getClientAuthData)(ss->getClientAuthDataArg, |
| 119 @@ -6600,12 +6637,52 @@ ssl3_HandleCertificateRequest(sslSocket | 138 @@ -7006,12 +7055,55 @@ ssl3_HandleCertificateRequest(sslSocket |
| 120 } else { | 139 } else { |
| 121 rv = SECFailure; /* force it to send a no_certificate alert */ | 140 rv = SECFailure; /* force it to send a no_certificate alert */ |
| 122 } | 141 } |
| 123 + | 142 + |
| 124 switch (rv) { | 143 switch (rv) { |
| 125 case SECWouldBlock: /* getClientAuthData has put up a dialog box. */ | 144 case SECWouldBlock: /* getClientAuthData has put up a dialog box. */ |
| 126 ssl3_SetAlwaysBlock(ss); | 145 ssl3_SetAlwaysBlock(ss); |
| 127 break; /* not an error */ | 146 break; /* not an error */ |
| 128 | 147 |
| 129 case SECSuccess: | 148 case SECSuccess: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 156 + if (ss->ssl3.clientCertificate != NULL) { | 175 + if (ss->ssl3.clientCertificate != NULL) { |
| 157 + CERT_DestroyCertificate(ss->ssl3.clientCertificate); | 176 + CERT_DestroyCertificate(ss->ssl3.clientCertificate); |
| 158 + ss->ssl3.clientCertificate = NULL; | 177 + ss->ssl3.clientCertificate = NULL; |
| 159 + } | 178 + } |
| 160 + if (ss->ssl3.platformClientKey) { | 179 + if (ss->ssl3.platformClientKey) { |
| 161 + ssl_FreePlatformKey(ss->ssl3.platformClientKey); | 180 + ssl_FreePlatformKey(ss->ssl3.platformClientKey); |
| 162 + ss->ssl3.platformClientKey = (PlatformKey)NULL; | 181 + ss->ssl3.platformClientKey = (PlatformKey)NULL; |
| 163 + } | 182 + } |
| 164 + goto send_no_certificate; | 183 + goto send_no_certificate; |
| 165 + } | 184 + } |
| 185 + if (ss->ssl3.hs.hashType == handshake_hash_single) { |
| 186 + ssl3_DestroyBackupHandshakeHashIfNotNeeded(ss, &algorithms); |
| 187 + } |
| 166 + break; /* not an error */ | 188 + break; /* not an error */ |
| 167 + } | 189 + } |
| 168 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 190 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
| 169 /* check what the callback function returned */ | 191 /* check what the callback function returned */ |
| 170 if ((!ss->ssl3.clientCertificate) || (!ss->ssl3.clientPrivateKey)) { | 192 if ((!ss->ssl3.clientCertificate) || (!ss->ssl3.clientPrivateKey)) { |
| 171 /* we are missing either the key or cert */ | 193 /* we are missing either the key or cert */ |
| 172 @@ -6668,6 +6745,10 @@ loser: | 194 @@ -7073,6 +7165,10 @@ loser: |
| 173 done: | 195 done: |
| 174 if (arena != NULL) | 196 if (arena != NULL) |
| 175 PORT_FreeArena(arena, PR_FALSE); | 197 PORT_FreeArena(arena, PR_FALSE); |
| 176 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 198 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
| 177 + if (platform_cert_list) | 199 + if (platform_cert_list) |
| 178 + CERT_DestroyCertList(platform_cert_list); | 200 + CERT_DestroyCertList(platform_cert_list); |
| 179 +#endif | 201 +#endif |
| 180 return rv; | 202 return rv; |
| 181 } | 203 } |
| 182 | 204 |
| 183 @@ -6749,7 +6830,8 @@ ssl3_SendClientSecondRound(sslSocket *ss | 205 @@ -7190,7 +7286,8 @@ ssl3_SendClientSecondRound(sslSocket *ss |
| 184 | 206 |
| 185 sendClientCert = !ss->ssl3.sendEmptyCert && | 207 sendClientCert = !ss->ssl3.sendEmptyCert && |
| 186 ss->ssl3.clientCertChain != NULL && | 208 ss->ssl3.clientCertChain != NULL && |
| 187 - ss->ssl3.clientPrivateKey != NULL; | 209 - ss->ssl3.clientPrivateKey != NULL; |
| 188 + (ss->ssl3.platformClientKey || | 210 + (ss->ssl3.platformClientKey || |
| 189 + ss->ssl3.clientPrivateKey != NULL); | 211 + ss->ssl3.clientPrivateKey != NULL); |
| 190 | 212 |
| 191 /* We must wait for the server's certificate to be authenticated before | 213 if (!sendClientCert && |
| 192 * sending the client certificate in order to disclosing the client | 214 » ss->ssl3.hs.hashType == handshake_hash_single && |
| 193 @@ -11465,6 +11547,10 @@ ssl3_DestroySSL3Info(sslSocket *ss) | 215 @@ -12027,6 +12124,10 @@ ssl3_DestroySSL3Info(sslSocket *ss) |
| 194 | 216 |
| 195 if (ss->ssl3.clientPrivateKey != NULL) | 217 if (ss->ssl3.clientPrivateKey != NULL) |
| 196 SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey); | 218 SECKEY_DestroyPrivateKey(ss->ssl3.clientPrivateKey); |
| 197 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 219 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
| 198 + if (ss->ssl3.platformClientKey) | 220 + if (ss->ssl3.platformClientKey) |
| 199 + ssl_FreePlatformKey(ss->ssl3.platformClientKey); | 221 + ssl_FreePlatformKey(ss->ssl3.platformClientKey); |
| 200 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 222 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
| 201 | 223 |
| 202 if (ss->ssl3.peerCertArena != NULL) | 224 if (ss->ssl3.peerCertArena != NULL) |
| 203 ssl3_CleanupPeerCerts(ss); | 225 ssl3_CleanupPeerCerts(ss); |
| 204 diff -pu a/nss/lib/ssl/ssl3ext.c b/nss/lib/ssl/ssl3ext.c | 226 diff -pu a/nss/lib/ssl/ssl3ext.c b/nss/lib/ssl/ssl3ext.c |
| 205 --- a/nss/lib/ssl/ssl3ext.c» 2013-07-31 12:07:10.964699464 -0700 | 227 --- a/nss/lib/ssl/ssl3ext.c» 2014-01-03 19:28:03.550814608 -0800 |
| 206 +++ b/nss/lib/ssl/ssl3ext.c» 2013-07-31 12:35:27.189373289 -0700 | 228 +++ b/nss/lib/ssl/ssl3ext.c» 2014-01-03 19:30:52.653579045 -0800 |
| 207 @@ -10,8 +10,8 @@ | 229 @@ -10,8 +10,8 @@ |
| 208 #include "nssrenam.h" | 230 #include "nssrenam.h" |
| 209 #include "nss.h" | 231 #include "nss.h" |
| 210 #include "ssl.h" | 232 #include "ssl.h" |
| 211 -#include "sslproto.h" | 233 -#include "sslproto.h" |
| 212 #include "sslimpl.h" | 234 #include "sslimpl.h" |
| 213 +#include "sslproto.h" | 235 +#include "sslproto.h" |
| 214 #include "pk11pub.h" | 236 #include "pk11pub.h" |
| 215 #ifdef NO_PKCS11_BYPASS | 237 #ifdef NO_PKCS11_BYPASS |
| 216 #include "blapit.h" | 238 #include "blapit.h" |
| 217 diff -pu a/nss/lib/ssl/sslauth.c b/nss/lib/ssl/sslauth.c | 239 diff -pu a/nss/lib/ssl/sslauth.c b/nss/lib/ssl/sslauth.c |
| 218 --- a/nss/lib/ssl/sslauth.c» 2013-07-31 12:32:29.076760372 -0700 | 240 --- a/nss/lib/ssl/sslauth.c» 2014-01-03 19:28:03.550814608 -0800 |
| 219 +++ b/nss/lib/ssl/sslauth.c» 2013-07-31 12:35:27.189373289 -0700 | 241 +++ b/nss/lib/ssl/sslauth.c» 2014-01-03 19:30:52.653579045 -0800 |
| 220 @@ -219,6 +219,28 @@ SSL_GetClientAuthDataHook(PRFileDesc *s, | 242 @@ -216,6 +216,28 @@ SSL_GetClientAuthDataHook(PRFileDesc *s, |
| 221 return SECSuccess; | 243 return SECSuccess; |
| 222 } | 244 } |
| 223 | 245 |
| 224 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 246 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
| 225 +/* NEED LOCKS IN HERE. */ | 247 +/* NEED LOCKS IN HERE. */ |
| 226 +SECStatus | 248 +SECStatus |
| 227 +SSL_GetPlatformClientAuthDataHook(PRFileDesc *s, | 249 +SSL_GetPlatformClientAuthDataHook(PRFileDesc *s, |
| 228 + SSLGetPlatformClientAuthData func, | 250 + SSLGetPlatformClientAuthData func, |
| 229 + void *arg) | 251 + void *arg) |
| 230 +{ | 252 +{ |
| 231 + sslSocket *ss; | 253 + sslSocket *ss; |
| 232 + | 254 + |
| 233 + ss = ssl_FindSocket(s); | 255 + ss = ssl_FindSocket(s); |
| 234 + if (!ss) { | 256 + if (!ss) { |
| 235 + SSL_DBG(("%d: SSL[%d]: bad socket in GetPlatformClientAuthDataHook", | 257 + SSL_DBG(("%d: SSL[%d]: bad socket in GetPlatformClientAuthDataHook", |
| 236 + SSL_GETPID(), s)); | 258 + SSL_GETPID(), s)); |
| 237 + return SECFailure; | 259 + return SECFailure; |
| 238 + } | 260 + } |
| 239 + | 261 + |
| 240 + ss->getPlatformClientAuthData = func; | 262 + ss->getPlatformClientAuthData = func; |
| 241 + ss->getPlatformClientAuthDataArg = arg; | 263 + ss->getPlatformClientAuthDataArg = arg; |
| 242 + return SECSuccess; | 264 + return SECSuccess; |
| 243 +} | 265 +} |
| 244 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 266 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
| 245 + | 267 + |
| 246 /* NEED LOCKS IN HERE. */ | 268 /* NEED LOCKS IN HERE. */ |
| 247 SECStatus | 269 SECStatus |
| 248 SSL_SetPKCS11PinArg(PRFileDesc *s, void *arg) | 270 SSL_SetPKCS11PinArg(PRFileDesc *s, void *arg) |
| 249 diff -pu a/nss/lib/ssl/ssl.h b/nss/lib/ssl/ssl.h | 271 diff -pu a/nss/lib/ssl/ssl.h b/nss/lib/ssl/ssl.h |
| 250 --- a/nss/lib/ssl/ssl.h»2013-07-31 12:32:29.076760372 -0700 | 272 --- a/nss/lib/ssl/ssl.h»2014-01-03 19:28:03.540814444 -0800 |
| 251 +++ b/nss/lib/ssl/ssl.h»2013-07-31 12:35:27.199373436 -0700 | 273 +++ b/nss/lib/ssl/ssl.h»2014-01-03 19:30:52.653579045 -0800 |
| 252 @@ -503,6 +503,48 @@ typedef SECStatus (PR_CALLBACK *SSLGetCl | 274 @@ -503,6 +503,48 @@ typedef SECStatus (PR_CALLBACK *SSLGetCl |
| 253 SSL_IMPORT SECStatus SSL_GetClientAuthDataHook(PRFileDesc *fd, | 275 SSL_IMPORT SECStatus SSL_GetClientAuthDataHook(PRFileDesc *fd, |
| 254 SSLGetClientAuthData f, void *a); | 276 SSLGetClientAuthData f, void *a); |
| 255 | 277 |
| 256 +/* | 278 +/* |
| 257 + * Prototype for SSL callback to get client auth data from the application, | 279 + * Prototype for SSL callback to get client auth data from the application, |
| 258 + * optionally using the underlying platform's cryptographic primitives. | 280 + * optionally using the underlying platform's cryptographic primitives. |
| 259 + * To use the platform cryptographic primitives, caNames and pRetCerts | 281 + * To use the platform cryptographic primitives, caNames and pRetCerts |
| 260 + * should be set. To use NSS, pRetNSSCert and pRetNSSKey should be set. | 282 + * should be set. To use NSS, pRetNSSCert and pRetNSSKey should be set. |
| 261 + * Returning SECFailure will cause the socket to send no client certificate. | 283 + * Returning SECFailure will cause the socket to send no client certificate. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 292 + * f - the application's callback that delivers the key and cert | 314 + * f - the application's callback that delivers the key and cert |
| 293 + * a - application specific data | 315 + * a - application specific data |
| 294 + */ | 316 + */ |
| 295 +SSL_IMPORT SECStatus | 317 +SSL_IMPORT SECStatus |
| 296 +SSL_GetPlatformClientAuthDataHook(PRFileDesc *fd, | 318 +SSL_GetPlatformClientAuthDataHook(PRFileDesc *fd, |
| 297 + SSLGetPlatformClientAuthData f, void *a); | 319 + SSLGetPlatformClientAuthData f, void *a); |
| 298 | 320 |
| 299 /* | 321 /* |
| 300 ** SNI extension processing callback function. | 322 ** SNI extension processing callback function. |
| 301 diff -pu a/nss/lib/ssl/sslimpl.h b/nss/lib/ssl/sslimpl.h | 323 diff -pu a/nss/lib/ssl/sslimpl.h b/nss/lib/ssl/sslimpl.h |
| 302 --- a/nss/lib/ssl/sslimpl.h» 2013-07-31 12:31:45.326118409 -0700 | 324 --- a/nss/lib/ssl/sslimpl.h» 2014-01-03 19:30:40.073373382 -0800 |
| 303 +++ b/nss/lib/ssl/sslimpl.h» 2013-07-31 12:35:27.199373436 -0700 | 325 +++ b/nss/lib/ssl/sslimpl.h» 2014-01-03 19:30:52.653579045 -0800 |
| 304 @@ -20,6 +20,7 @@ | 326 @@ -20,6 +20,7 @@ |
| 305 #include "sslerr.h" | 327 #include "sslerr.h" |
| 306 #include "ssl3prot.h" | 328 #include "ssl3prot.h" |
| 307 #include "hasht.h" | 329 #include "hasht.h" |
| 308 +#include "keythi.h" | 330 +#include "keythi.h" |
| 309 #include "nssilock.h" | 331 #include "nssilock.h" |
| 310 #include "pkcs11t.h" | 332 #include "pkcs11t.h" |
| 311 #if defined(XP_UNIX) || defined(XP_BEOS) | 333 #if defined(XP_UNIX) || defined(XP_BEOS) |
| 312 @@ -31,6 +32,15 @@ | 334 @@ -31,6 +32,15 @@ |
| 313 | 335 |
| 314 #include "sslt.h" /* for some formerly private types, now public */ | 336 #include "sslt.h" /* for some formerly private types, now public */ |
| 315 | 337 |
| 316 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 338 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
| 317 +#if defined(XP_WIN32) | 339 +#if defined(XP_WIN32) |
| 318 +#include <windows.h> | 340 +#include <windows.h> |
| 319 +#include <wincrypt.h> | 341 +#include <wincrypt.h> |
| 320 +#elif defined(XP_MACOSX) | 342 +#elif defined(XP_MACOSX) |
| 321 +#include <Security/Security.h> | 343 +#include <Security/Security.h> |
| 322 +#endif | 344 +#endif |
| 323 +#endif | 345 +#endif |
| 324 + | 346 + |
| 325 /* to make some of these old enums public without namespace pollution, | 347 /* to make some of these old enums public without namespace pollution, |
| 326 ** it was necessary to prepend ssl_ to the names. | 348 ** it was necessary to prepend ssl_ to the names. |
| 327 ** These #defines preserve compatibility with the old code here in libssl. | 349 ** These #defines preserve compatibility with the old code here in libssl. |
| 328 @@ -444,6 +454,14 @@ typedef SECStatus (*SSLCompressor)(void | 350 @@ -432,6 +442,14 @@ struct sslGatherStr { |
| 329 int inlen); | 351 #define GS_DATA» » 3 |
| 330 typedef SECStatus (*SSLDestroy)(void *context, PRBool freeit); | 352 #define GS_PAD»» 4 |
| 331 | 353 |
| 332 +#if defined(NSS_PLATFORM_CLIENT_AUTH) && defined(XP_WIN32) | 354 +#if defined(NSS_PLATFORM_CLIENT_AUTH) && defined(XP_WIN32) |
| 333 +typedef PCERT_KEY_CONTEXT PlatformKey; | 355 +typedef PCERT_KEY_CONTEXT PlatformKey; |
| 334 +#elif defined(NSS_PLATFORM_CLIENT_AUTH) && defined(XP_MACOSX) | 356 +#elif defined(NSS_PLATFORM_CLIENT_AUTH) && defined(XP_MACOSX) |
| 335 +typedef SecKeyRef PlatformKey; | 357 +typedef SecKeyRef PlatformKey; |
| 336 +#else | 358 +#else |
| 337 +typedef void *PlatformKey; | 359 +typedef void *PlatformKey; |
| 338 +#endif | 360 +#endif |
| 339 + | 361 + |
| 340 | 362 |
| 341 | 363 |
| 342 /* | 364 /* |
| 343 @@ -896,6 +914,10 @@ struct ssl3StateStr { | 365 @@ -944,6 +962,10 @@ struct ssl3StateStr { |
| 344 | 366 |
| 345 CERTCertificate * clientCertificate; /* used by client */ | 367 CERTCertificate * clientCertificate; /* used by client */ |
| 346 SECKEYPrivateKey * clientPrivateKey; /* used by client */ | 368 SECKEYPrivateKey * clientPrivateKey; /* used by client */ |
| 347 + /* platformClientKey is present even when NSS_PLATFORM_CLIENT_AUTH is not | 369 + /* platformClientKey is present even when NSS_PLATFORM_CLIENT_AUTH is not |
| 348 + * defined in order to allow cleaner conditional code. | 370 + * defined in order to allow cleaner conditional code. |
| 349 + * At most one of clientPrivateKey and platformClientKey may be set. */ | 371 + * At most one of clientPrivateKey and platformClientKey may be set. */ |
| 350 + PlatformKey platformClientKey; /* used by client */ | 372 + PlatformKey platformClientKey; /* used by client */ |
| 351 CERTCertificateList *clientCertChain; /* used by client */ | 373 CERTCertificateList *clientCertChain; /* used by client */ |
| 352 PRBool sendEmptyCert; /* used by client */ | 374 PRBool sendEmptyCert; /* used by client */ |
| 353 | 375 |
| 354 @@ -1153,6 +1175,10 @@ const unsigned char * preferredCipher; | 376 @@ -1205,6 +1227,10 @@ const unsigned char * preferredCipher; |
| 355 void *authCertificateArg; | 377 void *authCertificateArg; |
| 356 SSLGetClientAuthData getClientAuthData; | 378 SSLGetClientAuthData getClientAuthData; |
| 357 void *getClientAuthDataArg; | 379 void *getClientAuthDataArg; |
| 358 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 380 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
| 359 + SSLGetPlatformClientAuthData getPlatformClientAuthData; | 381 + SSLGetPlatformClientAuthData getPlatformClientAuthData; |
| 360 + void *getPlatformClientAuthDataArg; | 382 + void *getPlatformClientAuthDataArg; |
| 361 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 383 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
| 362 SSLSNISocketConfig sniSocketConfig; | 384 SSLSNISocketConfig sniSocketConfig; |
| 363 void *sniSocketConfigArg; | 385 void *sniSocketConfigArg; |
| 364 SSLBadCertHandler handleBadCert; | 386 SSLBadCertHandler handleBadCert; |
| 365 @@ -1737,7 +1763,6 @@ extern void ssl_FreePRSocket(PRFileDesc | 387 @@ -1843,6 +1869,26 @@ extern SECStatus ssl_InitSessionCacheLoc |
| 366 * various ciphers */ | |
| 367 extern int ssl3_config_match_init(sslSocket *); | |
| 368 | |
| 369 - | |
| 370 /* Create a new ref counted key pair object from two keys. */ | |
| 371 extern ssl3KeyPair * ssl3_NewKeyPair( SECKEYPrivateKey * privKey, | |
| 372 SECKEYPublicKey * pubKey); | |
| 373 @@ -1777,6 +1802,26 @@ extern SECStatus ssl_InitSessionCacheLoc | |
| 374 | 388 |
| 375 extern SECStatus ssl_FreeSessionCacheLocks(void); | 389 extern SECStatus ssl_FreeSessionCacheLocks(void); |
| 376 | 390 |
| 377 +/***************** platform client auth ****************/ | 391 +/***************** platform client auth ****************/ |
| 378 + | 392 + |
| 379 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 393 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
| 380 +// Releases the platform key. | 394 +// Releases the platform key. |
| 381 +extern void ssl_FreePlatformKey(PlatformKey key); | 395 +extern void ssl_FreePlatformKey(PlatformKey key); |
| 382 + | 396 + |
| 383 +// Implement the client CertificateVerify message for SSL3/TLS1.0 | 397 +// Implement the client CertificateVerify message for SSL3/TLS1.0 |
| 384 +extern SECStatus ssl3_PlatformSignHashes(SSL3Hashes *hash, | 398 +extern SECStatus ssl3_PlatformSignHashes(SSL3Hashes *hash, |
| 385 + PlatformKey key, SECItem *buf, | 399 + PlatformKey key, SECItem *buf, |
| 386 + PRBool isTLS, KeyType keyType); | 400 + PRBool isTLS, KeyType keyType); |
| 387 + | 401 + |
| 388 +// Converts a CERTCertList* (A collection of CERTCertificates) into a | 402 +// Converts a CERTCertList* (A collection of CERTCertificates) into a |
| 389 +// CERTCertificateList* (A collection of SECItems), or returns NULL if | 403 +// CERTCertificateList* (A collection of SECItems), or returns NULL if |
| 390 +// it cannot be converted. | 404 +// it cannot be converted. |
| 391 +// This is to allow the platform-supplied chain to be created with purely | 405 +// This is to allow the platform-supplied chain to be created with purely |
| 392 +// public API functions, using the preferred CERTCertList mutators, rather | 406 +// public API functions, using the preferred CERTCertList mutators, rather |
| 393 +// pushing this hack to clients. | 407 +// pushing this hack to clients. |
| 394 +extern CERTCertificateList* hack_NewCertificateListFromCertList( | 408 +extern CERTCertificateList* hack_NewCertificateListFromCertList( |
| 395 + CERTCertList* list); | 409 + CERTCertList* list); |
| 396 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 410 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
| 397 | 411 |
| 398 /**************** DTLS-specific functions **************/ | 412 /**************** DTLS-specific functions **************/ |
| 399 extern void dtls_FreeQueuedMessage(DTLSQueuedMessage *msg); | 413 extern void dtls_FreeQueuedMessage(DTLSQueuedMessage *msg); |
| 400 diff -pu a/nss/lib/ssl/sslsock.c b/nss/lib/ssl/sslsock.c | 414 diff -pu a/nss/lib/ssl/sslsock.c b/nss/lib/ssl/sslsock.c |
| 401 --- a/nss/lib/ssl/sslsock.c» 2013-07-31 12:28:39.283413269 -0700 | 415 --- a/nss/lib/ssl/sslsock.c» 2014-01-03 19:28:03.560814773 -0800 |
| 402 +++ b/nss/lib/ssl/sslsock.c» 2013-07-31 12:35:27.199373436 -0700 | 416 +++ b/nss/lib/ssl/sslsock.c» 2014-01-03 19:30:52.653579045 -0800 |
| 403 @@ -343,6 +343,10 @@ ssl_DupSocket(sslSocket *os) | 417 @@ -261,6 +261,10 @@ ssl_DupSocket(sslSocket *os) |
| 404 ss->authCertificateArg = os->authCertificateArg; | 418 ss->authCertificateArg = os->authCertificateArg; |
| 405 ss->getClientAuthData = os->getClientAuthData; | 419 ss->getClientAuthData = os->getClientAuthData; |
| 406 ss->getClientAuthDataArg = os->getClientAuthDataArg; | 420 ss->getClientAuthDataArg = os->getClientAuthDataArg; |
| 407 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 421 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
| 408 + ss->getPlatformClientAuthData = os->getPlatformClientAuthData; | 422 + ss->getPlatformClientAuthData = os->getPlatformClientAuthData; |
| 409 + ss->getPlatformClientAuthDataArg = os->getPlatformClientAuthDataArg; | 423 + ss->getPlatformClientAuthDataArg = os->getPlatformClientAuthDataArg; |
| 410 +#endif | 424 +#endif |
| 411 ss->sniSocketConfig = os->sniSocketConfig; | 425 ss->sniSocketConfig = os->sniSocketConfig; |
| 412 ss->sniSocketConfigArg = os->sniSocketConfigArg; | 426 ss->sniSocketConfigArg = os->sniSocketConfigArg; |
| 413 ss->handleBadCert = os->handleBadCert; | 427 ss->handleBadCert = os->handleBadCert; |
| 414 @@ -1730,6 +1734,12 @@ SSL_ReconfigFD(PRFileDesc *model, PRFile | 428 @@ -1645,6 +1649,12 @@ SSL_ReconfigFD(PRFileDesc *model, PRFile |
| 415 ss->getClientAuthData = sm->getClientAuthData; | 429 ss->getClientAuthData = sm->getClientAuthData; |
| 416 if (sm->getClientAuthDataArg) | 430 if (sm->getClientAuthDataArg) |
| 417 ss->getClientAuthDataArg = sm->getClientAuthDataArg; | 431 ss->getClientAuthDataArg = sm->getClientAuthDataArg; |
| 418 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 432 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
| 419 + if (sm->getPlatformClientAuthData) | 433 + if (sm->getPlatformClientAuthData) |
| 420 + ss->getPlatformClientAuthData = sm->getPlatformClientAuthData; | 434 + ss->getPlatformClientAuthData = sm->getPlatformClientAuthData; |
| 421 + if (sm->getPlatformClientAuthDataArg) | 435 + if (sm->getPlatformClientAuthDataArg) |
| 422 + ss->getPlatformClientAuthDataArg = sm->getPlatformClientAuthDataArg; | 436 + ss->getPlatformClientAuthDataArg = sm->getPlatformClientAuthDataArg; |
| 423 +#endif | 437 +#endif |
| 424 if (sm->sniSocketConfig) | 438 if (sm->sniSocketConfig) |
| 425 ss->sniSocketConfig = sm->sniSocketConfig; | 439 ss->sniSocketConfig = sm->sniSocketConfig; |
| 426 if (sm->sniSocketConfigArg) | 440 if (sm->sniSocketConfigArg) |
| 427 @@ -2980,6 +2990,10 @@ ssl_NewSocket(PRBool makeLocks, SSLProto | 441 @@ -2899,6 +2909,10 @@ ssl_NewSocket(PRBool makeLocks, SSLProto |
| 428 ss->sniSocketConfig = NULL; | 442 ss->sniSocketConfig = NULL; |
| 429 ss->sniSocketConfigArg = NULL; | 443 ss->sniSocketConfigArg = NULL; |
| 430 ss->getClientAuthData = NULL; | 444 ss->getClientAuthData = NULL; |
| 431 +#ifdef NSS_PLATFORM_CLIENT_AUTH | 445 +#ifdef NSS_PLATFORM_CLIENT_AUTH |
| 432 + ss->getPlatformClientAuthData = NULL; | 446 + ss->getPlatformClientAuthData = NULL; |
| 433 + ss->getPlatformClientAuthDataArg = NULL; | 447 + ss->getPlatformClientAuthDataArg = NULL; |
| 434 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ | 448 +#endif /* NSS_PLATFORM_CLIENT_AUTH */ |
| 435 ss->handleBadCert = NULL; | 449 ss->handleBadCert = NULL; |
| 436 ss->badCertArg = NULL; | 450 ss->badCertArg = NULL; |
| 437 ss->pkcs11PinArg = NULL; | 451 ss->pkcs11PinArg = NULL; |
| OLD | NEW |