OLD | NEW |
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | 1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 /* | 2 /* |
3 * This file is PRIVATE to SSL and should be the first thing included by | 3 * This file is PRIVATE to SSL and should be the first thing included by |
4 * any SSL implementation file. | 4 * any SSL implementation file. |
5 * | 5 * |
6 * This Source Code Form is subject to the terms of the Mozilla Public | 6 * This Source Code Form is subject to the terms of the Mozilla Public |
7 * License, v. 2.0. If a copy of the MPL was not distributed with this | 7 * License, v. 2.0. If a copy of the MPL was not distributed with this |
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 8 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
9 | 9 |
10 #ifndef __sslimpl_h_ | 10 #ifndef __sslimpl_h_ |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 /* Mask of the 25 named curves we support. */ | 133 /* Mask of the 25 named curves we support. */ |
134 #define SSL3_ALL_SUPPORTED_CURVES_MASK 0x3fffffe | 134 #define SSL3_ALL_SUPPORTED_CURVES_MASK 0x3fffffe |
135 /* Mask of only 3 curves, suite B */ | 135 /* Mask of only 3 curves, suite B */ |
136 #define SSL3_SUITE_B_SUPPORTED_CURVES_MASK 0x3800000 | 136 #define SSL3_SUITE_B_SUPPORTED_CURVES_MASK 0x3800000 |
137 | 137 |
138 #ifndef BPB | 138 #ifndef BPB |
139 #define BPB 8 /* Bits Per Byte */ | 139 #define BPB 8 /* Bits Per Byte */ |
140 #endif | 140 #endif |
141 | 141 |
142 #define EXPORT_RSA_KEY_LENGTH 64 /* bytes */ | |
143 | |
144 /* The default value from RFC 4347 is 1s, which is too slow. */ | 142 /* The default value from RFC 4347 is 1s, which is too slow. */ |
145 #define DTLS_RETRANSMIT_INITIAL_MS 50 | 143 #define DTLS_RETRANSMIT_INITIAL_MS 50 |
146 /* The maximum time to wait between retransmissions. */ | 144 /* The maximum time to wait between retransmissions. */ |
147 #define DTLS_RETRANSMIT_MAX_MS 10000 | 145 #define DTLS_RETRANSMIT_MAX_MS 10000 |
148 /* Time to wait in FINISHED state for retransmissions. */ | 146 /* Time to wait in FINISHED state for retransmissions. */ |
149 #define DTLS_RETRANSMIT_FINISHED_MS 30000 | 147 #define DTLS_RETRANSMIT_FINISHED_MS 30000 |
150 | 148 |
151 typedef struct sslBufferStr sslBuffer; | 149 typedef struct sslBufferStr sslBuffer; |
152 typedef struct sslConnectInfoStr sslConnectInfo; | 150 typedef struct sslConnectInfoStr sslConnectInfo; |
153 typedef struct sslGatherStr sslGather; | 151 typedef struct sslGatherStr sslGather; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 unsigned int isPresent : 1; | 263 unsigned int isPresent : 1; |
266 #else | 264 #else |
267 ssl3CipherSuite cipher_suite; | 265 ssl3CipherSuite cipher_suite; |
268 PRUint8 policy; | 266 PRUint8 policy; |
269 unsigned char enabled : 1; | 267 unsigned char enabled : 1; |
270 unsigned char isPresent : 1; | 268 unsigned char isPresent : 1; |
271 #endif | 269 #endif |
272 } ssl3CipherSuiteCfg; | 270 } ssl3CipherSuiteCfg; |
273 | 271 |
274 #ifndef NSS_DISABLE_ECC | 272 #ifndef NSS_DISABLE_ECC |
275 #define ssl_V3_SUITES_IMPLEMENTED 67 | 273 #define ssl_V3_SUITES_IMPLEMENTED 63 |
276 #else | 274 #else |
277 #define ssl_V3_SUITES_IMPLEMENTED 41 | 275 #define ssl_V3_SUITES_IMPLEMENTED 37 |
278 #endif /* NSS_DISABLE_ECC */ | 276 #endif /* NSS_DISABLE_ECC */ |
279 | 277 |
280 #define MAX_DTLS_SRTP_CIPHER_SUITES 4 | 278 #define MAX_DTLS_SRTP_CIPHER_SUITES 4 |
281 | 279 |
282 /* MAX_SIGNATURE_ALGORITHMS allows for a large number of combinations of | 280 /* MAX_SIGNATURE_ALGORITHMS allows for a large number of combinations of |
283 * SSLSignType and SSLHashType, but not all combinations (specifically, this | 281 * SSLSignType and SSLHashType, but not all combinations (specifically, this |
284 * doesn't allow space for combinations with MD5). */ | 282 * doesn't allow space for combinations with MD5). */ |
285 #define MAX_SIGNATURE_ALGORITHMS 15 | 283 #define MAX_SIGNATURE_ALGORITHMS 15 |
286 | 284 |
287 /* clang-format off */ | 285 /* clang-format off */ |
288 typedef struct sslOptionsStr { | 286 typedef struct sslOptionsStr { |
289 /* If SSL_SetNextProtoNego has been called, then this contains the | 287 /* If SSL_SetNextProtoNego has been called, then this contains the |
290 * list of supported protocols. */ | 288 * list of supported protocols. */ |
291 SECItem nextProtoNego; | 289 SECItem nextProtoNego; |
292 | 290 |
293 unsigned int useSecurity : 1; /* 1 */ | 291 unsigned int useSecurity : 1; /* 1 */ |
294 unsigned int useSocks : 1; /* 2 */ | 292 unsigned int useSocks : 1; /* 2 */ |
295 unsigned int requestCertificate : 1; /* 3 */ | 293 unsigned int requestCertificate : 1; /* 3 */ |
296 unsigned int requireCertificate : 2; /* 4-5 */ | 294 unsigned int requireCertificate : 2; /* 4-5 */ |
297 unsigned int handshakeAsClient : 1; /* 6 */ | 295 unsigned int handshakeAsClient : 1; /* 6 */ |
298 unsigned int handshakeAsServer : 1; /* 7 */ | 296 unsigned int handshakeAsServer : 1; /* 7 */ |
299 unsigned int unusedBit8 : 1; /* 8 */ | 297 unsigned int unusedBit8 : 1; /* 8 */ |
300 unsigned int unusedBit9 : 1; /* 9 */ | 298 unsigned int unusedBit9 : 1; /* 9 */ |
301 unsigned int unusedBit10 : 1; /* 10 */ | 299 unsigned int unusedBit10 : 1; /* 10 */ |
302 unsigned int noCache : 1; /* 11 */ | 300 unsigned int noCache : 1; /* 11 */ |
303 unsigned int fdx : 1; /* 12 */ | 301 unsigned int fdx : 1; /* 12 */ |
304 unsigned int unusedBit13 : 1; /* 13 */ | 302 unsigned int unusedBit13 : 1; /* 13 */ |
305 unsigned int detectRollBack : 1; /* 14 */ | 303 unsigned int detectRollBack : 1; /* 14 */ |
306 unsigned int noStepDown : 1; /* 15 */ | 304 unsigned int unusedBit15 : 1; /* 15 */ |
307 unsigned int bypassPKCS11 : 1; /* 16 */ | 305 unsigned int bypassPKCS11 : 1; /* 16 */ |
308 unsigned int noLocks : 1; /* 17 */ | 306 unsigned int noLocks : 1; /* 17 */ |
309 unsigned int enableSessionTickets : 1; /* 18 */ | 307 unsigned int enableSessionTickets : 1; /* 18 */ |
310 unsigned int enableDeflate : 1; /* 19 */ | 308 unsigned int enableDeflate : 1; /* 19 */ |
311 unsigned int enableRenegotiation : 2; /* 20-21 */ | 309 unsigned int enableRenegotiation : 2; /* 20-21 */ |
312 unsigned int requireSafeNegotiation : 1; /* 22 */ | 310 unsigned int requireSafeNegotiation : 1; /* 22 */ |
313 unsigned int enableFalseStart : 1; /* 23 */ | 311 unsigned int enableFalseStart : 1; /* 23 */ |
314 unsigned int cbcRandomIV : 1; /* 24 */ | 312 unsigned int cbcRandomIV : 1; /* 24 */ |
315 unsigned int enableOCSPStapling : 1; /* 25 */ | 313 unsigned int enableOCSPStapling : 1; /* 25 */ |
316 unsigned int enableNPN : 1; /* 26 */ | 314 unsigned int enableNPN : 1; /* 26 */ |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 SSL3KeyExchangeAlgorithm key_exchange_alg; | 688 SSL3KeyExchangeAlgorithm key_exchange_alg; |
691 } ssl3CipherSuiteDef; | 689 } ssl3CipherSuiteDef; |
692 | 690 |
693 /* | 691 /* |
694 ** There are tables of these, all const. | 692 ** There are tables of these, all const. |
695 */ | 693 */ |
696 typedef struct { | 694 typedef struct { |
697 SSL3KeyExchangeAlgorithm kea; | 695 SSL3KeyExchangeAlgorithm kea; |
698 SSL3KEAType exchKeyType; | 696 SSL3KEAType exchKeyType; |
699 SSLSignType signKeyType; | 697 SSLSignType signKeyType; |
700 /* For export cipher suites: | |
701 * is_limited identifies a suite as having a limit on the key size. | |
702 * key_size_limit provides the corresponding limit. */ | |
703 PRBool is_limited; | |
704 unsigned int key_size_limit; | |
705 PRBool tls_keygen; | 698 PRBool tls_keygen; |
706 /* True if the key exchange for the suite is ephemeral. Or to be more | 699 /* True if the key exchange for the suite is ephemeral. Or to be more |
707 * precise: true if the ServerKeyExchange message is always required. */ | 700 * precise: true if the ServerKeyExchange message is always required. */ |
708 PRBool ephemeral; | 701 PRBool ephemeral; |
709 /* An OID describing the key exchange */ | 702 /* An OID describing the key exchange */ |
710 SECOidTag oid; | 703 SECOidTag oid; |
711 } ssl3KEADef; | 704 } ssl3KEADef; |
712 | 705 |
713 /* | 706 /* |
714 ** There are tables of these, all const. | 707 ** There are tables of these, all const. |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 SSLCompressionMethod compression; | 859 SSLCompressionMethod compression; |
867 sslBuffer msg_body; /* protected by recvBufLock */ | 860 sslBuffer msg_body; /* protected by recvBufLock */ |
868 /* partial handshake message from record layer */ | 861 /* partial handshake message from record layer */ |
869 unsigned int header_bytes; | 862 unsigned int header_bytes; |
870 /* number of bytes consumed from handshake */ | 863 /* number of bytes consumed from handshake */ |
871 /* message for message type and header length */ | 864 /* message for message type and header length */ |
872 SSL3HandshakeType msg_type; | 865 SSL3HandshakeType msg_type; |
873 unsigned long msg_len; | 866 unsigned long msg_len; |
874 SECItem ca_list; /* used only by client */ | 867 SECItem ca_list; /* used only by client */ |
875 PRBool isResuming; /* are we resuming a session */ | 868 PRBool isResuming; /* are we resuming a session */ |
876 PRBool usedStepDownKey; /* we did a server key exchange. */ | |
877 PRBool sendingSCSV; /* instead of empty RI */ | 869 PRBool sendingSCSV; /* instead of empty RI */ |
878 sslBuffer msgState; /* current state for handshake messages*/ | 870 sslBuffer msgState; /* current state for handshake messages*/ |
879 /* protected by recvBufLock */ | 871 /* protected by recvBufLock */ |
880 | 872 |
881 /* The session ticket received in a NewSessionTicket message is temporarily | 873 /* The session ticket received in a NewSessionTicket message is temporarily |
882 * stored in newSessionTicket until the handshake is finished; then it is | 874 * stored in newSessionTicket until the handshake is finished; then it is |
883 * moved to the sid. | 875 * moved to the sid. |
884 */ | 876 */ |
885 PRBool receivedNewSessionTicket; | 877 PRBool receivedNewSessionTicket; |
886 NewSessionTicket newSessionTicket; | 878 NewSessionTicket newSessionTicket; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 sslSecurityInfo sec; /* not a pointer any more */ | 1162 sslSecurityInfo sec; /* not a pointer any more */ |
1171 | 1163 |
1172 /* protected by firstHandshakeLock AND ssl3HandshakeLock. */ | 1164 /* protected by firstHandshakeLock AND ssl3HandshakeLock. */ |
1173 const char *url; | 1165 const char *url; |
1174 | 1166 |
1175 sslHandshakeFunc handshake; /*firstHandshakeLock*/ | 1167 sslHandshakeFunc handshake; /*firstHandshakeLock*/ |
1176 | 1168 |
1177 /* the following variable is only used with socks or other proxies. */ | 1169 /* the following variable is only used with socks or other proxies. */ |
1178 char *peerID; /* String uniquely identifies target server. */ | 1170 char *peerID; /* String uniquely identifies target server. */ |
1179 | 1171 |
1180 ssl3KeyPair *stepDownKeyPair; /* RSA step down keys */ | |
1181 | |
1182 const ssl3DHParams *dheParams; /* DHE param */ | 1172 const ssl3DHParams *dheParams; /* DHE param */ |
1183 ssl3KeyPair *dheKeyPair; /* DHE keys */ | 1173 ssl3KeyPair *dheKeyPair; /* DHE keys */ |
1184 | 1174 |
1185 /* Callbacks */ | 1175 /* Callbacks */ |
1186 SSLAuthCertificate authCertificate; | 1176 SSLAuthCertificate authCertificate; |
1187 void *authCertificateArg; | 1177 void *authCertificateArg; |
1188 SSLGetClientAuthData getClientAuthData; | 1178 SSLGetClientAuthData getClientAuthData; |
1189 void *getClientAuthDataArg; | 1179 void *getClientAuthDataArg; |
1190 SSLSNISocketConfig sniSocketConfig; | 1180 SSLSNISocketConfig sniSocketConfig; |
1191 void *sniSocketConfigArg; | 1181 void *sniSocketConfigArg; |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1557 #define SSL_LIBRARY_VERSION_MAX_SUPPORTED SSL_LIBRARY_VERSION_TLS_1_2 | 1547 #define SSL_LIBRARY_VERSION_MAX_SUPPORTED SSL_LIBRARY_VERSION_TLS_1_2 |
1558 #endif | 1548 #endif |
1559 | 1549 |
1560 #define SSL_ALL_VERSIONS_DISABLED(vrange) \ | 1550 #define SSL_ALL_VERSIONS_DISABLED(vrange) \ |
1561 ((vrange)->min == SSL_LIBRARY_VERSION_NONE) | 1551 ((vrange)->min == SSL_LIBRARY_VERSION_NONE) |
1562 | 1552 |
1563 extern PRBool ssl3_VersionIsSupported(SSLProtocolVariant protocolVariant, | 1553 extern PRBool ssl3_VersionIsSupported(SSLProtocolVariant protocolVariant, |
1564 SSL3ProtocolVersion version); | 1554 SSL3ProtocolVersion version); |
1565 | 1555 |
1566 extern SECStatus ssl3_KeyAndMacDeriveBypass(ssl3CipherSpec *pwSpec, | 1556 extern SECStatus ssl3_KeyAndMacDeriveBypass(ssl3CipherSpec *pwSpec, |
1567 const unsigned char *cr, const unsig
ned char *sr, | 1557 const unsigned char *cr, |
1568 PRBool isTLS, PRBool isExport); | 1558 const unsigned char *sr, |
| 1559 PRBool isTLS); |
1569 extern SECStatus ssl3_MasterSecretDeriveBypass(ssl3CipherSpec *pwSpec, | 1560 extern SECStatus ssl3_MasterSecretDeriveBypass(ssl3CipherSpec *pwSpec, |
1570 const unsigned char *cr, const un
signed char *sr, | 1561 const unsigned char *cr, const un
signed char *sr, |
1571 const SECItem *pms, PRBool isTLS,
PRBool isRSA); | 1562 const SECItem *pms, PRBool isTLS,
PRBool isRSA); |
1572 | 1563 |
1573 /* These functions are called from secnav, even though they're "private". */ | 1564 /* These functions are called from secnav, even though they're "private". */ |
1574 | 1565 |
1575 extern int SSL_RestartHandshakeAfterCertReq(struct sslSocketStr *ss, | 1566 extern int SSL_RestartHandshakeAfterCertReq(struct sslSocketStr *ss, |
1576 CERTCertificate *cert, | 1567 CERTCertificate *cert, |
1577 SECKEYPrivateKey *key, | 1568 SECKEYPrivateKey *key, |
1578 CERTCertificateList *certChain); | 1569 CERTCertificateList *certChain); |
(...skipping 14 matching lines...) Expand all Loading... |
1593 SECStatus ssl3_SendClientHello(sslSocket *ss, PRBool resending); | 1584 SECStatus ssl3_SendClientHello(sslSocket *ss, PRBool resending); |
1594 | 1585 |
1595 /* | 1586 /* |
1596 * input into the SSL3 machinery from the actualy network reading code | 1587 * input into the SSL3 machinery from the actualy network reading code |
1597 */ | 1588 */ |
1598 SECStatus ssl3_HandleRecord( | 1589 SECStatus ssl3_HandleRecord( |
1599 sslSocket *ss, SSL3Ciphertext *cipher, sslBuffer *out); | 1590 sslSocket *ss, SSL3Ciphertext *cipher, sslBuffer *out); |
1600 | 1591 |
1601 int ssl3_GatherAppDataRecord(sslSocket *ss, int flags); | 1592 int ssl3_GatherAppDataRecord(sslSocket *ss, int flags); |
1602 int ssl3_GatherCompleteHandshake(sslSocket *ss, int flags); | 1593 int ssl3_GatherCompleteHandshake(sslSocket *ss, int flags); |
1603 /* | |
1604 * When talking to export clients or using export cipher suites, servers | |
1605 * with public RSA keys larger than 512 bits need to use a 512-bit public | |
1606 * key, signed by the larger key. The smaller key is a "step down" key. | |
1607 * Generate that key pair and keep it around. | |
1608 */ | |
1609 extern SECStatus ssl3_CreateRSAStepDownKeys(sslSocket *ss); | |
1610 | 1594 |
1611 extern SECStatus ssl3_SelectDHParams(sslSocket *ss); | 1595 extern SECStatus ssl3_SelectDHParams(sslSocket *ss); |
1612 | 1596 |
1613 #ifndef NSS_DISABLE_ECC | 1597 #ifndef NSS_DISABLE_ECC |
1614 extern void ssl3_FilterECCipherSuitesByServerCerts(sslSocket *ss); | 1598 extern void ssl3_FilterECCipherSuitesByServerCerts(sslSocket *ss); |
1615 extern PRBool ssl3_IsECCEnabled(sslSocket *ss); | 1599 extern PRBool ssl3_IsECCEnabled(sslSocket *ss); |
1616 extern SECStatus ssl3_DisableECCSuites(sslSocket *ss, | 1600 extern SECStatus ssl3_DisableECCSuites(sslSocket *ss, |
1617 const ssl3CipherSuite *suite); | 1601 const ssl3CipherSuite *suite); |
1618 extern PRUint32 ssl3_GetSupportedECCurveMask(sslSocket *ss); | 1602 extern PRUint32 ssl3_GetSupportedECCurveMask(sslSocket *ss); |
1619 | 1603 |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1947 #ifdef DEBUG | 1931 #ifdef DEBUG |
1948 extern void ssl3_CheckCipherSuiteOrderConsistency(); | 1932 extern void ssl3_CheckCipherSuiteOrderConsistency(); |
1949 #endif | 1933 #endif |
1950 | 1934 |
1951 extern int ssl_MapLowLevelError(int hiLevelError); | 1935 extern int ssl_MapLowLevelError(int hiLevelError); |
1952 | 1936 |
1953 extern PRUint32 ssl_Time(void); | 1937 extern PRUint32 ssl_Time(void); |
1954 | 1938 |
1955 extern void SSL_AtomicIncrementLong(long *x); | 1939 extern void SSL_AtomicIncrementLong(long *x); |
1956 | 1940 |
1957 SECStatus SSL_DisableDefaultExportCipherSuites(void); | |
1958 SECStatus SSL_DisableExportCipherSuites(PRFileDesc *fd); | |
1959 PRBool SSL_IsExportCipherSuite(PRUint16 cipherSuite); | |
1960 | |
1961 SECStatus ssl3_ApplyNSSPolicy(void); | 1941 SECStatus ssl3_ApplyNSSPolicy(void); |
1962 | 1942 |
1963 extern SECStatus | 1943 extern SECStatus |
1964 ssl3_TLSPRFWithMasterSecret(ssl3CipherSpec *spec, | 1944 ssl3_TLSPRFWithMasterSecret(ssl3CipherSpec *spec, |
1965 const char *label, unsigned int labelLen, | 1945 const char *label, unsigned int labelLen, |
1966 const unsigned char *val, unsigned int valLen, | 1946 const unsigned char *val, unsigned int valLen, |
1967 unsigned char *out, unsigned int outLen); | 1947 unsigned char *out, unsigned int outLen); |
1968 extern SECOidTag | 1948 extern SECOidTag |
1969 ssl3_TLSHashAlgorithmToOID(SSLHashType hashFunc); | 1949 ssl3_TLSHashAlgorithmToOID(SSLHashType hashFunc); |
1970 | 1950 |
(...skipping 10 matching lines...) Expand all Loading... |
1981 #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS) | 1961 #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS) |
1982 #define SSL_GETPID getpid | 1962 #define SSL_GETPID getpid |
1983 #elif defined(WIN32) | 1963 #elif defined(WIN32) |
1984 extern int __cdecl _getpid(void); | 1964 extern int __cdecl _getpid(void); |
1985 #define SSL_GETPID _getpid | 1965 #define SSL_GETPID _getpid |
1986 #else | 1966 #else |
1987 #define SSL_GETPID() 0 | 1967 #define SSL_GETPID() 0 |
1988 #endif | 1968 #endif |
1989 | 1969 |
1990 #endif /* __sslimpl_h_ */ | 1970 #endif /* __sslimpl_h_ */ |
OLD | NEW |