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

Side by Side Diff: net/third_party/nss/ssl/sslimpl.h

Issue 9558017: Update net/third_party/nss to NSS 3.13.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Upload before checkin Created 8 years, 9 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 | « net/third_party/nss/ssl/sslerrstrs.c ('k') | net/third_party/nss/ssl/sslinfo.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * ***** BEGIN LICENSE BLOCK ***** 5 * ***** BEGIN LICENSE BLOCK *****
6 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 6 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 * 7 *
8 * The contents of this file are subject to the Mozilla Public License Version 8 * The contents of this file are subject to the Mozilla Public License Version
9 * 1.1 (the "License"); you may not use this file except in compliance with 9 * 1.1 (the "License"); you may not use this file except in compliance with
10 * the License. You may obtain a copy of the License at 10 * the License. You may obtain a copy of the License at
(...skipping 21 matching lines...) Expand all
32 * in which case the provisions of the GPL or the LGPL are applicable instead 32 * in which case the provisions of the GPL or the LGPL are applicable instead
33 * of those above. If you wish to allow use of your version of this file only 33 * of those above. If you wish to allow use of your version of this file only
34 * under the terms of either the GPL or the LGPL, and not to allow others to 34 * under the terms of either the GPL or the LGPL, and not to allow others to
35 * use your version of this file under the terms of the MPL, indicate your 35 * use your version of this file under the terms of the MPL, indicate your
36 * decision by deleting the provisions above and replace them with the notice 36 * decision by deleting the provisions above and replace them with the notice
37 * and other provisions required by the GPL or the LGPL. If you do not delete 37 * and other provisions required by the GPL or the LGPL. If you do not delete
38 * the provisions above, a recipient may use your version of this file under 38 * the provisions above, a recipient may use your version of this file under
39 * the terms of any one of the MPL, the GPL or the LGPL. 39 * the terms of any one of the MPL, the GPL or the LGPL.
40 * 40 *
41 * ***** END LICENSE BLOCK ***** */ 41 * ***** END LICENSE BLOCK ***** */
42 /* $Id: sslimpl.h,v 1.77.2.1 2010/07/31 04:33:52 wtc%google.com Exp $ */ 42 /* $Id: sslimpl.h,v 1.94 2012/02/15 21:52:08 kaie%kuix.de Exp $ */
43 43
44 #ifndef __sslimpl_h_ 44 #ifndef __sslimpl_h_
45 #define __sslimpl_h_ 45 #define __sslimpl_h_
46 46
47 #ifdef DEBUG 47 #ifdef DEBUG
48 #undef NDEBUG 48 #undef NDEBUG
49 #else 49 #else
50 #undef NDEBUG 50 #undef NDEBUG
51 #define NDEBUG 51 #define NDEBUG
52 #endif 52 #endif
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 317
318 #ifdef NSS_ENABLE_ECC 318 #ifdef NSS_ENABLE_ECC
319 #define ssl_V3_SUITES_IMPLEMENTED 50 319 #define ssl_V3_SUITES_IMPLEMENTED 50
320 #else 320 #else
321 #define ssl_V3_SUITES_IMPLEMENTED 30 321 #define ssl_V3_SUITES_IMPLEMENTED 30
322 #endif /* NSS_ENABLE_ECC */ 322 #endif /* NSS_ENABLE_ECC */
323 323
324 typedef struct sslOptionsStr { 324 typedef struct sslOptionsStr {
325 /* If SSL_SetNextProtoNego has been called, then this contains the 325 /* If SSL_SetNextProtoNego has been called, then this contains the
326 * list of supported protocols. */ 326 * list of supported protocols. */
327 SECItem nextProtoNego; 327 SECItem nextProtoNego;
328 328
329 unsigned int useSecurity : 1; /* 1 */ 329 unsigned int useSecurity : 1; /* 1 */
330 unsigned int useSocks : 1; /* 2 */ 330 unsigned int useSocks : 1; /* 2 */
331 unsigned int requestCertificate : 1; /* 3 */ 331 unsigned int requestCertificate : 1; /* 3 */
332 unsigned int requireCertificate : 2; /* 4-5 */ 332 unsigned int requireCertificate : 2; /* 4-5 */
333 unsigned int handshakeAsClient : 1; /* 6 */ 333 unsigned int handshakeAsClient : 1; /* 6 */
334 unsigned int handshakeAsServer : 1; /* 7 */ 334 unsigned int handshakeAsServer : 1; /* 7 */
335 unsigned int enableSSL2 : 1; /* 8 */ 335 unsigned int enableSSL2 : 1; /* 8 */
336 unsigned int enableSSL3 : 1; /* 9 */ 336 unsigned int enableSSL3 : 1; /* 9 */
337 unsigned int enableTLS : 1; /* 10 */ 337 unsigned int enableTLS : 1; /* 10 */
338 unsigned int noCache : 1; /* 11 */ 338 unsigned int noCache : 1; /* 11 */
339 unsigned int fdx : 1; /* 12 */ 339 unsigned int fdx : 1; /* 12 */
340 unsigned int v2CompatibleHello : 1; /* 13 */ 340 unsigned int v2CompatibleHello : 1; /* 13 */
341 unsigned int detectRollBack : 1; /* 14 */ 341 unsigned int detectRollBack : 1; /* 14 */
342 unsigned int noStepDown : 1; /* 15 */ 342 unsigned int noStepDown : 1; /* 15 */
343 unsigned int bypassPKCS11 : 1; /* 16 */ 343 unsigned int bypassPKCS11 : 1; /* 16 */
344 unsigned int noLocks : 1; /* 17 */ 344 unsigned int noLocks : 1; /* 17 */
345 unsigned int enableSessionTickets : 1; /* 18 */ 345 unsigned int enableSessionTickets : 1; /* 18 */
346 unsigned int enableDeflate : 1; /* 19 */ 346 unsigned int enableDeflate : 1; /* 19 */
347 unsigned int enableRenegotiation : 2; /* 20-21 */ 347 unsigned int enableRenegotiation : 2; /* 20-21 */
348 unsigned int requireSafeNegotiation : 1; /* 22 */ 348 unsigned int requireSafeNegotiation : 1; /* 22 */
349 unsigned int enableFalseStart : 1; /* 23 */ 349 unsigned int enableFalseStart : 1; /* 23 */
350 unsigned int enableOCSPStapling : 1; /* 24 */ 350 unsigned int cbcRandomIV : 1; /* 24 */
351 unsigned int enableCachedInfo : 1; /* 25 */ 351 unsigned int enableOCSPStapling : 1; /* 25 */
352 unsigned int enableOBCerts : 1; /* 26 */ 352 unsigned int enableOBCerts : 1; /* 26 */
353 unsigned int encryptClientCerts : 1; /* 27 */ 353 unsigned int encryptClientCerts : 1; /* 27 */
354 } sslOptions; 354 } sslOptions;
355 355
356 typedef enum { sslHandshakingUndetermined = 0, 356 typedef enum { sslHandshakingUndetermined = 0,
357 sslHandshakingAsClient, 357 sslHandshakingAsClient,
358 sslHandshakingAsServer 358 sslHandshakingAsServer
359 } sslHandshakingType; 359 } sslHandshakingType;
360 360
361 typedef struct sslServerCertsStr { 361 typedef struct sslServerCertsStr {
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 PRBool emptySessionTicket; 766 PRBool emptySessionTicket;
767 767
768 /* SNI Extension related data 768 /* SNI Extension related data
769 * Names data is not coppied from the input buffer. It can not be 769 * Names data is not coppied from the input buffer. It can not be
770 * used outside the scope where input buffer is defined and that 770 * used outside the scope where input buffer is defined and that
771 * is beyond ssl3_HandleClientHello function. */ 771 * is beyond ssl3_HandleClientHello function. */
772 SECItem *sniNameArr; 772 SECItem *sniNameArr;
773 PRUint32 sniNameArrSize; 773 PRUint32 sniNameArrSize;
774 }; 774 };
775 775
776 typedef enum { 776 typedef SECStatus (*sslRestartTarget)(sslSocket *);
777 cached_info_certificate_chain = 1,
778 cached_info_trusted_cas = 2
779 } TLSCachedInfoType;
780 777
781 /* 778 /*
782 ** This is the "hs" member of the "ssl3" struct. 779 ** This is the "hs" member of the "ssl3" struct.
783 ** This entire struct is protected by ssl3HandshakeLock 780 ** This entire struct is protected by ssl3HandshakeLock
784 */ 781 */
785 typedef struct SSL3HandshakeStateStr { 782 typedef struct SSL3HandshakeStateStr {
786 SSL3Random server_random; 783 SSL3Random server_random;
787 SSL3Random client_random; 784 SSL3Random client_random;
788 SSL3WaitState ws; 785 SSL3WaitState ws;
789 PRUint64 md5_cx[MAX_MAC_CONTEXT_LLONGS]; 786 PRUint64 md5_cx[MAX_MAC_CONTEXT_LLONGS];
790 PRUint64 sha_cx[MAX_MAC_CONTEXT_LLONGS]; 787 PRUint64 sha_cx[MAX_MAC_CONTEXT_LLONGS];
791 PK11Context * md5; /* handshake running hashes */ 788 PK11Context * md5; /* handshake running hashes */
792 PK11Context * sha; 789 PK11Context * sha;
793 const ssl3KEADef * kea_def; 790 const ssl3KEADef * kea_def;
794 ssl3CipherSuite cipher_suite; 791 ssl3CipherSuite cipher_suite;
795 const ssl3CipherSuiteDef *suite_def; 792 const ssl3CipherSuiteDef *suite_def;
796 SSLCompressionMethod compression; 793 SSLCompressionMethod compression;
797 sslBuffer msg_body; /* protected by recvBufLock */ 794 sslBuffer msg_body; /* protected by recvBufLock */
798 /* partial handshake message from record layer */ 795 /* partial handshake message from record layer */
799 unsigned int header_bytes; 796 unsigned int header_bytes;
800 /* number of bytes consumed from handshake */ 797 /* number of bytes consumed from handshake */
801 /* message for message type and header length */ 798 /* message for message type and header length */
802 SSL3HandshakeType msg_type; 799 SSL3HandshakeType msg_type;
803 unsigned long msg_len; 800 unsigned long msg_len;
804 SECItem ca_list; /* used only by client */ 801 SECItem ca_list; /* used only by client */
805 PRBool isResuming; /* are we resuming a session */ 802 PRBool isResuming; /* are we resuming a session */
806 PRBool rehandshake; /* immediately start another handshake
807 * when this one finishes */
808 PRBool usedStepDownKey; /* we did a server key exchange. */ 803 PRBool usedStepDownKey; /* we did a server key exchange. */
809 PRBool sendingSCSV; /* instead of empty RI */ 804 PRBool sendingSCSV; /* instead of empty RI */
810 PRBool may_get_cert_status; /* the server echoed a 805 PRBool may_get_cert_status; /* the server echoed a
811 * status_request extension so 806 * status_request extension so
812 * may send a CertificateStatus 807 * may send a CertificateStatus
813 * handshake message. */ 808 * handshake message. */
814 SECItem pending_cert_msg; /* a Certificate message which we 809 SECItem pending_cert_msg; /* a Certificate message which we
815 * save temporarily if we may get 810 * save temporarily if we may get
816 * a CertificateStatus message */ 811 * a CertificateStatus message */
817 SECItem cert_status; /* an OCSP response */ 812 SECItem cert_status; /* an OCSP response */
818 sslBuffer msgState; /* current state for handshake messages*/ 813 sslBuffer msgState; /* current state for handshake messages*/
819 /* protected by recvBufLock */ 814 /* protected by recvBufLock */
820 sslBuffer messages; /* Accumulated handshake messages */ 815 sslBuffer messages; /* Accumulated handshake messages */
821 PRUint16 finishedBytes; /* size of single finished below */ 816 PRUint16 finishedBytes; /* size of single finished below */
822 union { 817 union {
823 TLSFinished tFinished[2]; /* client, then server */ 818 TLSFinished tFinished[2]; /* client, then server */
824 SSL3Hashes sFinished[2]; 819 SSL3Hashes sFinished[2];
825 SSL3Opaque data[72]; 820 SSL3Opaque data[72];
826 } finishedMsgs; 821 } finishedMsgs;
827 #ifdef NSS_ENABLE_ECC 822 #ifdef NSS_ENABLE_ECC
828 PRUint32 negotiatedECCurves; /* bit mask */ 823 PRUint32 negotiatedECCurves; /* bit mask */
829 #endif /* NSS_ENABLE_ECC */ 824 #endif /* NSS_ENABLE_ECC */
825
826 PRBool authCertificatePending;
827 /* Which function should SSL_RestartHandshake* call if we're blocked?
828 * One of NULL, ssl3_SendClientSecondRound, ssl3_FinishHandshake,
829 * or ssl3_AlwaysFail */
830 sslRestartTarget restartTarget;
831 /* Shared state between ssl3_HandleFinished and ssl3_FinishHandshake */
832 PRBool cacheSID;
830 } SSL3HandshakeState; 833 } SSL3HandshakeState;
831 834
832 835
833 836
834 /* 837 /*
835 ** This is the "ssl3" struct, as in "ss->ssl3". 838 ** This is the "ssl3" struct, as in "ss->ssl3".
836 ** note: 839 ** note:
837 ** usually, crSpec == cwSpec and prSpec == pwSpec. 840 ** usually, crSpec == cwSpec and prSpec == pwSpec.
838 ** Sometimes, crSpec == pwSpec and prSpec == cwSpec. 841 ** Sometimes, crSpec == pwSpec and prSpec == cwSpec.
839 ** But there are never more than 2 actual specs. 842 ** But there are never more than 2 actual specs.
(...skipping 12 matching lines...) Expand all
852 855
853 CERTCertificate * clientCertificate; /* used by client */ 856 CERTCertificate * clientCertificate; /* used by client */
854 SECKEYPrivateKey * clientPrivateKey; /* used by client */ 857 SECKEYPrivateKey * clientPrivateKey; /* used by client */
855 /* platformClientKey is present even when NSS_PLATFORM_CLIENT_AUTH is not 858 /* platformClientKey is present even when NSS_PLATFORM_CLIENT_AUTH is not
856 * defined in order to allow cleaner conditional code. 859 * defined in order to allow cleaner conditional code.
857 * At most one of clientPrivateKey and platformClientKey may be set. */ 860 * At most one of clientPrivateKey and platformClientKey may be set. */
858 PlatformKey platformClientKey; /* used by client */ 861 PlatformKey platformClientKey; /* used by client */
859 CERTCertificateList *clientCertChain; /* used by client */ 862 CERTCertificateList *clientCertChain; /* used by client */
860 PRBool sendEmptyCert; /* used by client */ 863 PRBool sendEmptyCert; /* used by client */
861 864
862 /* TLS Cached Info Extension */
863 CERTCertificate ** predictedCertChain;
864 /* An array terminated with a NULL. */
865 PRUint8 certChainDigest[8];
866 /* Used in cached info extension. Stored in network
867 * byte order. */
868 PRBool cachedInfoCertChainDigestReceived;
869
870 int policy; 865 int policy;
871 /* This says what cipher suites we can do, and should 866 /* This says what cipher suites we can do, and should
872 * be either SSL_ALLOWED or SSL_RESTRICTED 867 * be either SSL_ALLOWED or SSL_RESTRICTED
873 */ 868 */
874 PRArenaPool * peerCertArena; 869 PRArenaPool * peerCertArena;
875 /* These are used to keep track of the peer CA */ 870 /* These are used to keep track of the peer CA */
876 void * peerCertChain; 871 void * peerCertChain;
877 » » » /* Chain while we are trying to validate it. This 872 » » » /* chain while we are trying to validate it. */
878 » » » * does not include the leaf cert. It is actually a
879 » » » * linked list of ssl3CertNode structs.
880 » » » */
881 CERTDistNames * ca_list; 873 CERTDistNames * ca_list;
882 /* used by server. trusted CAs for this socket. */ 874 /* used by server. trusted CAs for this socket. */
883 PRBool initialized; 875 PRBool initialized;
884 SSL3HandshakeState hs; 876 SSL3HandshakeState hs;
885 ssl3CipherSpec specs[2]; /* one is current, one is pending. */ 877 ssl3CipherSpec specs[2]; /* one is current, one is pending. */
886 878
887 /* In a client: if the server supports Next Protocol Negotiation, then 879 /* In a client: if the server supports Next Protocol Negotiation, then
888 * this is the protocol that was negotiated. 880 * this is the protocol that was negotiated.
889 * 881 */
890 * If the data pointer is non-NULL, then it is malloced data. */ 882 SECItem» » nextProto;
891 SECItem» » nextProto; 883 SSLNextProtoState nextProtoState;
892 int»» » nextProtoState; /* See NEXT_PROTO_* defines */
893 }; 884 };
894 885
895 typedef struct { 886 typedef struct {
896 SSL3ContentType type; 887 SSL3ContentType type;
897 SSL3ProtocolVersion version; 888 SSL3ProtocolVersion version;
898 sslBuffer * buf; 889 sslBuffer * buf;
899 } SSL3Ciphertext; 890 } SSL3Ciphertext;
900 891
901 struct ssl3KeyPairStr { 892 struct ssl3KeyPairStr {
902 SECKEYPrivateKey * privKey; 893 SECKEYPrivateKey * privKey;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 ** ssl_global_data_lock, which is a reader/writer lock. 1194 ** ssl_global_data_lock, which is a reader/writer lock.
1204 */ 1195 */
1205 extern NSSRWLock * ssl_global_data_lock; 1196 extern NSSRWLock * ssl_global_data_lock;
1206 extern char ssl_debug; 1197 extern char ssl_debug;
1207 extern char ssl_trace; 1198 extern char ssl_trace;
1208 extern FILE * ssl_trace_iob; 1199 extern FILE * ssl_trace_iob;
1209 extern FILE * ssl_keylog_iob; 1200 extern FILE * ssl_keylog_iob;
1210 extern CERTDistNames * ssl3_server_ca_list; 1201 extern CERTDistNames * ssl3_server_ca_list;
1211 extern PRUint32 ssl_sid_timeout; 1202 extern PRUint32 ssl_sid_timeout;
1212 extern PRUint32 ssl3_sid_timeout; 1203 extern PRUint32 ssl3_sid_timeout;
1213 extern PRBool ssl3_global_policy_some_restricted;
1214 1204
1215 extern const char * const ssl_cipherName[]; 1205 extern const char * const ssl_cipherName[];
1216 extern const char * const ssl3_cipherName[]; 1206 extern const char * const ssl3_cipherName[];
1217 1207
1218 extern sslSessionIDLookupFunc ssl_sid_lookup; 1208 extern sslSessionIDLookupFunc ssl_sid_lookup;
1219 extern sslSessionIDCacheFunc ssl_sid_cache; 1209 extern sslSessionIDCacheFunc ssl_sid_cache;
1220 extern sslSessionIDUncacheFunc ssl_sid_uncache; 1210 extern sslSessionIDUncacheFunc ssl_sid_uncache;
1221 1211
1222 /************************************************************************/ 1212 /************************************************************************/
1223 1213
1224 SEC_BEGIN_PROTOS 1214 SEC_BEGIN_PROTOS
1225 1215
1216 /* Internal initialization and installation of the SSL error tables */
1217 extern SECStatus ssl_Init(void);
1218 extern SECStatus ssl_InitializePRErrorTable(void);
1219
1226 /* Implementation of ops for default (non socks, non secure) case */ 1220 /* Implementation of ops for default (non socks, non secure) case */
1227 extern int ssl_DefConnect(sslSocket *ss, const PRNetAddr *addr); 1221 extern int ssl_DefConnect(sslSocket *ss, const PRNetAddr *addr);
1228 extern PRFileDesc *ssl_DefAccept(sslSocket *ss, PRNetAddr *addr); 1222 extern PRFileDesc *ssl_DefAccept(sslSocket *ss, PRNetAddr *addr);
1229 extern int ssl_DefBind(sslSocket *ss, const PRNetAddr *addr); 1223 extern int ssl_DefBind(sslSocket *ss, const PRNetAddr *addr);
1230 extern int ssl_DefListen(sslSocket *ss, int backlog); 1224 extern int ssl_DefListen(sslSocket *ss, int backlog);
1231 extern int ssl_DefShutdown(sslSocket *ss, int how); 1225 extern int ssl_DefShutdown(sslSocket *ss, int how);
1232 extern int ssl_DefClose(sslSocket *ss); 1226 extern int ssl_DefClose(sslSocket *ss);
1233 extern int ssl_DefRecv(sslSocket *ss, unsigned char *buf, int len, int flags); 1227 extern int ssl_DefRecv(sslSocket *ss, unsigned char *buf, int len, int flags);
1234 extern int ssl_DefSend(sslSocket *ss, const unsigned char *buf, 1228 extern int ssl_DefSend(sslSocket *ss, const unsigned char *buf,
1235 int len, int flags); 1229 int len, int flags);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 const char *peerID, const char *urlSvrName); 1307 const char *peerID, const char *urlSvrName);
1314 extern void ssl_FreeSID(sslSessionID *sid); 1308 extern void ssl_FreeSID(sslSessionID *sid);
1315 1309
1316 extern int ssl3_SendApplicationData(sslSocket *ss, const PRUint8 *in, 1310 extern int ssl3_SendApplicationData(sslSocket *ss, const PRUint8 *in,
1317 int len, int flags); 1311 int len, int flags);
1318 1312
1319 extern PRBool ssl_FdIsBlocking(PRFileDesc *fd); 1313 extern PRBool ssl_FdIsBlocking(PRFileDesc *fd);
1320 1314
1321 extern PRBool ssl_SocketIsBlocking(sslSocket *ss); 1315 extern PRBool ssl_SocketIsBlocking(sslSocket *ss);
1322 1316
1323 extern void ssl_SetAlwaysBlock(sslSocket *ss); 1317 extern void ssl3_SetAlwaysBlock(sslSocket *ss);
1324 1318
1325 extern SECStatus ssl_EnableNagleDelay(sslSocket *ss, PRBool enabled); 1319 extern SECStatus ssl_EnableNagleDelay(sslSocket *ss, PRBool enabled);
1326 1320
1327 extern PRBool ssl3_CanFalseStart(sslSocket *ss); 1321 extern PRBool ssl3_CanFalseStart(sslSocket *ss);
1328 1322
1329 #define SSL_LOCK_READER(ss) if (ss->recvLock) PZ_Lock(ss->recvLock) 1323 #define SSL_LOCK_READER(ss) if (ss->recvLock) PZ_Lock(ss->recvLock)
1330 #define SSL_UNLOCK_READER(ss) if (ss->recvLock) PZ_Unlock(ss->recvLock ) 1324 #define SSL_UNLOCK_READER(ss) if (ss->recvLock) PZ_Unlock(ss->recvLock )
1331 #define SSL_LOCK_WRITER(ss) if (ss->sendLock) PZ_Lock(ss->sendLock) 1325 #define SSL_LOCK_WRITER(ss) if (ss->sendLock) PZ_Lock(ss->sendLock)
1332 #define SSL_UNLOCK_WRITER(ss) if (ss->sendLock) PZ_Unlock(ss->sendLock ) 1326 #define SSL_UNLOCK_WRITER(ss) if (ss->sendLock) PZ_Unlock(ss->sendLock )
1333 1327
1328 /* firstHandshakeLock -> recvBufLock */
1334 #define ssl_Get1stHandshakeLock(ss) \ 1329 #define ssl_Get1stHandshakeLock(ss) \
1335 { if (!ss->opt.noLocks) PZ_EnterMonitor((ss)->firstHandshakeLock); } 1330 { if (!ss->opt.noLocks) { \
1331 » PORT_Assert(PZ_InMonitor((ss)->firstHandshakeLock) || \
1332 » » !ssl_HaveRecvBufLock(ss)); \
1333 » PZ_EnterMonitor((ss)->firstHandshakeLock); \
1334 } }
1336 #define ssl_Release1stHandshakeLock(ss) \ 1335 #define ssl_Release1stHandshakeLock(ss) \
1337 { if (!ss->opt.noLocks) PZ_ExitMonitor((ss)->firstHandshakeLock); } 1336 { if (!ss->opt.noLocks) PZ_ExitMonitor((ss)->firstHandshakeLock); }
1338 #define ssl_Have1stHandshakeLock(ss) \ 1337 #define ssl_Have1stHandshakeLock(ss) \
1339 (PZ_InMonitor((ss)->firstHandshakeLock)) 1338 (PZ_InMonitor((ss)->firstHandshakeLock))
1340 1339
1340 /* ssl3HandshakeLock -> xmitBufLock */
1341 #define ssl_GetSSL3HandshakeLock(ss) \ 1341 #define ssl_GetSSL3HandshakeLock(ss) \
1342 { if (!ss->opt.noLocks) PZ_EnterMonitor((ss)->ssl3HandshakeLock); } 1342 { if (!ss->opt.noLocks) { \
1343 » PORT_Assert(!ssl_HaveXmitBufLock(ss)); \
1344 » PZ_EnterMonitor((ss)->ssl3HandshakeLock); \
1345 } }
1343 #define ssl_ReleaseSSL3HandshakeLock(ss) \ 1346 #define ssl_ReleaseSSL3HandshakeLock(ss) \
1344 { if (!ss->opt.noLocks) PZ_ExitMonitor((ss)->ssl3HandshakeLock); } 1347 { if (!ss->opt.noLocks) PZ_ExitMonitor((ss)->ssl3HandshakeLock); }
1345 #define ssl_HaveSSL3HandshakeLock(ss) \ 1348 #define ssl_HaveSSL3HandshakeLock(ss) \
1346 (PZ_InMonitor((ss)->ssl3HandshakeLock)) 1349 (PZ_InMonitor((ss)->ssl3HandshakeLock))
1347 1350
1348 #define ssl_GetSpecReadLock(ss) \ 1351 #define ssl_GetSpecReadLock(ss) \
1349 { if (!ss->opt.noLocks) NSSRWLock_LockRead((ss)->specLock); } 1352 { if (!ss->opt.noLocks) NSSRWLock_LockRead((ss)->specLock); }
1350 #define ssl_ReleaseSpecReadLock(ss) \ 1353 #define ssl_ReleaseSpecReadLock(ss) \
1351 { if (!ss->opt.noLocks) NSSRWLock_UnlockRead((ss)->specLock); } 1354 { if (!ss->opt.noLocks) NSSRWLock_UnlockRead((ss)->specLock); }
1355 /* NSSRWLock_HaveReadLock is not exported so there's no
1356 * ssl_HaveSpecReadLock macro. */
1352 1357
1353 #define ssl_GetSpecWriteLock(ss) \ 1358 #define ssl_GetSpecWriteLock(ss) \
1354 { if (!ss->opt.noLocks) NSSRWLock_LockWrite((ss)->specLock); } 1359 { if (!ss->opt.noLocks) NSSRWLock_LockWrite((ss)->specLock); }
1355 #define ssl_ReleaseSpecWriteLock(ss) \ 1360 #define ssl_ReleaseSpecWriteLock(ss) \
1356 { if (!ss->opt.noLocks) NSSRWLock_UnlockWrite((ss)->specLock); } 1361 { if (!ss->opt.noLocks) NSSRWLock_UnlockWrite((ss)->specLock); }
1357 #define ssl_HaveSpecWriteLock(ss) \ 1362 #define ssl_HaveSpecWriteLock(ss) \
1358 (NSSRWLock_HaveWriteLock((ss)->specLock)) 1363 (NSSRWLock_HaveWriteLock((ss)->specLock))
1359 1364
1365 /* recvBufLock -> ssl3HandshakeLock -> xmitBufLock */
1360 #define ssl_GetRecvBufLock(ss) \ 1366 #define ssl_GetRecvBufLock(ss) \
1361 { if (!ss->opt.noLocks) PZ_EnterMonitor((ss)->recvBufLock); } 1367 { if (!ss->opt.noLocks) { \
1368 » PORT_Assert(!ssl_HaveSSL3HandshakeLock(ss)); \
1369 » PORT_Assert(!ssl_HaveXmitBufLock(ss)); \
1370 » PZ_EnterMonitor((ss)->recvBufLock); \
1371 } }
1362 #define ssl_ReleaseRecvBufLock(ss) \ 1372 #define ssl_ReleaseRecvBufLock(ss) \
1363 { if (!ss->opt.noLocks) PZ_ExitMonitor( (ss)->recvBufLock); } 1373 { if (!ss->opt.noLocks) PZ_ExitMonitor( (ss)->recvBufLock); }
1364 #define ssl_HaveRecvBufLock(ss) \ 1374 #define ssl_HaveRecvBufLock(ss) \
1365 (PZ_InMonitor((ss)->recvBufLock)) 1375 (PZ_InMonitor((ss)->recvBufLock))
1366 1376
1377 /* xmitBufLock -> specLock */
1367 #define ssl_GetXmitBufLock(ss) \ 1378 #define ssl_GetXmitBufLock(ss) \
1368 { if (!ss->opt.noLocks) PZ_EnterMonitor((ss)->xmitBufLock); } 1379 { if (!ss->opt.noLocks) PZ_EnterMonitor((ss)->xmitBufLock); }
1369 #define ssl_ReleaseXmitBufLock(ss) \ 1380 #define ssl_ReleaseXmitBufLock(ss) \
1370 { if (!ss->opt.noLocks) PZ_ExitMonitor( (ss)->xmitBufLock); } 1381 { if (!ss->opt.noLocks) PZ_ExitMonitor( (ss)->xmitBufLock); }
1371 #define ssl_HaveXmitBufLock(ss) \ 1382 #define ssl_HaveXmitBufLock(ss) \
1372 (PZ_InMonitor((ss)->xmitBufLock)) 1383 (PZ_InMonitor((ss)->xmitBufLock))
1373 1384
1374 1385
1375 extern SECStatus ssl3_KeyAndMacDeriveBypass(ssl3CipherSpec * pwSpec, 1386 extern SECStatus ssl3_KeyAndMacDeriveBypass(ssl3CipherSpec * pwSpec,
1376 const unsigned char * cr, const unsigned char * sr, 1387 const unsigned char * cr, const unsigned char * sr,
1377 PRBool isTLS, PRBool isExport); 1388 PRBool isTLS, PRBool isExport);
1378 extern SECStatus ssl3_MasterKeyDeriveBypass( ssl3CipherSpec * pwSpec, 1389 extern SECStatus ssl3_MasterKeyDeriveBypass( ssl3CipherSpec * pwSpec,
1379 const unsigned char * cr, const unsigned char * sr, 1390 const unsigned char * cr, const unsigned char * sr,
1380 const SECItem * pms, PRBool isTLS, PRBool isRSA); 1391 const SECItem * pms, PRBool isTLS, PRBool isRSA);
1381 1392
1382 /* These functions are called from secnav, even though they're "private". */ 1393 /* These functions are called from secnav, even though they're "private". */
1383 1394
1384 extern int ssl2_SendErrorMessage(struct sslSocketStr *ss, int error); 1395 extern int ssl2_SendErrorMessage(struct sslSocketStr *ss, int error);
1385 extern int SSL_RestartHandshakeAfterServerCert(struct sslSocketStr *ss);
1386 extern sslSocket *ssl_FindSocket(PRFileDesc *fd); 1396 extern sslSocket *ssl_FindSocket(PRFileDesc *fd);
1387 extern void ssl_FreeSocket(struct sslSocketStr *ssl); 1397 extern void ssl_FreeSocket(struct sslSocketStr *ssl);
1388 extern SECStatus SSL3_SendAlert(sslSocket *ss, SSL3AlertLevel level, 1398 extern SECStatus SSL3_SendAlert(sslSocket *ss, SSL3AlertLevel level,
1389 SSL3AlertDescription desc); 1399 SSL3AlertDescription desc);
1390 1400
1391 extern int ssl2_RestartHandshakeAfterCertReq(sslSocket * ss,
1392 CERTCertificate * cert,
1393 SECKEYPrivateKey * key);
1394
1395 extern SECStatus ssl3_RestartHandshakeAfterCertReq(sslSocket * ss, 1401 extern SECStatus ssl3_RestartHandshakeAfterCertReq(sslSocket * ss,
1396 CERTCertificate * cert, 1402 CERTCertificate * cert,
1397 SECKEYPrivateKey * key, 1403 SECKEYPrivateKey * key,
1398 CERTCertificateList *certChain); 1404 CERTCertificateList *certChain);
1399 1405
1400 extern int ssl2_RestartHandshakeAfterServerCert(sslSocket *ss); 1406 extern SECStatus ssl3_AuthCertificateComplete(sslSocket *ss, PRErrorCode error);
1401 extern int ssl3_RestartHandshakeAfterServerCert(sslSocket *ss);
1402 1407
1403 /* 1408 /*
1404 * for dealing with SSL 3.0 clients sending SSL 2.0 format hellos 1409 * for dealing with SSL 3.0 clients sending SSL 2.0 format hellos
1405 */ 1410 */
1406 extern SECStatus ssl3_HandleV2ClientHello( 1411 extern SECStatus ssl3_HandleV2ClientHello(
1407 sslSocket *ss, unsigned char *buffer, int length); 1412 sslSocket *ss, unsigned char *buffer, int length);
1408 extern SECStatus ssl3_StartHandshakeHash( 1413 extern SECStatus ssl3_StartHandshakeHash(
1409 sslSocket *ss, unsigned char *buf, int length); 1414 sslSocket *ss, unsigned char *buf, int length);
1410 1415
1411 /* 1416 /*
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 1561
1557 /* Functions that handle ClientHello and ServerHello extensions. */ 1562 /* Functions that handle ClientHello and ServerHello extensions. */
1558 extern SECStatus ssl3_HandleServerNameXtn(sslSocket * ss, 1563 extern SECStatus ssl3_HandleServerNameXtn(sslSocket * ss,
1559 PRUint16 ex_type, SECItem *data); 1564 PRUint16 ex_type, SECItem *data);
1560 extern SECStatus ssl3_HandleSupportedCurvesXtn(sslSocket * ss, 1565 extern SECStatus ssl3_HandleSupportedCurvesXtn(sslSocket * ss,
1561 PRUint16 ex_type, SECItem *data); 1566 PRUint16 ex_type, SECItem *data);
1562 extern SECStatus ssl3_HandleSupportedPointFormatsXtn(sslSocket * ss, 1567 extern SECStatus ssl3_HandleSupportedPointFormatsXtn(sslSocket * ss,
1563 PRUint16 ex_type, SECItem *data); 1568 PRUint16 ex_type, SECItem *data);
1564 extern SECStatus ssl3_ClientHandleSessionTicketXtn(sslSocket *ss, 1569 extern SECStatus ssl3_ClientHandleSessionTicketXtn(sslSocket *ss,
1565 PRUint16 ex_type, SECItem *data); 1570 PRUint16 ex_type, SECItem *data);
1566 extern SECStatus ssl3_ClientHandleNextProtoNegoXtn(sslSocket *ss,
1567 PRUint16 ex_type, SECItem *data);
1568 extern SECStatus ssl3_ServerHandleCachedInfoXtn(sslSocket *ss,
1569 PRUint16 ex_type, SECItem *data);
1570 extern SECStatus ssl3_ClientHandleCachedInfoXtn(sslSocket *ss,
1571 PRUint16 ex_type, SECItem *data);
1572 extern SECStatus ssl3_ClientHandleStatusRequestXtn(sslSocket *ss, 1571 extern SECStatus ssl3_ClientHandleStatusRequestXtn(sslSocket *ss,
1573 PRUint16 ex_type, SECItem *data); 1572 PRUint16 ex_type, SECItem *data);
1574 extern SECStatus ssl3_ClientHandleOBCertXtn(sslSocket *ss, 1573 extern SECStatus ssl3_ClientHandleOBCertXtn(sslSocket *ss,
1575 PRUint16 ex_type, SECItem *data); 1574 PRUint16 ex_type, SECItem *data);
1576 extern SECStatus ssl3_ServerHandleSessionTicketXtn(sslSocket *ss, 1575 extern SECStatus ssl3_ServerHandleSessionTicketXtn(sslSocket *ss,
1577 PRUint16 ex_type, SECItem *data); 1576 PRUint16 ex_type, SECItem *data);
1578 extern SECStatus ssl3_ServerHandleNextProtoNegoXtn(sslSocket *ss,
1579 PRUint16 ex_type, SECItem *data);
1580 extern SECStatus ssl3_ServerHandleOBCertXtn(sslSocket *ss, 1577 extern SECStatus ssl3_ServerHandleOBCertXtn(sslSocket *ss,
1581 PRUint16 ex_type, SECItem *data); 1578 PRUint16 ex_type, SECItem *data);
1582 1579
1583 /* ClientHello and ServerHello extension senders. 1580 /* ClientHello and ServerHello extension senders.
1584 * Note that not all extension senders are exposed here; only those that 1581 * Note that not all extension senders are exposed here; only those that
1585 * that need exposure. 1582 * that need exposure.
1586 */ 1583 */
1587 extern PRInt32 ssl3_SendSessionTicketXtn(sslSocket *ss, PRBool append, 1584 extern PRInt32 ssl3_SendSessionTicketXtn(sslSocket *ss, PRBool append,
1588 PRUint32 maxBytes); 1585 PRUint32 maxBytes);
1589 extern PRInt32 ssl3_ClientSendStatusRequestXtn(sslSocket *ss, PRBool append, 1586 extern PRInt32 ssl3_ClientSendStatusRequestXtn(sslSocket *ss, PRBool append,
1590 PRUint32 maxBytes); 1587 PRUint32 maxBytes);
1591 1588
1592 /* ClientHello and ServerHello extension senders. 1589 /* ClientHello and ServerHello extension senders.
1593 * The code is in ssl3ext.c. 1590 * The code is in ssl3ext.c.
1594 */ 1591 */
1595 extern PRInt32 ssl3_SendServerNameXtn(sslSocket *ss, PRBool append, 1592 extern PRInt32 ssl3_SendServerNameXtn(sslSocket *ss, PRBool append,
1596 PRUint32 maxBytes); 1593 PRUint32 maxBytes);
1597 extern PRInt32 ssl3_ClientSendCachedInfoXtn(sslSocket *ss, PRBool append,
1598 PRUint32 maxBytes);
1599 extern PRInt32 ssl3_ServerSendCachedInfoXtn(sslSocket *ss, PRBool append,
1600 PRUint32 maxBytes);
1601 extern PRInt32 ssl3_SendOBCertXtn(sslSocket *ss, PRBool append, 1594 extern PRInt32 ssl3_SendOBCertXtn(sslSocket *ss, PRBool append,
1602 PRUint32 maxBytes); 1595 PRUint32 maxBytes);
1603 1596
1604 /* Assigns new cert, cert chain and keys to ss->serverCerts 1597 /* Assigns new cert, cert chain and keys to ss->serverCerts
1605 * struct. If certChain is NULL, tries to find one. Aborts if 1598 * struct. If certChain is NULL, tries to find one. Aborts if
1606 * fails to do so. If cert and keyPair are NULL - unconfigures 1599 * fails to do so. If cert and keyPair are NULL - unconfigures
1607 * sslSocket of kea type.*/ 1600 * sslSocket of kea type.*/
1608 extern SECStatus ssl_ConfigSecureServer(sslSocket *ss, CERTCertificate *cert, 1601 extern SECStatus ssl_ConfigSecureServer(sslSocket *ss, CERTCertificate *cert,
1609 CERTCertificateList *certChain, 1602 const CERTCertificateList *certChain,
1610 ssl3KeyPair *keyPair, SSLKEAType kea); 1603 ssl3KeyPair *keyPair, SSLKEAType kea);
1611 /* Return key type for the cert */ 1604 /* Return key type for the cert */
1612 extern SSLKEAType ssl_FindCertKEAType(CERTCertificate * cert); 1605 extern SSLKEAType ssl_FindCertKEAType(CERTCertificate * cert);
1613 1606
1614 #ifdef NSS_ENABLE_ECC 1607 #ifdef NSS_ENABLE_ECC
1615 extern PRInt32 ssl3_SendSupportedCurvesXtn(sslSocket *ss, 1608 extern PRInt32 ssl3_SendSupportedCurvesXtn(sslSocket *ss,
1616 PRBool append, PRUint32 maxBytes); 1609 PRBool append, PRUint32 maxBytes);
1617 extern PRInt32 ssl3_SendSupportedPointFormatsXtn(sslSocket *ss, 1610 extern PRInt32 ssl3_SendSupportedPointFormatsXtn(sslSocket *ss,
1618 PRBool append, PRUint32 maxBytes); 1611 PRBool append, PRUint32 maxBytes);
1619 #endif 1612 #endif
1620 extern PRInt32 ssl3_ClientSendNextProtoNegoXtn(sslSocket *ss, PRBool append,
1621 PRUint32 maxBytes);
1622 extern SECStatus ssl3_ValidateNextProtoNego(const unsigned char* data,
1623 unsigned short length);
1624 1613
1625 /* call the registered extension handlers. */ 1614 /* call the registered extension handlers. */
1626 extern SECStatus ssl3_HandleHelloExtensions(sslSocket *ss, 1615 extern SECStatus ssl3_HandleHelloExtensions(sslSocket *ss,
1627 SSL3Opaque **b, PRUint32 *length); 1616 SSL3Opaque **b, PRUint32 *length);
1628 1617
1629 /* Hello Extension related routines. */ 1618 /* Hello Extension related routines. */
1630 extern PRBool ssl3_ExtensionNegotiated(sslSocket *ss, PRUint16 ex_type); 1619 extern PRBool ssl3_ExtensionNegotiated(sslSocket *ss, PRUint16 ex_type);
1631 extern SECStatus ssl3_SetSIDSessionTicket(sslSessionID *sid, 1620 extern SECStatus ssl3_SetSIDSessionTicket(sslSessionID *sid,
1632 NewSessionTicket *session_ticket); 1621 NewSessionTicket *session_ticket);
1633 extern SECStatus ssl3_SendNewSessionTicket(sslSocket *ss); 1622 extern SECStatus ssl3_SendNewSessionTicket(sslSocket *ss);
1634 extern PRBool ssl_GetSessionTicketKeys(unsigned char *keyName, 1623 extern PRBool ssl_GetSessionTicketKeys(unsigned char *keyName,
1635 unsigned char *encKey, unsigned char *macKey); 1624 unsigned char *encKey, unsigned char *macKey);
1636 extern PRBool ssl_GetSessionTicketKeysPKCS11(SECKEYPrivateKey *svrPrivKey, 1625 extern PRBool ssl_GetSessionTicketKeysPKCS11(SECKEYPrivateKey *svrPrivKey,
1637 SECKEYPublicKey *svrPubKey, void *pwArg, 1626 SECKEYPublicKey *svrPubKey, void *pwArg,
1638 unsigned char *keyName, PK11SymKey **aesKey, 1627 unsigned char *keyName, PK11SymKey **aesKey,
1639 PK11SymKey **macKey); 1628 PK11SymKey **macKey);
1640 1629
1641 /* Tell clients to consider tickets valid for this long. */ 1630 /* Tell clients to consider tickets valid for this long. */
1642 #define TLS_EX_SESS_TICKET_LIFETIME_HINT (2 * 24 * 60 * 60) /* 2 days */ 1631 #define TLS_EX_SESS_TICKET_LIFETIME_HINT (2 * 24 * 60 * 60) /* 2 days */
1643 #define TLS_EX_SESS_TICKET_VERSION (0x0100) 1632 #define TLS_EX_SESS_TICKET_VERSION (0x0100)
1644 1633
1634 extern SECStatus ssl3_ValidateNextProtoNego(const unsigned char* data,
1635 unsigned int length);
1636
1645 /* Construct a new NSPR socket for the app to use */ 1637 /* Construct a new NSPR socket for the app to use */
1646 extern PRFileDesc *ssl_NewPRSocket(sslSocket *ss, PRFileDesc *fd); 1638 extern PRFileDesc *ssl_NewPRSocket(sslSocket *ss, PRFileDesc *fd);
1647 extern void ssl_FreePRSocket(PRFileDesc *fd); 1639 extern void ssl_FreePRSocket(PRFileDesc *fd);
1648 1640
1649 /* Internal config function so SSL2 can initialize the present state of 1641 /* Internal config function so SSL2 can initialize the present state of
1650 * various ciphers */ 1642 * various ciphers */
1651 extern int ssl3_config_match_init(sslSocket *); 1643 extern int ssl3_config_match_init(sslSocket *);
1652 1644
1653 1645
1654 /* Create a new ref counted key pair object from two keys. */ 1646 /* Create a new ref counted key pair object from two keys. */
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 SECStatus SSL_DisableDefaultExportCipherSuites(void); 1714 SECStatus SSL_DisableDefaultExportCipherSuites(void);
1723 SECStatus SSL_DisableExportCipherSuites(PRFileDesc * fd); 1715 SECStatus SSL_DisableExportCipherSuites(PRFileDesc * fd);
1724 PRBool SSL_IsExportCipherSuite(PRUint16 cipherSuite); 1716 PRBool SSL_IsExportCipherSuite(PRUint16 cipherSuite);
1725 1717
1726 SECStatus ssl3_TLSPRFWithMasterSecret( 1718 SECStatus ssl3_TLSPRFWithMasterSecret(
1727 ssl3CipherSpec *spec, const char *label, 1719 ssl3CipherSpec *spec, const char *label,
1728 unsigned int labelLen, const unsigned char *val, 1720 unsigned int labelLen, const unsigned char *val,
1729 unsigned int valLen, unsigned char *out, 1721 unsigned int valLen, unsigned char *out,
1730 unsigned int outLen); 1722 unsigned int outLen);
1731 1723
1732 /********************** FNV hash *********************/
1733
1734 void FNV1A64_Init(PRUint64 *digest);
1735 void FNV1A64_Update(PRUint64 *digest, const unsigned char *data,
1736 unsigned int length);
1737 void FNV1A64_Final(PRUint64 *digest);
1738
1739 #ifdef TRACE 1724 #ifdef TRACE
1740 #define SSL_TRACE(msg) ssl_Trace msg 1725 #define SSL_TRACE(msg) ssl_Trace msg
1741 #else 1726 #else
1742 #define SSL_TRACE(msg) 1727 #define SSL_TRACE(msg)
1743 #endif 1728 #endif
1744 1729
1745 void ssl_Trace(const char *format, ...); 1730 void ssl_Trace(const char *format, ...);
1746 1731
1747 SEC_END_PROTOS 1732 SEC_END_PROTOS
1748 1733
1749 #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS) 1734 #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
1750 #define SSL_GETPID getpid 1735 #define SSL_GETPID getpid
1751 #elif defined(_WIN32_WCE) 1736 #elif defined(_WIN32_WCE)
1752 #define SSL_GETPID GetCurrentProcessId 1737 #define SSL_GETPID GetCurrentProcessId
1753 #elif defined(WIN32) 1738 #elif defined(WIN32)
1754 extern int __cdecl _getpid(void); 1739 extern int __cdecl _getpid(void);
1755 #define SSL_GETPID _getpid 1740 #define SSL_GETPID _getpid
1756 #else 1741 #else
1757 #define SSL_GETPID() 0 1742 #define SSL_GETPID() 0
1758 #endif 1743 #endif
1759 1744
1760 #endif /* __sslimpl_h_ */ 1745 #endif /* __sslimpl_h_ */
OLDNEW
« no previous file with comments | « net/third_party/nss/ssl/sslerrstrs.c ('k') | net/third_party/nss/ssl/sslinfo.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698