OLD | NEW |
---|---|
1 /* | 1 /* |
2 * SSL3 Protocol | 2 * SSL3 Protocol |
3 * | 3 * |
4 * This Source Code Form is subject to the terms of the Mozilla Public | 4 * This Source Code Form is subject to the terms of the Mozilla Public |
5 * License, v. 2.0. If a copy of the MPL was not distributed with this | 5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
7 | 7 |
8 /* TLS extension code moved here from ssl3ecc.c */ | 8 /* TLS extension code moved here from ssl3ecc.c */ |
9 | 9 |
10 #include "nssrenam.h" | 10 #include "nssrenam.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 PRBool append, PRUint32 maxBytes); | 50 PRBool append, PRUint32 maxBytes); |
51 static SECStatus ssl3_HandleRenegotiationInfoXtn(sslSocket *ss, | 51 static SECStatus ssl3_HandleRenegotiationInfoXtn(sslSocket *ss, |
52 PRUint16 ex_type, SECItem *data); | 52 PRUint16 ex_type, SECItem *data); |
53 static SECStatus ssl3_ClientHandleNextProtoNegoXtn(sslSocket *ss, | 53 static SECStatus ssl3_ClientHandleNextProtoNegoXtn(sslSocket *ss, |
54 PRUint16 ex_type, SECItem *data); | 54 PRUint16 ex_type, SECItem *data); |
55 static SECStatus ssl3_ClientHandleAppProtoXtn(sslSocket *ss, | 55 static SECStatus ssl3_ClientHandleAppProtoXtn(sslSocket *ss, |
56 PRUint16 ex_type, SECItem *data); | 56 PRUint16 ex_type, SECItem *data); |
57 static SECStatus ssl3_ServerHandleNextProtoNegoXtn(sslSocket *ss, | 57 static SECStatus ssl3_ServerHandleNextProtoNegoXtn(sslSocket *ss, |
58 PRUint16 ex_type, SECItem *data); | 58 PRUint16 ex_type, SECItem *data); |
59 static PRInt32 ssl3_ClientSendAppProtoXtn(sslSocket *ss, PRBool append, | 59 static PRInt32 ssl3_ClientSendAppProtoXtn(sslSocket *ss, PRBool append, |
60 » » » » » PRUint32 maxBytes); | 60 » » » » » PRUint32 maxBytes); |
61 static PRInt32 ssl3_ClientSendNextProtoNegoXtn(sslSocket *ss, PRBool append, | 61 static PRInt32 ssl3_ClientSendNextProtoNegoXtn(sslSocket *ss, PRBool append, |
62 PRUint32 maxBytes); | 62 PRUint32 maxBytes); |
63 static PRInt32 ssl3_SendUseSRTPXtn(sslSocket *ss, PRBool append, | 63 static PRInt32 ssl3_SendUseSRTPXtn(sslSocket *ss, PRBool append, |
64 PRUint32 maxBytes); | 64 PRUint32 maxBytes); |
65 static SECStatus ssl3_HandleUseSRTPXtn(sslSocket * ss, PRUint16 ex_type, | 65 static SECStatus ssl3_HandleUseSRTPXtn(sslSocket * ss, PRUint16 ex_type, |
66 SECItem *data); | 66 SECItem *data); |
67 static SECStatus ssl3_ClientHandleChannelIDXtn(sslSocket *ss, | 67 static SECStatus ssl3_ClientHandleChannelIDXtn(sslSocket *ss, |
68 PRUint16 ex_type, SECItem *data); | 68 PRUint16 ex_type, SECItem *data); |
69 static PRInt32 ssl3_ClientSendChannelIDXtn(sslSocket *ss, PRBool append, | 69 static PRInt32 ssl3_ClientSendChannelIDXtn(sslSocket *ss, PRBool append, |
70 PRUint32 maxBytes); | 70 PRUint32 maxBytes); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 }; | 276 }; |
277 | 277 |
278 /* Tables of functions to format TLS hello extensions, one function per | 278 /* Tables of functions to format TLS hello extensions, one function per |
279 * extension. | 279 * extension. |
280 * These static tables are for the formatting of client hello extensions. | 280 * These static tables are for the formatting of client hello extensions. |
281 * The server's table of hello senders is dynamic, in the socket struct, | 281 * The server's table of hello senders is dynamic, in the socket struct, |
282 * and sender functions are registered there. | 282 * and sender functions are registered there. |
283 */ | 283 */ |
284 static const | 284 static const |
285 ssl3HelloExtensionSender clientHelloSendersTLS[SSL_MAX_EXTENSIONS] = { | 285 ssl3HelloExtensionSender clientHelloSendersTLS[SSL_MAX_EXTENSIONS] = { |
286 { ssl_server_name_xtn, &ssl3_SendServerNameXtn }, | 286 { ssl_server_name_xtn, &ssl3_SendServerNameXtn }, |
287 { ssl_renegotiation_info_xtn, &ssl3_SendRenegotiationInfoXtn }, | 287 { ssl_renegotiation_info_xtn, &ssl3_SendRenegotiationInfoXtn }, |
288 #ifdef NSS_ENABLE_ECC | 288 #ifdef NSS_ENABLE_ECC |
289 { ssl_elliptic_curves_xtn, &ssl3_SendSupportedCurvesXtn }, | 289 { ssl_elliptic_curves_xtn, &ssl3_SendSupportedCurvesXtn }, |
290 { ssl_ec_point_formats_xtn, &ssl3_SendSupportedPointFormatsXtn }, | 290 { ssl_ec_point_formats_xtn, &ssl3_SendSupportedPointFormatsXtn }, |
291 #endif | 291 #endif |
292 { ssl_session_ticket_xtn, &ssl3_SendSessionTicketXtn }, | 292 { ssl_session_ticket_xtn, &ssl3_SendSessionTicketXtn }, |
293 { ssl_next_proto_nego_xtn, &ssl3_ClientSendNextProtoNegoXtn }, | 293 { ssl_next_proto_nego_xtn, &ssl3_ClientSendNextProtoNegoXtn }, |
294 { ssl_app_layer_protocol_xtn, &ssl3_ClientSendAppProtoXtn }, | 294 { ssl_app_layer_protocol_xtn, &ssl3_ClientSendAppProtoXtn }, |
295 { ssl_use_srtp_xtn, &ssl3_SendUseSRTPXtn }, | 295 { ssl_use_srtp_xtn, &ssl3_SendUseSRTPXtn }, |
296 { ssl_channel_id_xtn, &ssl3_ClientSendChannelIDXtn }, | 296 { ssl_channel_id_xtn, &ssl3_ClientSendChannelIDXtn }, |
297 { ssl_cert_status_xtn, &ssl3_ClientSendStatusRequestXtn }, | 297 { ssl_cert_status_xtn, &ssl3_ClientSendStatusRequestXtn }, |
298 { ssl_signature_algorithms_xtn, &ssl3_ClientSendSigAlgsXtn }, | 298 { ssl_signature_algorithms_xtn, &ssl3_ClientSendSigAlgsXtn }, |
299 { ssl_signed_certificate_timestamp_xtn, | 299 { ssl_signed_certificate_timestamp_xtn, |
300 &ssl3_ClientSendSignedCertTimestampXtn } | 300 &ssl3_ClientSendSignedCertTimestampXtn } |
301 /* any extra entries will appear as { 0, NULL } */ | 301 /* any extra entries will appear as { 0, NULL } */ |
302 }; | 302 }; |
303 | 303 |
304 static const | 304 static const |
305 ssl3HelloExtensionSender clientHelloSendersSSL3[SSL_MAX_EXTENSIONS] = { | 305 ssl3HelloExtensionSender clientHelloSendersSSL3[SSL_MAX_EXTENSIONS] = { |
306 { ssl_renegotiation_info_xtn, &ssl3_SendRenegotiationInfoXtn } | 306 { ssl_renegotiation_info_xtn, &ssl3_SendRenegotiationInfoXtn } |
307 /* any extra entries will appear as { 0, NULL } */ | 307 /* any extra entries will appear as { 0, NULL } */ |
308 }; | 308 }; |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
623 static SECStatus | 623 static SECStatus |
624 ssl3_ClientHandleNextProtoNegoXtn(sslSocket *ss, PRUint16 ex_type, | 624 ssl3_ClientHandleNextProtoNegoXtn(sslSocket *ss, PRUint16 ex_type, |
625 SECItem *data) | 625 SECItem *data) |
626 { | 626 { |
627 SECStatus rv; | 627 SECStatus rv; |
628 unsigned char resultBuffer[255]; | 628 unsigned char resultBuffer[255]; |
629 SECItem result = { siBuffer, resultBuffer, 0 }; | 629 SECItem result = { siBuffer, resultBuffer, 0 }; |
630 | 630 |
631 PORT_Assert(!ss->firstHsDone); | 631 PORT_Assert(!ss->firstHsDone); |
632 | 632 |
633 if (ssl3_ExtensionNegotiated(ss, ssl_app_layer_protocol_xtn)) { | 633 if (ssl3_ExtensionNegotiated(ss, ssl_app_layer_protocol_xtn)) { |
wtc
2014/02/12 15:26:24
As an optimization, check ss->opt.enableALPN first
| |
634 /* If the server negotiated ALPN then it has already told us what protoc ol | |
635 * to use, so it doesn't make sense for us to try to negotiate a differe nt | |
636 * one by sending the NPN handshake message. However, if we've negotiate d | |
637 * NPN then we're required to send the NPN handshake message. Thus, thes e | |
638 * two extensions cannot both be negotiated on the same connection. */ | |
634 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); | 639 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); |
wtc
2014/02/12 15:26:24
Use a different error code. This is not an NSS bug
| |
635 return SECFailure; | 640 return SECFailure; |
636 } | 641 } |
637 | 642 |
638 rv = ssl3_ValidateNextProtoNego(data->data, data->len); | 643 rv = ssl3_ValidateNextProtoNego(data->data, data->len); |
639 if (rv != SECSuccess) | 644 if (rv != SECSuccess) |
640 return rv; | 645 return rv; |
641 | 646 |
642 /* ss->nextProtoCallback cannot normally be NULL if we negotiated the | 647 /* ss->nextProtoCallback cannot normally be NULL if we negotiated the |
643 * extension. However, It is possible that an application erroneously | 648 * extension. However, It is possible that an application erroneously |
644 * cleared the callback between the time we sent the ClientHello and now. | 649 * cleared the callback between the time we sent the ClientHello and now. |
(...skipping 23 matching lines...) Expand all Loading... | |
668 return SECITEM_CopyItem(NULL, &ss->ssl3.nextProto, &result); | 673 return SECITEM_CopyItem(NULL, &ss->ssl3.nextProto, &result); |
669 } | 674 } |
670 | 675 |
671 static SECStatus | 676 static SECStatus |
672 ssl3_ClientHandleAppProtoXtn(sslSocket *ss, PRUint16 ex_type, SECItem *data) | 677 ssl3_ClientHandleAppProtoXtn(sslSocket *ss, PRUint16 ex_type, SECItem *data) |
673 { | 678 { |
674 const unsigned char* d = data->data; | 679 const unsigned char* d = data->data; |
675 PRUint16 name_list_len; | 680 PRUint16 name_list_len; |
676 SECItem protocol_name; | 681 SECItem protocol_name; |
677 | 682 |
678 if (ssl3_ExtensionNegotiated(ss, ssl_next_proto_nego_xtn)) { | 683 if (ssl3_ExtensionNegotiated(ss, ssl_next_proto_nego_xtn)) { |
wtc
2014/02/12 15:26:24
Add a comment.
As an optimization, check ss->opt.
| |
679 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); | 684 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); |
680 return SECFailure; | 685 return SECFailure; |
681 } | 686 } |
682 | 687 |
683 /* The extension data from the server has the following format: | 688 /* The extension data from the server has the following format: |
684 * uint16 name_list_len; | 689 * uint16 name_list_len; |
685 * uint8 len; | 690 * uint8 len; |
686 * uint8 protocol_name[len]; */ | 691 * uint8 protocol_name[len]; */ |
687 if (data->len < 4 || data->len > 2 + 1 + 255) { | 692 if (data->len < 4 || data->len > 2 + 1 + 255) { |
688 PORT_SetError(SSL_ERROR_NEXT_PROTOCOL_DATA_INVALID); | 693 PORT_SetError(SSL_ERROR_NEXT_PROTOCOL_DATA_INVALID); |
689 return SECFailure; | 694 return SECFailure; |
690 } | 695 } |
691 | 696 |
692 name_list_len = ((PRUint16) d[0]) << 8 | | 697 name_list_len = ((PRUint16) d[0]) << 8 | |
693 ((PRUint16) d[1]); | 698 ((PRUint16) d[1]); |
694 if (name_list_len != data->len - 2 || | 699 if (name_list_len != data->len - 2 || d[2] != data->len - 3) { |
695 » d[2] != data->len - 3) { | |
696 PORT_SetError(SSL_ERROR_NEXT_PROTOCOL_DATA_INVALID); | 700 PORT_SetError(SSL_ERROR_NEXT_PROTOCOL_DATA_INVALID); |
697 return SECFailure; | 701 return SECFailure; |
698 } | 702 } |
699 | 703 |
700 protocol_name.data = data->data + 3; | 704 protocol_name.data = data->data + 3; |
701 protocol_name.len = data->len - 3; | 705 protocol_name.len = data->len - 3; |
702 | 706 |
703 SECITEM_FreeItem(&ss->ssl3.nextProto, PR_FALSE); | 707 SECITEM_FreeItem(&ss->ssl3.nextProto, PR_FALSE); |
704 ss->ssl3.nextProtoState = SSL_NEXT_PROTO_SELECTED; | 708 ss->ssl3.nextProtoState = SSL_NEXT_PROTO_SELECTED; |
705 ss->xtnData.negotiated[ss->xtnData.numNegotiated++] = ex_type; | 709 ss->xtnData.negotiated[ss->xtnData.numNegotiated++] = ex_type; |
706 return SECITEM_CopyItem(NULL, &ss->ssl3.nextProto, &protocol_name); | 710 return SECITEM_CopyItem(NULL, &ss->ssl3.nextProto, &protocol_name); |
707 } | 711 } |
708 | 712 |
709 static PRInt32 | 713 static PRInt32 |
710 ssl3_ClientSendNextProtoNegoXtn(sslSocket * ss, PRBool append, | 714 ssl3_ClientSendNextProtoNegoXtn(sslSocket * ss, PRBool append, |
711 PRUint32 maxBytes) | 715 PRUint32 maxBytes) |
712 { | 716 { |
713 PRInt32 extension_length; | 717 PRInt32 extension_length; |
714 | 718 |
715 /* Renegotiations do not send this extension. */ | 719 /* Renegotiations do not send this extension. */ |
716 if (!ss->nextProtoCallback || ss->firstHsDone) { | 720 if (!ss->opt.enableNPN || !ss->nextProtoCallback || ss->firstHsDone) { |
717 return 0; | 721 return 0; |
718 } | 722 } |
719 | 723 |
720 extension_length = 4; | 724 extension_length = 4; |
721 | 725 |
722 if (append && maxBytes >= extension_length) { | 726 if (append && maxBytes >= extension_length) { |
723 SECStatus rv; | 727 SECStatus rv; |
724 rv = ssl3_AppendHandshakeNumber(ss, ssl_next_proto_nego_xtn, 2); | 728 rv = ssl3_AppendHandshakeNumber(ss, ssl_next_proto_nego_xtn, 2); |
725 if (rv != SECSuccess) | 729 if (rv != SECSuccess) |
726 goto loser; | 730 goto loser; |
(...skipping 12 matching lines...) Expand all Loading... | |
739 return -1; | 743 return -1; |
740 } | 744 } |
741 | 745 |
742 static PRInt32 | 746 static PRInt32 |
743 ssl3_ClientSendAppProtoXtn(sslSocket * ss, PRBool append, PRUint32 maxBytes) | 747 ssl3_ClientSendAppProtoXtn(sslSocket * ss, PRBool append, PRUint32 maxBytes) |
744 { | 748 { |
745 PRInt32 extension_length; | 749 PRInt32 extension_length; |
746 unsigned char *alpn_protos = NULL; | 750 unsigned char *alpn_protos = NULL; |
747 | 751 |
748 /* Renegotiations do not send this extension. */ | 752 /* Renegotiations do not send this extension. */ |
749 if (!ss->opt.nextProtoNego.data || ss->firstHsDone) { | 753 if (!ss->opt.enableALPN || !ss->opt.nextProtoNego.data || ss->firstHsDone) { |
750 return 0; | 754 return 0; |
751 } | 755 } |
752 | 756 |
753 extension_length = 2 /* extension type */ + 2 /* extension length */ + | 757 extension_length = 2 /* extension type */ + 2 /* extension length */ + |
754 2 /* protocol name list length */ + | 758 » » 2 /* protocol name list length */ + |
755 ss->opt.nextProtoNego.len; | 759 » » ss->opt.nextProtoNego.len; |
756 | 760 |
757 if (append && maxBytes >= extension_length) { | 761 if (append && maxBytes >= extension_length) { |
758 /* NPN requires that the client's fallback protocol is first in the | 762 /* NPN requires that the client's fallback protocol is first in the |
759 * list. However, ALPN sends protocols in preference order. So we | 763 * list. However, ALPN sends protocols in preference order. So we |
760 * allocate a buffer and move the first protocol to the end of the | 764 * allocate a buffer and move the first protocol to the end of the |
761 * list. */ | 765 * list. */ |
762 SECStatus rv; | 766 SECStatus rv; |
763 const unsigned int len = ss->opt.nextProtoNego.len; | 767 const unsigned int len = ss->opt.nextProtoNego.len; |
764 | 768 |
765 alpn_protos = PORT_Alloc(len); | 769 alpn_protos = PORT_Alloc(len); |
766 if (alpn_protos == NULL) { | 770 if (alpn_protos == NULL) { |
767 return SECFailure; | 771 return SECFailure; |
768 } | 772 } |
769 if (len > 0) { | 773 if (len > 0) { |
770 /* Each protocol string is prefixed with a single byte length. */ | 774 /* Each protocol string is prefixed with a single byte length. */ |
771 unsigned int i = ss->opt.nextProtoNego.data[0] + 1; | 775 unsigned int i = ss->opt.nextProtoNego.data[0] + 1; |
772 if (i <= len) { | 776 if (i <= len) { |
773 memcpy(alpn_protos, &ss->opt.nextProtoNego.data[i], len - i); | 777 memcpy(alpn_protos, &ss->opt.nextProtoNego.data[i], len - i); |
774 memcpy(alpn_protos + len - i, ss->opt.nextProtoNego.data, i); | 778 memcpy(alpn_protos + len - i, ss->opt.nextProtoNego.data, i); |
775 } else { | 779 } else { |
776 /* This seems to be invalid data so we'll send as-is. */ | 780 /* This seems to be invalid data so we'll send as-is. */ |
777 memcpy(alpn_protos, ss->opt.nextProtoNego.data, len); | 781 memcpy(alpn_protos, ss->opt.nextProtoNego.data, len); |
778 } | 782 } |
779 } | 783 } |
780 | 784 |
781 rv = ssl3_AppendHandshakeNumber(ss, ssl_app_layer_protocol_xtn, 2); | 785 rv = ssl3_AppendHandshakeNumber(ss, ssl_app_layer_protocol_xtn, 2); |
782 » if (rv != SECSuccess) | 786 » if (rv != SECSuccess) { |
783 goto loser; | 787 goto loser; |
788 } | |
784 rv = ssl3_AppendHandshakeNumber(ss, extension_length - 4, 2); | 789 rv = ssl3_AppendHandshakeNumber(ss, extension_length - 4, 2); |
785 » if (rv != SECSuccess) | 790 » if (rv != SECSuccess) { |
786 goto loser; | 791 goto loser; |
792 } | |
787 rv = ssl3_AppendHandshakeVariable(ss, alpn_protos, len, 2); | 793 rv = ssl3_AppendHandshakeVariable(ss, alpn_protos, len, 2); |
788 PORT_Free(alpn_protos); | 794 PORT_Free(alpn_protos); |
789 alpn_protos = NULL; | 795 alpn_protos = NULL; |
790 » if (rv != SECSuccess) | 796 » if (rv != SECSuccess) { |
791 goto loser; | 797 goto loser; |
798 } | |
792 ss->xtnData.advertised[ss->xtnData.numAdvertised++] = | 799 ss->xtnData.advertised[ss->xtnData.numAdvertised++] = |
793 ssl_app_layer_protocol_xtn; | 800 ssl_app_layer_protocol_xtn; |
794 } else if (maxBytes < extension_length) { | 801 } else if (maxBytes < extension_length) { |
795 return 0; | 802 return 0; |
796 } | 803 } |
797 | 804 |
798 return extension_length; | 805 return extension_length; |
799 | 806 |
800 loser: | 807 loser: |
801 if (alpn_protos) | 808 if (alpn_protos) { |
802 PORT_Free(alpn_protos); | 809 PORT_Free(alpn_protos); |
810 } | |
803 return -1; | 811 return -1; |
804 } | 812 } |
805 | 813 |
806 static SECStatus | 814 static SECStatus |
807 ssl3_ClientHandleChannelIDXtn(sslSocket *ss, PRUint16 ex_type, | 815 ssl3_ClientHandleChannelIDXtn(sslSocket *ss, PRUint16 ex_type, |
808 SECItem *data) | 816 SECItem *data) |
809 { | 817 { |
810 PORT_Assert(ss->getChannelID != NULL); | 818 PORT_Assert(ss->getChannelID != NULL); |
811 | 819 |
812 if (data->len) { | 820 if (data->len) { |
(...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2335 unsigned int extensionLength; | 2343 unsigned int extensionLength; |
2336 | 2344 |
2337 /* This condition should be: | 2345 /* This condition should be: |
2338 * if (recordLength < 256 || recordLength >= 512) { | 2346 * if (recordLength < 256 || recordLength >= 512) { |
2339 * It has been changed, temporarily, to test whether 512 byte ClientHellos | 2347 * It has been changed, temporarily, to test whether 512 byte ClientHellos |
2340 * are a compatibility problem. */ | 2348 * are a compatibility problem. */ |
2341 if (recordLength >= 512) { | 2349 if (recordLength >= 512) { |
2342 return 0; | 2350 return 0; |
2343 } | 2351 } |
2344 | 2352 |
2345 extensionLength = 512 - recordLength; | 2353 extensionLength = 512 - recordLength; |
2346 /* Extensions take at least four bytes to encode. */ | 2354 /* Extensions take at least four bytes to encode. */ |
2347 if (extensionLength < 4) { | 2355 if (extensionLength < 4) { |
2348 » extensionLength = 4; | 2356 » extensionLength = 4; |
2349 } | 2357 } |
2350 | 2358 |
2351 return extensionLength; | 2359 return extensionLength; |
2352 } | 2360 } |
2353 | 2361 |
2354 /* ssl3_AppendPaddingExtension possibly adds an extension which ensures that a | 2362 /* ssl3_AppendPaddingExtension possibly adds an extension which ensures that a |
2355 * ClientHello record is either < 256 bytes or is >= 512 bytes. This ensures | 2363 * ClientHello record is either < 256 bytes or is >= 512 bytes. This ensures |
2356 * that we don't trigger bugs in F5 products. */ | 2364 * that we don't trigger bugs in F5 products. */ |
2357 PRInt32 | 2365 PRInt32 |
2358 ssl3_AppendPaddingExtension(sslSocket *ss, unsigned int extensionLen, | 2366 ssl3_AppendPaddingExtension(sslSocket *ss, unsigned int extensionLen, |
2359 PRUint32 maxBytes) | 2367 PRUint32 maxBytes) |
2360 { | 2368 { |
2361 unsigned int paddingLen = extensionLen - 4; | 2369 unsigned int paddingLen = extensionLen - 4; |
2362 unsigned char padding[512]; | 2370 static unsigned char padding[512]; |
2363 | 2371 |
2364 if (extensionLen == 0) { | 2372 if (extensionLen == 0) { |
2365 return 0; | 2373 return 0; |
2366 } | 2374 } |
2367 | 2375 |
2368 if (extensionLen < 4 || | 2376 if (extensionLen < 4 || |
2369 extensionLen > maxBytes || | 2377 extensionLen > maxBytes || |
2370 paddingLen > sizeof(padding)) { | 2378 paddingLen > sizeof(padding)) { |
2371 PORT_Assert(0); | 2379 PORT_Assert(0); |
2372 return -1; | 2380 return -1; |
2373 } | 2381 } |
2374 | 2382 |
2375 if (SECSuccess != ssl3_AppendHandshakeNumber(ss, ssl_padding_xtn, 2)) | 2383 if (SECSuccess != ssl3_AppendHandshakeNumber(ss, ssl_padding_xtn, 2)) |
2376 return -1; | 2384 return -1; |
2377 if (SECSuccess != ssl3_AppendHandshakeNumber(ss, paddingLen, 2)) | 2385 if (SECSuccess != ssl3_AppendHandshakeNumber(ss, paddingLen, 2)) |
2378 return -1; | 2386 return -1; |
2379 memset(padding, 0, paddingLen); | |
2380 if (SECSuccess != ssl3_AppendHandshake(ss, padding, paddingLen)) | 2387 if (SECSuccess != ssl3_AppendHandshake(ss, padding, paddingLen)) |
2381 return -1; | 2388 return -1; |
2382 | 2389 |
2383 return extensionLen; | 2390 return extensionLen; |
2384 } | 2391 } |
2385 | 2392 |
2386 /* ssl3_ClientSendSignedCertTimestampXtn sends the signed_certificate_timestamp | 2393 /* ssl3_ClientSendSignedCertTimestampXtn sends the signed_certificate_timestamp |
2387 * extension for TLS ClientHellos. */ | 2394 * extension for TLS ClientHellos. */ |
2388 static PRInt32 | 2395 static PRInt32 |
2389 ssl3_ClientSendSignedCertTimestampXtn(sslSocket *ss, PRBool append, | 2396 ssl3_ClientSendSignedCertTimestampXtn(sslSocket *ss, PRBool append, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2437 | 2444 |
2438 if (!data->len) { | 2445 if (!data->len) { |
2439 /* Empty extension data: RFC 6962 mandates non-empty contents. */ | 2446 /* Empty extension data: RFC 6962 mandates non-empty contents. */ |
2440 return SECFailure; | 2447 return SECFailure; |
2441 } | 2448 } |
2442 *scts = *data; | 2449 *scts = *data; |
2443 /* Keep track of negotiated extensions. */ | 2450 /* Keep track of negotiated extensions. */ |
2444 ss->xtnData.negotiated[ss->xtnData.numNegotiated++] = ex_type; | 2451 ss->xtnData.negotiated[ss->xtnData.numNegotiated++] = ex_type; |
2445 return SECSuccess; | 2452 return SECSuccess; |
2446 } | 2453 } |
OLD | NEW |