Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(866)

Side by Side Diff: net/third_party/nss/patches/channelid.patch

Issue 10540014: nss: support SECWouldBlock from ChannelID callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/third_party/nss/ssl/ssl.h » ('j') | net/third_party/nss/ssl/ssl.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 diff --git a/net/third_party/nss/ssl/SSLerrs.h b/net/third_party/nss/ssl/SSLerrs .h 1 diff --git a/net/third_party/nss/ssl/SSLerrs.h b/net/third_party/nss/ssl/SSLerrs .h
2 index e3f9a1c..2d92514 100644 2 index e3f9a1c..2d92514 100644
3 --- a/net/third_party/nss/ssl/SSLerrs.h 3 --- a/net/third_party/nss/ssl/SSLerrs.h
4 +++ b/net/third_party/nss/ssl/SSLerrs.h 4 +++ b/net/third_party/nss/ssl/SSLerrs.h
5 @@ -429,3 +429,12 @@ ER3(SSL_ERROR_RX_MALFORMED_HELLO_VERIFY_REQUEST, (SSL_ERROR _BASE + 122), 5 @@ -429,3 +429,12 @@ ER3(SSL_ERROR_RX_MALFORMED_HELLO_VERIFY_REQUEST, (SSL_ERROR _BASE + 122),
6 6
7 ER3(SSL_ERROR_RX_UNEXPECTED_HELLO_VERIFY_REQUEST, (SSL_ERROR_BASE + 123), 7 ER3(SSL_ERROR_RX_UNEXPECTED_HELLO_VERIFY_REQUEST, (SSL_ERROR_BASE + 123),
8 "SSL received an unexpected Hello Verify Request handshake message.") 8 "SSL received an unexpected Hello Verify Request handshake message.")
9 + 9 +
10 +ER3(SSL_ERROR_BAD_CHANNEL_ID_DATA, (SSL_ERROR_BASE + 124), 10 +ER3(SSL_ERROR_BAD_CHANNEL_ID_DATA, (SSL_ERROR_BASE + 124),
11 +"SSL received a malformed TLS Channel ID extension.") 11 +"SSL received a malformed TLS Channel ID extension.")
12 + 12 +
13 +ER3(SSL_ERROR_INVALID_CHANNEL_ID_KEY, (SSL_ERROR_BASE + 125), 13 +ER3(SSL_ERROR_INVALID_CHANNEL_ID_KEY, (SSL_ERROR_BASE + 125),
14 +"The application provided an invalid TLS Channel ID key.") 14 +"The application provided an invalid TLS Channel ID key.")
15 + 15 +
16 +ER3(SSL_ERROR_GET_CHANNEL_ID_FAILED, (SSL_ERROR_BASE + 126), 16 +ER3(SSL_ERROR_GET_CHANNEL_ID_FAILED, (SSL_ERROR_BASE + 126),
17 +"The application could not get a TLS Channel ID.") 17 +"The application could not get a TLS Channel ID.")
18 diff --git a/net/third_party/nss/ssl/ssl.h b/net/third_party/nss/ssl/ssl.h 18 diff --git a/net/third_party/nss/ssl/ssl.h b/net/third_party/nss/ssl/ssl.h
19 index 1368e2f..3d8fdcb 100644 19 index 1368e2f..9aa307b 100644
20 --- a/net/third_party/nss/ssl/ssl.h 20 --- a/net/third_party/nss/ssl/ssl.h
21 +++ b/net/third_party/nss/ssl/ssl.h 21 +++ b/net/third_party/nss/ssl/ssl.h
22 @@ -945,6 +945,25 @@ SSL_IMPORT SECStatus SSL_HandshakeNegotiatedExtension(PRFil eDesc * socket, 22 @@ -945,6 +945,34 @@ SSL_IMPORT SECStatus SSL_HandshakeNegotiatedExtension(PRFil eDesc * socket,
23 SSL_IMPORT SECStatus SSL_HandshakeResumedSession(PRFileDesc *fd, 23 SSL_IMPORT SECStatus SSL_HandshakeResumedSession(PRFileDesc *fd,
24 PRBool *last_handshake_resumed ); 24 PRBool *last_handshake_resumed );
25 25
26 +/* See SSL_SetClientChannelIDCallback for usage. The callback must return 26 +/* See SSL_SetClientChannelIDCallback for usage. If the callback returns
27 + * SECFailure or SECSuccess (not SECWouldBlock). On SECSuccess, the callback 27 + * SECWouldBlock then SSL_RestartHandshakeAfterChannelIDReq should be called in
28 + * must have written a P-256, EC key pair to |*out_public_key| and 28 + * the future to restart the handshake. On SECSuccess, the callback must have
29 + * |*out_private_key|. */ 29 + * written a P-256, EC key pair to |*out_public_key| and |*out_private_key|. */
30 +typedef SECStatus (PR_CALLBACK *SSLClientChannelIDCallback)( 30 +typedef SECStatus (PR_CALLBACK *SSLClientChannelIDCallback)(
31 + void *arg, 31 + void *arg,
32 + PRFileDesc *fd, 32 + PRFileDesc *fd,
33 + SECKEYPublicKey **out_public_key, 33 + SECKEYPublicKey **out_public_key,
34 + SECKEYPrivateKey **out_private_key); 34 + SECKEYPrivateKey **out_private_key);
35 + 35 +
36 +/* SSL_RestartHandshakeAfterChannelIDReq attempts to restart the handshake
37 + * after a ChannelID callback returned SECWouldBlock.
38 + *
39 + * This function takes ownership of |channelIDPub| and |channelID|. */
40 +SSL_IMPORT SECStatus SSL_RestartHandshakeAfterChannelIDReq(
41 + PRFileDesc * fd,
42 + SECKEYPublicKey * channelIDPub,
43 + SECKEYPrivateKey *channelID);
44 +
36 +/* SSL_SetClientChannelIDCallback sets a callback function that will be called 45 +/* SSL_SetClientChannelIDCallback sets a callback function that will be called
37 + * just before a Channel ID is sent. This is only applicable to a client socket 46 + * once the server's ServerHello has been processed. This is only applicable to
38 + * and setting this callback causes the TLS Channel ID extension to be 47 + * a client socket and setting this callback causes the TLS Channel ID
39 + * advertised. */ 48 + * extension to be advertised. */
40 +SSL_IMPORT SECStatus SSL_SetClientChannelIDCallback( 49 +SSL_IMPORT SECStatus SSL_SetClientChannelIDCallback(
41 + PRFileDesc *fd, 50 + PRFileDesc *fd,
42 + SSLClientChannelIDCallback callback, 51 + SSLClientChannelIDCallback callback,
43 + void *arg); 52 + void *arg);
44 + 53 +
45 /* 54 /*
46 ** How long should we wait before retransmitting the next flight of 55 ** How long should we wait before retransmitting the next flight of
47 ** the DTLS handshake? Returns SECFailure if not DTLS or not in a 56 ** the DTLS handshake? Returns SECFailure if not DTLS or not in a
48 diff --git a/net/third_party/nss/ssl/ssl3con.c b/net/third_party/nss/ssl/ssl3con .c 57 diff --git a/net/third_party/nss/ssl/ssl3con.c b/net/third_party/nss/ssl/ssl3con .c
49 index db9fad3..f714a98 100644 58 index db9fad3..2505d65 100644
50 --- a/net/third_party/nss/ssl/ssl3con.c 59 --- a/net/third_party/nss/ssl/ssl3con.c
51 +++ b/net/third_party/nss/ssl/ssl3con.c 60 +++ b/net/third_party/nss/ssl/ssl3con.c
52 @@ -86,6 +86,7 @@ static SECStatus ssl3_SendCertificate( sslSocket *ss); 61 @@ -86,6 +86,7 @@ static SECStatus ssl3_SendCertificate( sslSocket *ss);
53 static SECStatus ssl3_SendEmptyCertificate( sslSocket *ss); 62 static SECStatus ssl3_SendEmptyCertificate( sslSocket *ss);
54 static SECStatus ssl3_SendCertificateRequest(sslSocket *ss); 63 static SECStatus ssl3_SendCertificateRequest(sslSocket *ss);
55 static SECStatus ssl3_SendNextProto( sslSocket *ss); 64 static SECStatus ssl3_SendNextProto( sslSocket *ss);
56 +static SECStatus ssl3_SendEncryptedExtensions(sslSocket *ss); 65 +static SECStatus ssl3_SendEncryptedExtensions(sslSocket *ss);
57 static SECStatus ssl3_SendFinished( sslSocket *ss, PRInt32 flags); 66 static SECStatus ssl3_SendFinished( sslSocket *ss, PRInt32 flags);
58 static SECStatus ssl3_SendServerHello( sslSocket *ss); 67 static SECStatus ssl3_SendServerHello( sslSocket *ss);
59 static SECStatus ssl3_SendServerHelloDone( sslSocket *ss); 68 static SECStatus ssl3_SendServerHelloDone( sslSocket *ss);
60 @@ -6239,6 +6240,10 @@ ssl3_SendClientSecondRound(sslSocket *ss) 69 @@ -5200,6 +5201,15 @@ ssl3_HandleServerHello(sslSocket *ss, SSL3Opaque *b, PRUi nt32 length)
70 }
71 #endif /* NSS_PLATFORM_CLIENT_AUTH */
72
73 + if (ss->ssl3.channelID != NULL) {
74 +» SECKEY_DestroyPrivateKey(ss->ssl3.channelID);
75 +» ss->ssl3.channelID = NULL;
76 + }
77 + if (ss->ssl3.channelIDPub != NULL) {
78 +» SECKEY_DestroyPublicKey(ss->ssl3.channelIDPub);
79 +» ss->ssl3.channelIDPub = NULL;
80 + }
81 +
82 temp = ssl3_ConsumeHandshakeNumber(ss, 2, &b, &length);
83 if (temp < 0) {
84 » goto loser; » /* alert has been sent */
85 @@ -5452,13 +5462,12 @@ ssl3_HandleServerHello(sslSocket *ss, SSL3Opaque *b, PRU int32 length)
86 » ssl3_CopyPeerCertsFromSID(ss, sid);
87 » }
88
89 -
90 » /* NULL value for PMS signifies re-use of the old MS */
91 » rv = ssl3_InitPendingCipherSpec(ss, NULL);
92 » if (rv != SECSuccess) {
93 » goto alert_loser;» /* err code was set */
94 » }
95 -» return SECSuccess;
96 +» goto winner;
97 } while (0);
98
99 if (sid_match)
100 @@ -5483,6 +5492,25 @@ ssl3_HandleServerHello(sslSocket *ss, SSL3Opaque *b, PRUi nt32 length)
101
102 ss->ssl3.hs.isResuming = PR_FALSE;
103 ss->ssl3.hs.ws = wait_server_cert;
104 +
105 +winner:
106 + /* If we will need a ChannelID key then we make the callback now. This
107 + * allows the handshake to be restarted cleanly if the callback returns
108 + * SECWouldBlock. */
109 + if (ss->getChannelID &&
110 +» ssl3_ExtensionNegotiated(ss, ssl_channel_id_xtn)) {
111 +» rv = ss->getChannelID(ss->getChannelIDArg, ss->fd,
112 +» » » &ss->ssl3.channelIDPub, &ss->ssl3.channelID);
113 +» if (rv == SECWouldBlock) {
114 +» ssl3_SetAlwaysBlock(ss);
115 +» return rv;
116 +» }
117 +» if (rv != SECSuccess) {
118 +» PORT_SetError(SSL_ERROR_GET_CHANNEL_ID_FAILED);
119 +» goto loser;
120 +» }
121 + }
122 +
123 return SECSuccess;
124
125 alert_loser:
126 @@ -6239,6 +6267,10 @@ ssl3_SendClientSecondRound(sslSocket *ss)
61 goto loser; /* err code was set. */ 127 goto loser; /* err code was set. */
62 } 128 }
63 } 129 }
64 + rv = ssl3_SendEncryptedExtensions(ss); 130 + rv = ssl3_SendEncryptedExtensions(ss);
65 + if (rv != SECSuccess) { 131 + if (rv != SECSuccess) {
66 + goto loser; /* err code was set. */ 132 + goto loser; /* err code was set. */
67 + } 133 + }
68 134
69 rv = ssl3_SendFinished(ss, 0); 135 rv = ssl3_SendFinished(ss, 0);
70 if (rv != SECSuccess) { 136 if (rv != SECSuccess) {
71 @@ -8855,6 +8860,130 @@ ssl3_SendNextProto(sslSocket *ss) 137 @@ -8855,6 +8887,154 @@ ssl3_SendNextProto(sslSocket *ss)
72 return rv; 138 return rv;
73 } 139 }
74 140
75 +/* called from ssl3_SendClientSecondRound 141 +/* called from ssl3_SendClientSecondRound
76 + * ssl3_HandleFinished 142 + * ssl3_HandleFinished
77 + */ 143 + */
78 +static SECStatus 144 +static SECStatus
79 +ssl3_SendEncryptedExtensions(sslSocket *ss) 145 +ssl3_SendEncryptedExtensions(sslSocket *ss)
80 +{ 146 +{
81 + static const char CHANNEL_ID_MAGIC[] = "TLS Channel ID signature"; 147 + static const char CHANNEL_ID_MAGIC[] = "TLS Channel ID signature";
(...skipping 20 matching lines...) Expand all
102 + 168 +
103 + SECStatus rv = SECFailure; 169 + SECStatus rv = SECFailure;
104 + SECItem *spki = NULL; 170 + SECItem *spki = NULL;
105 + SSL3Hashes hashes; 171 + SSL3Hashes hashes;
106 + const unsigned char *pub_bytes; 172 + const unsigned char *pub_bytes;
107 + unsigned char signed_data[sizeof(CHANNEL_ID_MAGIC) + sizeof(SSL3Hashes)]; 173 + unsigned char signed_data[sizeof(CHANNEL_ID_MAGIC) + sizeof(SSL3Hashes)];
108 + unsigned char digest[SHA256_LENGTH]; 174 + unsigned char digest[SHA256_LENGTH];
109 + SECItem digest_item; 175 + SECItem digest_item;
110 + unsigned char signature[64]; 176 + unsigned char signature[64];
111 + SECItem signature_item; 177 + SECItem signature_item;
112 + SECKEYPrivateKey *channelID = NULL;
113 + SECKEYPublicKey *channelIDPub = NULL;
114 + 178 +
115 + PORT_Assert(ss->opt.noLocks || ssl_HaveXmitBufLock(ss)); 179 + PORT_Assert(ss->opt.noLocks || ssl_HaveXmitBufLock(ss));
116 + PORT_Assert(ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss)); 180 + PORT_Assert(ss->opt.noLocks || ssl_HaveSSL3HandshakeLock(ss));
117 + 181 +
118 + if (ss->getChannelID == NULL || 182 + if (ss->ssl3.channelID == NULL)
119 +» !ssl3_ExtensionNegotiated(ss, ssl_channel_id_xtn)) {
120 + return SECSuccess; 183 + return SECSuccess;
121 + }
122 + 184 +
123 + rv = ss->getChannelID(ss->getChannelIDArg, ss->fd, 185 + PORT_Assert(ssl3_ExtensionNegotiated(ss, ssl_channel_id_xtn));
124 +» » » &channelIDPub, &channelID);
125 + if (rv != SECSuccess) {
126 +» PORT_SetError(SSL_ERROR_GET_CHANNEL_ID_FAILED);
127 +» goto loser;
128 + }
129 + 186 +
130 + if (SECKEY_GetPrivateKeyType(channelID) != ecKey || 187 + if (SECKEY_GetPrivateKeyType(ss->ssl3.channelID) != ecKey ||
131 +» PK11_SignatureLen(channelID) != sizeof(signature)) { 188 +» PK11_SignatureLen(ss->ssl3.channelID) != sizeof(signature)) {
132 + PORT_SetError(SSL_ERROR_INVALID_CHANNEL_ID_KEY); 189 + PORT_SetError(SSL_ERROR_INVALID_CHANNEL_ID_KEY);
133 + rv = SECFailure; 190 + rv = SECFailure;
134 + goto loser; 191 + goto loser;
135 + } 192 + }
136 + 193 +
137 + ssl_GetSpecReadLock(ss); 194 + ssl_GetSpecReadLock(ss);
138 + rv = ssl3_ComputeHandshakeHashes(ss, ss->ssl3.cwSpec, &hashes, 0); 195 + rv = ssl3_ComputeHandshakeHashes(ss, ss->ssl3.cwSpec, &hashes, 0);
139 + ssl_ReleaseSpecReadLock(ss); 196 + ssl_ReleaseSpecReadLock(ss);
140 + 197 +
141 + if (rv != SECSuccess) 198 + if (rv != SECSuccess)
142 + goto loser; 199 + goto loser;
143 + 200 +
144 + rv = ssl3_AppendHandshakeHeader(ss, encrypted_extensions, 201 + rv = ssl3_AppendHandshakeHeader(ss, encrypted_extensions,
145 + 2 + 2 + CHANNEL_ID_LENGTH); 202 + 2 + 2 + CHANNEL_ID_LENGTH);
146 + if (rv != SECSuccess) 203 + if (rv != SECSuccess)
147 + goto loser; /* error code set by AppendHandshakeHeader */ 204 + goto loser; /* error code set by AppendHandshakeHeader */
148 + rv = ssl3_AppendHandshakeNumber(ss, ssl_channel_id_xtn, 2); 205 + rv = ssl3_AppendHandshakeNumber(ss, ssl_channel_id_xtn, 2);
149 + if (rv != SECSuccess) 206 + if (rv != SECSuccess)
150 + goto loser; /* error code set by AppendHandshake */ 207 + goto loser; /* error code set by AppendHandshake */
151 + rv = ssl3_AppendHandshakeNumber(ss, CHANNEL_ID_LENGTH, 2); 208 + rv = ssl3_AppendHandshakeNumber(ss, CHANNEL_ID_LENGTH, 2);
152 + if (rv != SECSuccess) 209 + if (rv != SECSuccess)
153 + goto loser; /* error code set by AppendHandshake */ 210 + goto loser; /* error code set by AppendHandshake */
154 + 211 +
155 + spki = SECKEY_EncodeDERSubjectPublicKeyInfo(channelIDPub); 212 + spki = SECKEY_EncodeDERSubjectPublicKeyInfo(ss->ssl3.channelIDPub);
156 + 213 +
157 + if (spki->len != sizeof(P256_SPKI_PREFIX) + CHANNEL_ID_PUBLIC_KEY_LENGTH || 214 + if (spki->len != sizeof(P256_SPKI_PREFIX) + CHANNEL_ID_PUBLIC_KEY_LENGTH ||
158 + memcmp(spki->data, P256_SPKI_PREFIX, sizeof(P256_SPKI_PREFIX) != 0)) { 215 + memcmp(spki->data, P256_SPKI_PREFIX, sizeof(P256_SPKI_PREFIX) != 0)) {
159 + PORT_SetError(SSL_ERROR_INVALID_CHANNEL_ID_KEY); 216 + PORT_SetError(SSL_ERROR_INVALID_CHANNEL_ID_KEY);
160 + rv = SECFailure; 217 + rv = SECFailure;
161 + goto loser; 218 + goto loser;
162 + } 219 + }
163 + 220 +
164 + pub_bytes = spki->data + sizeof(P256_SPKI_PREFIX); 221 + pub_bytes = spki->data + sizeof(P256_SPKI_PREFIX);
165 + 222 +
166 + memcpy(signed_data, CHANNEL_ID_MAGIC, sizeof(CHANNEL_ID_MAGIC)); 223 + memcpy(signed_data, CHANNEL_ID_MAGIC, sizeof(CHANNEL_ID_MAGIC));
167 + memcpy(signed_data + sizeof(CHANNEL_ID_MAGIC), &hashes, sizeof(hashes)); 224 + memcpy(signed_data + sizeof(CHANNEL_ID_MAGIC), &hashes, sizeof(hashes));
168 + 225 +
169 + rv = PK11_HashBuf(SEC_OID_SHA256, digest, signed_data, sizeof(signed_data)) ; 226 + rv = PK11_HashBuf(SEC_OID_SHA256, digest, signed_data, sizeof(signed_data)) ;
170 + if (rv != SECSuccess) 227 + if (rv != SECSuccess)
171 + goto loser; 228 + goto loser;
172 + 229 +
173 + digest_item.data = digest; 230 + digest_item.data = digest;
174 + digest_item.len = sizeof(digest); 231 + digest_item.len = sizeof(digest);
175 + 232 +
176 + signature_item.data = signature; 233 + signature_item.data = signature;
177 + signature_item.len = sizeof(signature); 234 + signature_item.len = sizeof(signature);
178 + 235 +
179 + rv = PK11_Sign(channelID, &signature_item, &digest_item); 236 + rv = PK11_Sign(ss->ssl3.channelID, &signature_item, &digest_item);
180 + if (rv != SECSuccess) 237 + if (rv != SECSuccess)
181 + goto loser; 238 + goto loser;
182 + 239 +
183 + rv = ssl3_AppendHandshake(ss, pub_bytes, CHANNEL_ID_PUBLIC_KEY_LENGTH); 240 + rv = ssl3_AppendHandshake(ss, pub_bytes, CHANNEL_ID_PUBLIC_KEY_LENGTH);
184 + if (rv != SECSuccess) 241 + if (rv != SECSuccess)
185 + goto loser; 242 + goto loser;
186 + rv = ssl3_AppendHandshake(ss, signature, sizeof(signature)); 243 + rv = ssl3_AppendHandshake(ss, signature, sizeof(signature));
187 + 244 +
188 +loser: 245 +loser:
189 + if (spki) 246 + if (spki)
190 + SECITEM_FreeItem(spki, PR_TRUE); 247 + SECITEM_FreeItem(spki, PR_TRUE);
191 + if (channelID) 248 + if (ss->ssl3.channelID) {
192 +» SECKEY_DestroyPrivateKey(channelID); 249 +» SECKEY_DestroyPrivateKey(ss->ssl3.channelID);
193 + if (channelIDPub) 250 +» ss->ssl3.channelID = NULL;
194 +» SECKEY_DestroyPublicKey(channelIDPub); 251 + }
252 + if (ss->ssl3.channelIDPub) {
253 +» SECKEY_DestroyPublicKey(ss->ssl3.channelIDPub);
254 +» ss->ssl3.channelIDPub = NULL;
255 + }
195 + 256 +
196 + return rv; 257 + return rv;
197 +} 258 +}
198 + 259 +
260 +/* ssl3_RestartHandshakeAfterChannelIDReq is called to restart a handshake
261 + * after a ChannelID callback returned SECWouldBlock. At this point we have
262 + * processed the server's ServerHello but not yet any further messages. We will
263 + * always get a message from the server after a ServerHello so either they are
264 + * waiting in the buffer or we'll get network I/O. */
265 +SECStatus
266 +ssl3_RestartHandshakeAfterChannelIDReq(sslSocket *ss,
267 + SECKEYPublicKey *channelIDPub,
268 + SECKEYPrivateKey *channelID)
269 +{
270 + if (ss->handshake == 0) {
271 + SECKEY_DestroyPublicKey(channelIDPub);
272 + SECKEY_DestroyPrivateKey(channelID);
273 + PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
274 + return SECFailure;
275 + }
276 +
277 + if (ss->ssl3.channelID)
278 + SECKEY_DestroyPrivateKey(ss->ssl3.channelID);
279 + if (ss->ssl3.channelIDPub)
280 + SECKEY_DestroyPublicKey(ss->ssl3.channelIDPub);
281 +
282 + ss->handshake = ssl_GatherRecord1stHandshake;
283 + ss->ssl3.channelID = channelID;
284 + ss->ssl3.channelIDPub = channelIDPub;
285 +
286 + return SECSuccess;
287 +}
288 +
199 /* called from ssl3_HandleServerHelloDone 289 /* called from ssl3_HandleServerHelloDone
200 * ssl3_HandleClientHello 290 * ssl3_HandleClientHello
201 * ssl3_HandleFinished 291 * ssl3_HandleFinished
202 @@ -9105,11 +9234,16 @@ ssl3_HandleFinished(sslSocket *ss, SSL3Opaque *b, PRUint 32 length, 292 @@ -9105,11 +9285,16 @@ ssl3_HandleFinished(sslSocket *ss, SSL3Opaque *b, PRUint 32 length,
203 flags = ssl_SEND_FLAG_FORCE_INTO_BUFFER; 293 flags = ssl_SEND_FLAG_FORCE_INTO_BUFFER;
204 } 294 }
205 295
206 - if (!isServer && !ss->firstHsDone) { 296 - if (!isServer && !ss->firstHsDone) {
207 - rv = ssl3_SendNextProto(ss); 297 - rv = ssl3_SendNextProto(ss);
208 - if (rv != SECSuccess) { 298 - if (rv != SECSuccess) {
209 - goto xmit_loser; /* err code was set. */ 299 - goto xmit_loser; /* err code was set. */
210 + if (!isServer) { 300 + if (!isServer) {
211 + if (!ss->firstHsDone) { 301 + if (!ss->firstHsDone) {
212 + rv = ssl3_SendNextProto(ss); 302 + rv = ssl3_SendNextProto(ss);
213 + if (rv != SECSuccess) { 303 + if (rv != SECSuccess) {
214 + goto xmit_loser; /* err code was set. */ 304 + goto xmit_loser; /* err code was set. */
215 + } 305 + }
216 } 306 }
217 + rv = ssl3_SendEncryptedExtensions(ss); 307 + rv = ssl3_SendEncryptedExtensions(ss);
218 + if (rv != SECSuccess) 308 + if (rv != SECSuccess)
219 + goto xmit_loser; /* err code was set. */ 309 + goto xmit_loser; /* err code was set. */
220 } 310 }
221 311
222 if (IS_DTLS(ss)) { 312 if (IS_DTLS(ss)) {
313 @@ -10376,6 +10561,11 @@ ssl3_DestroySSL3Info(sslSocket *ss)
314 ssl_FreePlatformKey(ss->ssl3.platformClientKey);
315 #endif /* NSS_PLATFORM_CLIENT_AUTH */
316
317 + if (ss->ssl3.channelID)
318 + SECKEY_DestroyPrivateKey(ss->ssl3.channelID);
319 + if (ss->ssl3.channelIDPub)
320 + SECKEY_DestroyPublicKey(ss->ssl3.channelIDPub);
321 +
322 if (ss->ssl3.peerCertArena != NULL)
323 ssl3_CleanupPeerCerts(ss);
324
223 diff --git a/net/third_party/nss/ssl/ssl3ext.c b/net/third_party/nss/ssl/ssl3ext .c 325 diff --git a/net/third_party/nss/ssl/ssl3ext.c b/net/third_party/nss/ssl/ssl3ext .c
224 index b9fd6e7..029487e 100644 326 index b9fd6e7..029487e 100644
225 --- a/net/third_party/nss/ssl/ssl3ext.c 327 --- a/net/third_party/nss/ssl/ssl3ext.c
226 +++ b/net/third_party/nss/ssl/ssl3ext.c 328 +++ b/net/third_party/nss/ssl/ssl3ext.c
227 @@ -80,10 +80,14 @@ static SECStatus ssl3_HandleRenegotiationInfoXtn(sslSocket * ss, 329 @@ -80,10 +80,14 @@ static SECStatus ssl3_HandleRenegotiationInfoXtn(sslSocket * ss,
228 PRUint16 ex_type, SECItem *data); 330 PRUint16 ex_type, SECItem *data);
229 static SECStatus ssl3_ClientHandleNextProtoNegoXtn(sslSocket *ss, 331 static SECStatus ssl3_ClientHandleNextProtoNegoXtn(sslSocket *ss,
230 PRUint16 ex_type, SECItem *data); 332 PRUint16 ex_type, SECItem *data);
231 +static SECStatus ssl3_ClientHandleChannelIDXtn(sslSocket *ss, 333 +static SECStatus ssl3_ClientHandleChannelIDXtn(sslSocket *ss,
232 + PRUint16 ex_type, SECItem *data); 334 + PRUint16 ex_type, SECItem *data);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 SSL_ERROR_RX_UNEXPECTED_HELLO_VERIFY_REQUEST = (SSL_ERROR_BASE + 123), 462 SSL_ERROR_RX_UNEXPECTED_HELLO_VERIFY_REQUEST = (SSL_ERROR_BASE + 123),
361 463
362 +SSL_ERROR_BAD_CHANNEL_ID_DATA = (SSL_ERROR_BASE + 124), 464 +SSL_ERROR_BAD_CHANNEL_ID_DATA = (SSL_ERROR_BASE + 124),
363 +SSL_ERROR_INVALID_CHANNEL_ID_KEY = (SSL_ERROR_BASE + 125), 465 +SSL_ERROR_INVALID_CHANNEL_ID_KEY = (SSL_ERROR_BASE + 125),
364 +SSL_ERROR_GET_CHANNEL_ID_FAILED = (SSL_ERROR_BASE + 126), 466 +SSL_ERROR_GET_CHANNEL_ID_FAILED = (SSL_ERROR_BASE + 126),
365 + 467 +
366 SSL_ERROR_END_OF_LIST /* let the c compiler determine the value of this. */ 468 SSL_ERROR_END_OF_LIST /* let the c compiler determine the value of this. */
367 } SSLErrorCodes; 469 } SSLErrorCodes;
368 #endif /* NO_SECURITY_ERROR_ENUM */ 470 #endif /* NO_SECURITY_ERROR_ENUM */
369 diff --git a/net/third_party/nss/ssl/sslimpl.h b/net/third_party/nss/ssl/sslimpl .h 471 diff --git a/net/third_party/nss/ssl/sslimpl.h b/net/third_party/nss/ssl/sslimpl .h
370 index 8ab865a..7cd2298 100644 472 index 8ab865a..dd3d90b 100644
371 --- a/net/third_party/nss/ssl/sslimpl.h 473 --- a/net/third_party/nss/ssl/sslimpl.h
372 +++ b/net/third_party/nss/ssl/sslimpl.h 474 +++ b/net/third_party/nss/ssl/sslimpl.h
373 @@ -1198,6 +1198,8 @@ const unsigned char * preferredCipher; 475 @@ -930,6 +930,9 @@ struct ssl3StateStr {
476 CERTCertificateList *clientCertChain; /* used by client */
477 PRBool sendEmptyCert; /* used by client */
478
479 + SECKEYPrivateKey *channelID; /* used by client */
480 + SECKEYPublicKey *channelIDPub; /* used by client */
481 +
482 int policy;
483 » » » /* This says what cipher suites we can do, and should
484 » » » * be either SSL_ALLOWED or SSL_RESTRICTED
485 @@ -1198,6 +1201,8 @@ const unsigned char * preferredCipher;
374 void *pkcs11PinArg; 486 void *pkcs11PinArg;
375 SSLNextProtoCallback nextProtoCallback; 487 SSLNextProtoCallback nextProtoCallback;
376 void *nextProtoArg; 488 void *nextProtoArg;
377 + SSLClientChannelIDCallback getChannelID; 489 + SSLClientChannelIDCallback getChannelID;
378 + void *getChannelIDArg; 490 + void *getChannelIDArg;
379 491
380 PRIntervalTime rTimeout; /* timeout for NSPR I/O */ 492 PRIntervalTime rTimeout; /* timeout for NSPR I/O */
381 PRIntervalTime wTimeout; /* timeout for NSPR I/O */ 493 PRIntervalTime wTimeout; /* timeout for NSPR I/O */
494 diff --git a/net/third_party/nss/ssl/sslsecur.c b/net/third_party/nss/ssl/sslsec ur.c
495 index e4804d0..cc8588b 100644
496 --- a/net/third_party/nss/ssl/sslsecur.c
497 +++ b/net/third_party/nss/ssl/sslsecur.c
498 @@ -1535,6 +1535,39 @@ SSL_RestartHandshakeAfterCertReq(PRFileDesc * fd,
499 return ret;
500 }
501
502 +SECStatus
503 +SSL_RestartHandshakeAfterChannelIDReq(PRFileDesc * fd,
504 + SECKEYPublicKey * channelIDPub,
505 + SECKEYPrivateKey *channelID)
506 +{
507 + sslSocket * ss = ssl_FindSocket(fd);
508 + SECStatus ret;
509 +
510 + if (!ss) {
511 + SSL_DBG(("%d: SSL[%d]: bad socket in"
512 + " SSL_RestartHandshakeAfterChannelIDReq",
513 + SSL_GETPID(), fd));
514 + goto loser;
515 + }
516 +
517 + if (ss->version < SSL_LIBRARY_VERSION_3_0) {
518 + PORT_SetError(SSL_ERROR_FEATURE_NOT_SUPPORTED_FOR_SSL2);
519 + goto loser;
520 + }
521 +
522 + ssl_Get1stHandshakeLock(ss);
523 + ret = ssl3_RestartHandshakeAfterChannelIDReq(ss, channelIDPub,
524 + channelID);
525 + ssl_Release1stHandshakeLock(ss);
526 +
527 + return ret;
528 +
529 +loser:
530 + SECKEY_DestroyPublicKey(channelIDPub);
531 + SECKEY_DestroyPrivateKey(channelID);
532 + return SECFailure;
533 +}
534 +
535 /* DO NOT USE. This function was exported in ssl.def with the wrong signature;
536 * this implementation exists to maintain link-time compatibility.
537 */
382 diff --git a/net/third_party/nss/ssl/sslsock.c b/net/third_party/nss/ssl/sslsock .c 538 diff --git a/net/third_party/nss/ssl/sslsock.c b/net/third_party/nss/ssl/sslsock .c
383 index ebc245a..9498828 100644 539 index ebc245a..9498828 100644
384 --- a/net/third_party/nss/ssl/sslsock.c 540 --- a/net/third_party/nss/ssl/sslsock.c
385 +++ b/net/third_party/nss/ssl/sslsock.c 541 +++ b/net/third_party/nss/ssl/sslsock.c
386 @@ -374,6 +374,8 @@ ssl_DupSocket(sslSocket *os) 542 @@ -374,6 +374,8 @@ ssl_DupSocket(sslSocket *os)
387 ss->handshakeCallback = os->handshakeCallback; 543 ss->handshakeCallback = os->handshakeCallback;
388 ss->handshakeCallbackData = os->handshakeCallbackData; 544 ss->handshakeCallbackData = os->handshakeCallbackData;
389 ss->pkcs11PinArg = os->pkcs11PinArg; 545 ss->pkcs11PinArg = os->pkcs11PinArg;
390 + ss->getChannelID = os->getChannelID; 546 + ss->getChannelID = os->getChannelID;
391 + ss->getChannelIDArg = os->getChannelIDArg; 547 + ss->getChannelIDArg = os->getChannelIDArg;
(...skipping 29 matching lines...) Expand all
421 ssl_session_ticket_xtn = 35, 577 ssl_session_ticket_xtn = 35,
422 ssl_next_proto_nego_xtn = 13172, 578 ssl_next_proto_nego_xtn = 13172,
423 + ssl_channel_id_xtn = 30031, 579 + ssl_channel_id_xtn = 30031,
424 ssl_renegotiation_info_xtn = 0xff01 /* experimental number */ 580 ssl_renegotiation_info_xtn = 0xff01 /* experimental number */
425 } SSLExtensionType; 581 } SSLExtensionType;
426 582
427 -#define SSL_MAX_EXTENSIONS 7 583 -#define SSL_MAX_EXTENSIONS 7
428 +#define SSL_MAX_EXTENSIONS 8 584 +#define SSL_MAX_EXTENSIONS 8
429 585
430 #endif /* __sslt_h_ */ 586 #endif /* __sslt_h_ */
OLDNEW
« no previous file with comments | « no previous file | net/third_party/nss/ssl/ssl.h » ('j') | net/third_party/nss/ssl/ssl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698