OLD | NEW |
1 /* | 1 /* |
2 * This file is PRIVATE to SSL and should be the first thing included by | 2 * This file is PRIVATE to SSL and should be the first thing included by |
3 * any SSL implementation file. | 3 * any SSL implementation file. |
4 * | 4 * |
5 * This Source Code Form is subject to the terms of the Mozilla Public | 5 * This Source Code Form is subject to the terms of the Mozilla Public |
6 * License, v. 2.0. If a copy of the MPL was not distributed with this | 6 * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
8 /* $Id: sslimpl.h,v 1.108 2012/09/28 01:46:45 wtc%google.com Exp $ */ | 8 /* $Id$ */ |
9 | 9 |
10 #ifndef __sslimpl_h_ | 10 #ifndef __sslimpl_h_ |
11 #define __sslimpl_h_ | 11 #define __sslimpl_h_ |
12 | 12 |
13 #ifdef DEBUG | 13 #ifdef DEBUG |
14 #undef NDEBUG | 14 #undef NDEBUG |
15 #else | 15 #else |
16 #undef NDEBUG | 16 #undef NDEBUG |
17 #define NDEBUG | 17 #define NDEBUG |
18 #endif | 18 #endif |
19 #include "secport.h" | 19 #include "secport.h" |
20 #include "secerr.h" | 20 #include "secerr.h" |
21 #include "sslerr.h" | 21 #include "sslerr.h" |
22 #include "ssl3prot.h" | 22 #include "ssl3prot.h" |
23 #include "hasht.h" | 23 #include "hasht.h" |
24 #include "keythi.h" | 24 #include "keythi.h" |
25 #include "nssilock.h" | 25 #include "nssilock.h" |
26 #include "pkcs11t.h" | 26 #include "pkcs11t.h" |
27 #if defined(XP_UNIX) || defined(XP_BEOS) | 27 #if defined(XP_UNIX) || defined(XP_BEOS) |
28 #include "unistd.h" | 28 #include "unistd.h" |
29 #endif | 29 #endif |
30 #include "nssrwlk.h" | 30 #include "nssrwlk.h" |
31 #include "prthread.h" | 31 #include "prthread.h" |
32 #include "prclist.h" | 32 #include "prclist.h" |
33 | 33 |
34 #include "sslt.h" /* for some formerly private types, now public */ | 34 #include "sslt.h" /* for some formerly private types, now public */ |
35 | 35 |
| 36 #include "secitem_array.h" |
| 37 |
36 #ifdef NSS_PLATFORM_CLIENT_AUTH | 38 #ifdef NSS_PLATFORM_CLIENT_AUTH |
37 #if defined(XP_WIN32) | 39 #if defined(XP_WIN32) |
38 #include <windows.h> | 40 #include <windows.h> |
39 #include <wincrypt.h> | 41 #include <wincrypt.h> |
40 #elif defined(XP_MACOSX) | 42 #elif defined(XP_MACOSX) |
41 #include <Security/Security.h> | 43 #include <Security/Security.h> |
42 #endif | 44 #endif |
43 #endif | 45 #endif |
44 | 46 |
45 /* to make some of these old enums public without namespace pollution, | 47 /* to make some of these old enums public without namespace pollution, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 146 |
145 /* number of wrap mechanisms potentially used to wrap master secrets. */ | 147 /* number of wrap mechanisms potentially used to wrap master secrets. */ |
146 #define SSL_NUM_WRAP_MECHS 16 | 148 #define SSL_NUM_WRAP_MECHS 16 |
147 | 149 |
148 /* This makes the cert cache entry exactly 4k. */ | 150 /* This makes the cert cache entry exactly 4k. */ |
149 #define SSL_MAX_CACHED_CERT_LEN 4060 | 151 #define SSL_MAX_CACHED_CERT_LEN 4060 |
150 | 152 |
151 #define NUM_MIXERS 9 | 153 #define NUM_MIXERS 9 |
152 | 154 |
153 /* Mask of the 25 named curves we support. */ | 155 /* Mask of the 25 named curves we support. */ |
154 #ifndef NSS_ECC_MORE_THAN_SUITE_B | 156 #define SSL3_ALL_SUPPORTED_CURVES_MASK 0x3fffffe |
155 #define SSL3_SUPPORTED_CURVES_MASK 0x3800000» /* only 3 curves, suite B*/ | 157 /* only 3 curves, suite B*/ |
156 #else | 158 #define SSL3_SUITE_B_SUPPORTED_CURVES_MASK 0x3800000 |
157 #define SSL3_SUPPORTED_CURVES_MASK 0x3fffffe | |
158 #endif | |
159 | 159 |
160 #ifndef BPB | 160 #ifndef BPB |
161 #define BPB 8 /* Bits Per Byte */ | 161 #define BPB 8 /* Bits Per Byte */ |
162 #endif | 162 #endif |
163 | 163 |
164 #define EXPORT_RSA_KEY_LENGTH 64 /* bytes */ | 164 #define EXPORT_RSA_KEY_LENGTH 64 /* bytes */ |
165 | 165 |
166 #define INITIAL_DTLS_TIMEOUT_MS 1000 /* Default value from RFC 4347 = 1s*/ | 166 #define INITIAL_DTLS_TIMEOUT_MS 1000 /* Default value from RFC 4347 = 1s*/ |
167 #define MAX_DTLS_TIMEOUT_MS 60000 /* 1 minute */ | 167 #define MAX_DTLS_TIMEOUT_MS 60000 /* 1 minute */ |
168 #define DTLS_FINISHED_TIMER_MS 120000 /* Time to wait in FINISHED state */ | 168 #define DTLS_FINISHED_TIMER_MS 120000 /* Time to wait in FINISHED state */ |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 invalid_cache /* no longer in any cache. */ | 590 invalid_cache /* no longer in any cache. */ |
591 } Cached; | 591 } Cached; |
592 | 592 |
593 #define MAX_PEER_CERT_CHAIN_SIZE 8 | 593 #define MAX_PEER_CERT_CHAIN_SIZE 8 |
594 | 594 |
595 struct sslSessionIDStr { | 595 struct sslSessionIDStr { |
596 sslSessionID * next; /* chain used for client sockets, only */ | 596 sslSessionID * next; /* chain used for client sockets, only */ |
597 | 597 |
598 CERTCertificate * peerCert; | 598 CERTCertificate * peerCert; |
599 CERTCertificate * peerCertChain[MAX_PEER_CERT_CHAIN_SIZE]; | 599 CERTCertificate * peerCertChain[MAX_PEER_CERT_CHAIN_SIZE]; |
| 600 SECItemArray peerCertStatus; /* client only */ |
600 const char * peerID; /* client only */ | 601 const char * peerID; /* client only */ |
601 const char * urlSvrName; /* client only */ | 602 const char * urlSvrName; /* client only */ |
602 CERTCertificate * localCert; | 603 CERTCertificate * localCert; |
603 | 604 |
604 PRIPv6Addr addr; | 605 PRIPv6Addr addr; |
605 PRUint16 port; | 606 PRUint16 port; |
606 | 607 |
607 SSL3ProtocolVersion version; | 608 SSL3ProtocolVersion version; |
608 | 609 |
609 PRUint32 creationTime; /* seconds since Jan 1, 1970 */ | 610 PRUint32 creationTime; /* seconds since Jan 1, 1970 */ |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 }; | 733 }; |
733 | 734 |
734 typedef enum { | 735 typedef enum { |
735 wait_client_hello, | 736 wait_client_hello, |
736 wait_client_cert, | 737 wait_client_cert, |
737 wait_client_key, | 738 wait_client_key, |
738 wait_cert_verify, | 739 wait_cert_verify, |
739 wait_change_cipher, | 740 wait_change_cipher, |
740 wait_finished, | 741 wait_finished, |
741 wait_server_hello, | 742 wait_server_hello, |
| 743 wait_certificate_status, |
742 wait_server_cert, | 744 wait_server_cert, |
743 wait_server_key, | 745 wait_server_key, |
744 wait_cert_request, | 746 wait_cert_request, |
745 wait_hello_done, | 747 wait_hello_done, |
746 wait_new_session_ticket, | 748 wait_new_session_ticket, |
747 idle_handshake | 749 idle_handshake |
748 } SSL3WaitState; | 750 } SSL3WaitState; |
749 | 751 |
750 /* | 752 /* |
751 * TLS extension related constants and data structures. | 753 * TLS extension related constants and data structures. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 /* partial handshake message from record layer */ | 809 /* partial handshake message from record layer */ |
808 unsigned int header_bytes; | 810 unsigned int header_bytes; |
809 /* number of bytes consumed from handshake */ | 811 /* number of bytes consumed from handshake */ |
810 /* message for message type and header length */ | 812 /* message for message type and header length */ |
811 SSL3HandshakeType msg_type; | 813 SSL3HandshakeType msg_type; |
812 unsigned long msg_len; | 814 unsigned long msg_len; |
813 SECItem ca_list; /* used only by client */ | 815 SECItem ca_list; /* used only by client */ |
814 PRBool isResuming; /* are we resuming a session */ | 816 PRBool isResuming; /* are we resuming a session */ |
815 PRBool usedStepDownKey; /* we did a server key exchange. */ | 817 PRBool usedStepDownKey; /* we did a server key exchange. */ |
816 PRBool sendingSCSV; /* instead of empty RI */ | 818 PRBool sendingSCSV; /* instead of empty RI */ |
817 PRBool may_get_cert_status; /* the server echoed a | |
818 * status_request extension so | |
819 * may send a CertificateStatus | |
820 * handshake message. */ | |
821 SECItem pending_cert_msg; /* a Certificate message which we | |
822 * save temporarily if we may get | |
823 * a CertificateStatus message */ | |
824 SECItem cert_status; /* an OCSP response */ | |
825 sslBuffer msgState; /* current state for handshake messages*/ | 819 sslBuffer msgState; /* current state for handshake messages*/ |
826 /* protected by recvBufLock */ | 820 /* protected by recvBufLock */ |
827 sslBuffer messages; /* Accumulated handshake messages */ | 821 sslBuffer messages; /* Accumulated handshake messages */ |
828 PRUint16 finishedBytes; /* size of single finished below */ | 822 PRUint16 finishedBytes; /* size of single finished below */ |
829 union { | 823 union { |
830 TLSFinished tFinished[2]; /* client, then server */ | 824 TLSFinished tFinished[2]; /* client, then server */ |
831 SSL3Hashes sFinished[2]; | 825 SSL3Hashes sFinished[2]; |
832 SSL3Opaque data[72]; | 826 SSL3Opaque data[72]; |
833 } finishedMsgs; | 827 } finishedMsgs; |
834 #ifdef NSS_ENABLE_ECC | 828 #ifdef NSS_ENABLE_ECC |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 | 1209 |
1216 /* Gather object used for gathering data */ | 1210 /* Gather object used for gathering data */ |
1217 sslGather gs; /*recvBufLock*/ | 1211 sslGather gs; /*recvBufLock*/ |
1218 | 1212 |
1219 sslBuffer saveBuf; /*xmitBufLock*/ | 1213 sslBuffer saveBuf; /*xmitBufLock*/ |
1220 sslBuffer pendingBuf; /*xmitBufLock*/ | 1214 sslBuffer pendingBuf; /*xmitBufLock*/ |
1221 | 1215 |
1222 /* Configuration state for server sockets */ | 1216 /* Configuration state for server sockets */ |
1223 /* server cert and key for each KEA type */ | 1217 /* server cert and key for each KEA type */ |
1224 sslServerCerts serverCerts[kt_kea_size]; | 1218 sslServerCerts serverCerts[kt_kea_size]; |
| 1219 SECItemArray * certStatusArray; |
1225 | 1220 |
1226 ssl3CipherSuiteCfg cipherSuites[ssl_V3_SUITES_IMPLEMENTED]; | 1221 ssl3CipherSuiteCfg cipherSuites[ssl_V3_SUITES_IMPLEMENTED]; |
1227 ssl3KeyPair * ephemeralECDHKeyPair; /* for ECDHE-* handshake */ | 1222 ssl3KeyPair * ephemeralECDHKeyPair; /* for ECDHE-* handshake */ |
1228 | 1223 |
1229 /* SSL3 state info. Formerly was a pointer */ | 1224 /* SSL3 state info. Formerly was a pointer */ |
1230 ssl3State ssl3; | 1225 ssl3State ssl3; |
1231 | 1226 |
1232 /* | 1227 /* |
1233 * TLS extension related data. | 1228 * TLS extension related data. |
1234 */ | 1229 */ |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 * key, signed by the larger key. The smaller key is a "step down" key. | 1530 * key, signed by the larger key. The smaller key is a "step down" key. |
1536 * Generate that key pair and keep it around. | 1531 * Generate that key pair and keep it around. |
1537 */ | 1532 */ |
1538 extern SECStatus ssl3_CreateRSAStepDownKeys(sslSocket *ss); | 1533 extern SECStatus ssl3_CreateRSAStepDownKeys(sslSocket *ss); |
1539 | 1534 |
1540 #ifdef NSS_ENABLE_ECC | 1535 #ifdef NSS_ENABLE_ECC |
1541 extern void ssl3_FilterECCipherSuitesByServerCerts(sslSocket *ss); | 1536 extern void ssl3_FilterECCipherSuitesByServerCerts(sslSocket *ss); |
1542 extern PRBool ssl3_IsECCEnabled(sslSocket *ss); | 1537 extern PRBool ssl3_IsECCEnabled(sslSocket *ss); |
1543 extern SECStatus ssl3_DisableECCSuites(sslSocket * ss, | 1538 extern SECStatus ssl3_DisableECCSuites(sslSocket * ss, |
1544 const ssl3CipherSuite * suite); | 1539 const ssl3CipherSuite * suite); |
| 1540 extern PRInt32 ssl3_GetSupportedECCCurveMask(sslSocket *ss); |
| 1541 |
1545 | 1542 |
1546 /* Macro for finding a curve equivalent in strength to RSA key's */ | 1543 /* Macro for finding a curve equivalent in strength to RSA key's */ |
1547 #define SSL_RSASTRENGTH_TO_ECSTRENGTH(s) \ | 1544 #define SSL_RSASTRENGTH_TO_ECSTRENGTH(s) \ |
1548 ((s <= 1024) ? 160 \ | 1545 ((s <= 1024) ? 160 \ |
1549 : ((s <= 2048) ? 224 \ | 1546 : ((s <= 2048) ? 224 \ |
1550 : ((s <= 3072) ? 256 \ | 1547 : ((s <= 3072) ? 256 \ |
1551 : ((s <= 7168) ? 384 : 521 ) ) ) ) | 1548 : ((s <= 7168) ? 384 : 521 ) ) ) ) |
1552 | 1549 |
1553 /* Types and names of elliptic curves used in TLS */ | 1550 /* Types and names of elliptic curves used in TLS */ |
1554 typedef enum { ec_type_explicitPrime = 1, | 1551 typedef enum { ec_type_explicitPrime = 1, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 | 1665 |
1669 /* Functions that handle ClientHello and ServerHello extensions. */ | 1666 /* Functions that handle ClientHello and ServerHello extensions. */ |
1670 extern SECStatus ssl3_HandleServerNameXtn(sslSocket * ss, | 1667 extern SECStatus ssl3_HandleServerNameXtn(sslSocket * ss, |
1671 PRUint16 ex_type, SECItem *data); | 1668 PRUint16 ex_type, SECItem *data); |
1672 extern SECStatus ssl3_HandleSupportedCurvesXtn(sslSocket * ss, | 1669 extern SECStatus ssl3_HandleSupportedCurvesXtn(sslSocket * ss, |
1673 PRUint16 ex_type, SECItem *data); | 1670 PRUint16 ex_type, SECItem *data); |
1674 extern SECStatus ssl3_HandleSupportedPointFormatsXtn(sslSocket * ss, | 1671 extern SECStatus ssl3_HandleSupportedPointFormatsXtn(sslSocket * ss, |
1675 PRUint16 ex_type, SECItem *data); | 1672 PRUint16 ex_type, SECItem *data); |
1676 extern SECStatus ssl3_ClientHandleSessionTicketXtn(sslSocket *ss, | 1673 extern SECStatus ssl3_ClientHandleSessionTicketXtn(sslSocket *ss, |
1677 PRUint16 ex_type, SECItem *data); | 1674 PRUint16 ex_type, SECItem *data); |
1678 extern SECStatus ssl3_ClientHandleStatusRequestXtn(sslSocket *ss, | |
1679 PRUint16 ex_type, SECItem *data); | |
1680 extern SECStatus ssl3_ServerHandleSessionTicketXtn(sslSocket *ss, | 1675 extern SECStatus ssl3_ServerHandleSessionTicketXtn(sslSocket *ss, |
1681 PRUint16 ex_type, SECItem *data); | 1676 PRUint16 ex_type, SECItem *data); |
1682 | 1677 |
1683 /* ClientHello and ServerHello extension senders. | 1678 /* ClientHello and ServerHello extension senders. |
1684 * Note that not all extension senders are exposed here; only those that | 1679 * Note that not all extension senders are exposed here; only those that |
1685 * that need exposure. | 1680 * that need exposure. |
1686 */ | 1681 */ |
1687 extern PRInt32 ssl3_SendSessionTicketXtn(sslSocket *ss, PRBool append, | 1682 extern PRInt32 ssl3_SendSessionTicketXtn(sslSocket *ss, PRBool append, |
1688 PRUint32 maxBytes); | 1683 PRUint32 maxBytes); |
1689 extern PRInt32 ssl3_ClientSendStatusRequestXtn(sslSocket *ss, PRBool append, | |
1690 PRUint32 maxBytes); | |
1691 | 1684 |
1692 /* ClientHello and ServerHello extension senders. | 1685 /* ClientHello and ServerHello extension senders. |
1693 * The code is in ssl3ext.c. | 1686 * The code is in ssl3ext.c. |
1694 */ | 1687 */ |
1695 extern PRInt32 ssl3_SendServerNameXtn(sslSocket *ss, PRBool append, | 1688 extern PRInt32 ssl3_SendServerNameXtn(sslSocket *ss, PRBool append, |
1696 PRUint32 maxBytes); | 1689 PRUint32 maxBytes); |
1697 | 1690 |
1698 /* Assigns new cert, cert chain and keys to ss->serverCerts | 1691 /* Assigns new cert, cert chain and keys to ss->serverCerts |
1699 * struct. If certChain is NULL, tries to find one. Aborts if | 1692 * struct. If certChain is NULL, tries to find one. Aborts if |
1700 * fails to do so. If cert and keyPair are NULL - unconfigures | 1693 * fails to do so. If cert and keyPair are NULL - unconfigures |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1865 #else | 1858 #else |
1866 #define SSL_TRACE(msg) | 1859 #define SSL_TRACE(msg) |
1867 #endif | 1860 #endif |
1868 | 1861 |
1869 void ssl_Trace(const char *format, ...); | 1862 void ssl_Trace(const char *format, ...); |
1870 | 1863 |
1871 SEC_END_PROTOS | 1864 SEC_END_PROTOS |
1872 | 1865 |
1873 #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS) | 1866 #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS) |
1874 #define SSL_GETPID getpid | 1867 #define SSL_GETPID getpid |
1875 #elif defined(_WIN32_WCE) | |
1876 #define SSL_GETPID GetCurrentProcessId | |
1877 #elif defined(WIN32) | 1868 #elif defined(WIN32) |
1878 extern int __cdecl _getpid(void); | 1869 extern int __cdecl _getpid(void); |
1879 #define SSL_GETPID _getpid | 1870 #define SSL_GETPID _getpid |
1880 #else | 1871 #else |
1881 #define SSL_GETPID() 0 | 1872 #define SSL_GETPID() 0 |
1882 #endif | 1873 #endif |
1883 | 1874 |
1884 #endif /* __sslimpl_h_ */ | 1875 #endif /* __sslimpl_h_ */ |
OLD | NEW |