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

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

Issue 111853013: Update net/third_party/nss to NSS 3.15.4. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Update the comment in sslenum.c for the two CHACHA20 cipher suites Created 6 years, 11 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/sslenum.c ('k') | net/third_party/nss/ssl/sslinit.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 * 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 8
9 #ifndef __sslimpl_h_ 9 #ifndef __sslimpl_h_
10 #define __sslimpl_h_ 10 #define __sslimpl_h_
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 611
612 typedef enum { never_cached, 612 typedef enum { never_cached,
613 in_client_cache, 613 in_client_cache,
614 in_server_cache, 614 in_server_cache,
615 invalid_cache /* no longer in any cache. */ 615 invalid_cache /* no longer in any cache. */
616 } Cached; 616 } Cached;
617 617
618 #define MAX_PEER_CERT_CHAIN_SIZE 8 618 #define MAX_PEER_CERT_CHAIN_SIZE 8
619 619
620 struct sslSessionIDStr { 620 struct sslSessionIDStr {
621 /* The global cache lock must be held when accessing these members when the
622 * sid is in any cache.
623 */
621 sslSessionID * next; /* chain used for client sockets, only */ 624 sslSessionID * next; /* chain used for client sockets, only */
625 Cached cached;
626 int references;
627 PRUint32 lastAccessTime; /* seconds since Jan 1, 1970 */
628
629 /* The rest of the members, except for the members of u.ssl3.locked, may
630 * be modified only when the sid is not in any cache.
631 */
622 632
623 CERTCertificate * peerCert; 633 CERTCertificate * peerCert;
624 CERTCertificate * peerCertChain[MAX_PEER_CERT_CHAIN_SIZE]; 634 CERTCertificate * peerCertChain[MAX_PEER_CERT_CHAIN_SIZE];
625 SECItemArray peerCertStatus; /* client only */ 635 SECItemArray peerCertStatus; /* client only */
626 const char * peerID; /* client only */ 636 const char * peerID; /* client only */
627 const char * urlSvrName; /* client only */ 637 const char * urlSvrName; /* client only */
628 CERTCertificate * localCert; 638 CERTCertificate * localCert;
629 639
630 PRIPv6Addr addr; 640 PRIPv6Addr addr;
631 PRUint16 port; 641 PRUint16 port;
632 642
633 SSL3ProtocolVersion version; 643 SSL3ProtocolVersion version;
634 644
635 PRUint32 creationTime; /* seconds since Jan 1, 1970 */ 645 PRUint32 creationTime; /* seconds since Jan 1, 1970 */
636 PRUint32 lastAccessTime; /* seconds since Jan 1, 1970 */
637 PRUint32 expirationTime; /* seconds since Jan 1, 1970 */ 646 PRUint32 expirationTime; /* seconds since Jan 1, 1970 */
638 Cached cached;
639 int references;
640 647
641 SSLSignType authAlgorithm; 648 SSLSignType authAlgorithm;
642 PRUint32 authKeyBits; 649 PRUint32 authKeyBits;
643 SSLKEAType keaType; 650 SSLKEAType keaType;
644 PRUint32 keaKeyBits; 651 PRUint32 keaKeyBits;
645 652
646 union { 653 union {
647 struct { 654 struct {
648 /* the V2 code depends upon the size of sessionID. */ 655 /* the V2 code depends upon the size of sessionID. */
649 unsigned char sessionID[SSL2_SESSIONID_BYTES]; 656 unsigned char sessionID[SSL2_SESSIONID_BYTES];
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 /* The following values pertain to the slot that did the signature 702 /* The following values pertain to the slot that did the signature
696 ** for client auth. (used only in client) 703 ** for client auth. (used only in client)
697 */ 704 */
698 SECMODModuleID clAuthModuleID; 705 SECMODModuleID clAuthModuleID;
699 CK_SLOT_ID clAuthSlotID; 706 CK_SLOT_ID clAuthSlotID;
700 PRUint16 clAuthSeries; 707 PRUint16 clAuthSeries;
701 708
702 char masterValid; 709 char masterValid;
703 char clAuthValid; 710 char clAuthValid;
704 711
705 » /* Session ticket if we have one, is sent as an extension in the 712 » SECItem srvName;
706 » * ClientHello message. This field is used by clients.
707 » */
708 » NewSessionTicket sessionTicket;
709 SECItem srvName;
710 713
711 /* originalHandshakeHash contains the hash of the original, full 714 /* originalHandshakeHash contains the hash of the original, full
712 * handshake prior to the server's final flow. This is either a 715 * handshake prior to the server's final flow. This is either a
713 * SHA-1/MD5 combination (for TLS < 1.2) or the TLS PRF hash (for 716 * SHA-1/MD5 combination (for TLS < 1.2) or the TLS PRF hash (for
714 * TLS 1.2). This is recorded and used only when ChannelID is 717 * TLS 1.2). This is recorded and used only when ChannelID is
715 * negotiated as it's used to bind the ChannelID signature on the 718 * negotiated as it's used to bind the ChannelID signature on the
716 * resumption handshake to the original handshake. */ 719 * resumption handshake to the original handshake. */
717 SECItem originalHandshakeHash; 720 SECItem originalHandshakeHash;
718 721
719 /* Signed certificate timestamps received in a TLS extension. 722 /* Signed certificate timestamps received in a TLS extension.
720 ** (used only in client). 723 ** (used only in client).
721 */ 724 */
722 SECItem signedCertTimestamps; 725 SECItem signedCertTimestamps;
726
727 /* This lock is lazily initialized by CacheSID when a sid is first
728 * cached. Before then, there is no need to lock anything because
729 * the sid isn't being shared by anything.
730 */
731 PRRWLock *lock;
732
733 /* The lock must be held while reading or writing these members
734 * because they change while the sid is cached.
735 */
736 struct {
737 /* The session ticket, if we have one, is sent as an extension
738 * in the ClientHello message. This field is used only by
739 * clients. It is protected by lock when lock is non-null
740 * (after the sid has been added to the client session cache).
741 */
742 NewSessionTicket sessionTicket;
743 } locked;
723 } ssl3; 744 } ssl3;
724 } u; 745 } u;
725 }; 746 };
726 747
727
728 typedef struct ssl3CipherSuiteDefStr { 748 typedef struct ssl3CipherSuiteDefStr {
729 ssl3CipherSuite cipher_suite; 749 ssl3CipherSuite cipher_suite;
730 SSL3BulkCipher bulk_cipher_alg; 750 SSL3BulkCipher bulk_cipher_alg;
731 SSL3MACAlgorithm mac_alg; 751 SSL3MACAlgorithm mac_alg;
732 SSL3KeyExchangeAlgorithm key_exchange_alg; 752 SSL3KeyExchangeAlgorithm key_exchange_alg;
733 } ssl3CipherSuiteDef; 753 } ssl3CipherSuiteDef;
734 754
735 /* 755 /*
736 ** There are tables of these, all const. 756 ** There are tables of these, all const.
737 */ 757 */
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 ssl3HelloExtensionSender serverSenders[SSL_MAX_EXTENSIONS]; 817 ssl3HelloExtensionSender serverSenders[SSL_MAX_EXTENSIONS];
798 /* Keep track of the extensions that are negotiated. */ 818 /* Keep track of the extensions that are negotiated. */
799 PRUint16 numAdvertised; 819 PRUint16 numAdvertised;
800 PRUint16 numNegotiated; 820 PRUint16 numNegotiated;
801 PRUint16 advertised[SSL_MAX_EXTENSIONS]; 821 PRUint16 advertised[SSL_MAX_EXTENSIONS];
802 PRUint16 negotiated[SSL_MAX_EXTENSIONS]; 822 PRUint16 negotiated[SSL_MAX_EXTENSIONS];
803 823
804 /* SessionTicket Extension related data. */ 824 /* SessionTicket Extension related data. */
805 PRBool ticketTimestampVerified; 825 PRBool ticketTimestampVerified;
806 PRBool emptySessionTicket; 826 PRBool emptySessionTicket;
827 PRBool sentSessionTicketInClientHello;
807 828
808 /* SNI Extension related data 829 /* SNI Extension related data
809 * Names data is not coppied from the input buffer. It can not be 830 * Names data is not coppied from the input buffer. It can not be
810 * used outside the scope where input buffer is defined and that 831 * used outside the scope where input buffer is defined and that
811 * is beyond ssl3_HandleClientHello function. */ 832 * is beyond ssl3_HandleClientHello function. */
812 SECItem *sniNameArr; 833 SECItem *sniNameArr;
813 PRUint32 sniNameArrSize; 834 PRUint32 sniNameArrSize;
814 835
815 /* Signed Certificate Timestamps extracted from the TLS extension. 836 /* Signed Certificate Timestamps extracted from the TLS extension.
816 * (client only). 837 * (client only).
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 * pointer for the <HASH>_Clone function. */ 891 * pointer for the <HASH>_Clone function. */
871 void (*sha_clone)(void *dest, void *src); 892 void (*sha_clone)(void *dest, void *src);
872 #endif 893 #endif
873 /* PKCS #11 mode: 894 /* PKCS #11 mode:
874 * SSL 3.0 - TLS 1.1 use both |md5| and |sha|. |md5| is used for MD5 and 895 * SSL 3.0 - TLS 1.1 use both |md5| and |sha|. |md5| is used for MD5 and
875 * |sha| for SHA-1. 896 * |sha| for SHA-1.
876 * TLS 1.2 and later use only |sha|, for SHA-256. */ 897 * TLS 1.2 and later use only |sha|, for SHA-256. */
877 /* NOTE: On the client side, TLS 1.2 and later use |md5| as a backup 898 /* NOTE: On the client side, TLS 1.2 and later use |md5| as a backup
878 * handshake hash for generating client auth signatures. Confusingly, the 899 * handshake hash for generating client auth signatures. Confusingly, the
879 * backup hash function is SHA-1. */ 900 * backup hash function is SHA-1. */
901 #define backupHash md5
880 PK11Context * md5; 902 PK11Context * md5;
881 PK11Context * sha; 903 PK11Context * sha;
882 904
883 const ssl3KEADef * kea_def; 905 const ssl3KEADef * kea_def;
884 ssl3CipherSuite cipher_suite; 906 ssl3CipherSuite cipher_suite;
885 const ssl3CipherSuiteDef *suite_def; 907 const ssl3CipherSuiteDef *suite_def;
886 SSLCompressionMethod compression; 908 SSLCompressionMethod compression;
887 sslBuffer msg_body; /* protected by recvBufLock */ 909 sslBuffer msg_body; /* protected by recvBufLock */
888 /* partial handshake message from record layer */ 910 /* partial handshake message from record layer */
889 unsigned int header_bytes; 911 unsigned int header_bytes;
890 /* number of bytes consumed from handshake */ 912 /* number of bytes consumed from handshake */
891 /* message for message type and header length */ 913 /* message for message type and header length */
892 SSL3HandshakeType msg_type; 914 SSL3HandshakeType msg_type;
893 unsigned long msg_len; 915 unsigned long msg_len;
894 SECItem ca_list; /* used only by client */ 916 SECItem ca_list; /* used only by client */
895 PRBool isResuming; /* are we resuming a session */ 917 PRBool isResuming; /* are we resuming a session */
896 PRBool usedStepDownKey; /* we did a server key exchange. */ 918 PRBool usedStepDownKey; /* we did a server key exchange. */
897 PRBool sendingSCSV; /* instead of empty RI */ 919 PRBool sendingSCSV; /* instead of empty RI */
898 sslBuffer msgState; /* current state for handshake messages*/ 920 sslBuffer msgState; /* current state for handshake messages*/
899 /* protected by recvBufLock */ 921 /* protected by recvBufLock */
922
923 /* The session ticket received in a NewSessionTicket message is temporarily
924 * stored in newSessionTicket until the handshake is finished; then it is
925 * moved to the sid.
926 */
927 PRBool receivedNewSessionTicket;
928 NewSessionTicket newSessionTicket;
929
900 PRUint16 finishedBytes; /* size of single finished below */ 930 PRUint16 finishedBytes; /* size of single finished below */
901 union { 931 union {
902 TLSFinished tFinished[2]; /* client, then server */ 932 TLSFinished tFinished[2]; /* client, then server */
903 SSL3Finished sFinished[2]; 933 SSL3Finished sFinished[2];
904 SSL3Opaque data[72]; 934 SSL3Opaque data[72];
905 } finishedMsgs; 935 } finishedMsgs;
906 #ifdef NSS_ENABLE_ECC 936 #ifdef NSS_ENABLE_ECC
907 PRUint32 negotiatedECCurves; /* bit mask */ 937 PRUint32 negotiatedECCurves; /* bit mask */
908 #endif /* NSS_ENABLE_ECC */ 938 #endif /* NSS_ENABLE_ECC */
909 939
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 extern PRInt32 ssl3_SendSupportedPointFormatsXtn(sslSocket *ss, 1859 extern PRInt32 ssl3_SendSupportedPointFormatsXtn(sslSocket *ss,
1830 PRBool append, PRUint32 maxBytes); 1860 PRBool append, PRUint32 maxBytes);
1831 #endif 1861 #endif
1832 1862
1833 /* call the registered extension handlers. */ 1863 /* call the registered extension handlers. */
1834 extern SECStatus ssl3_HandleHelloExtensions(sslSocket *ss, 1864 extern SECStatus ssl3_HandleHelloExtensions(sslSocket *ss,
1835 SSL3Opaque **b, PRUint32 *length); 1865 SSL3Opaque **b, PRUint32 *length);
1836 1866
1837 /* Hello Extension related routines. */ 1867 /* Hello Extension related routines. */
1838 extern PRBool ssl3_ExtensionNegotiated(sslSocket *ss, PRUint16 ex_type); 1868 extern PRBool ssl3_ExtensionNegotiated(sslSocket *ss, PRUint16 ex_type);
1839 extern SECStatus ssl3_SetSIDSessionTicket(sslSessionID *sid, 1869 extern void ssl3_SetSIDSessionTicket(sslSessionID *sid,
1840 » » » NewSessionTicket *session_ticket); 1870 » » » /*in/out*/ NewSessionTicket *session_ticket);
1841 extern SECStatus ssl3_SendNewSessionTicket(sslSocket *ss); 1871 extern SECStatus ssl3_SendNewSessionTicket(sslSocket *ss);
1842 extern PRBool ssl_GetSessionTicketKeys(unsigned char *keyName, 1872 extern PRBool ssl_GetSessionTicketKeys(unsigned char *keyName,
1843 unsigned char *encKey, unsigned char *macKey); 1873 unsigned char *encKey, unsigned char *macKey);
1844 extern PRBool ssl_GetSessionTicketKeysPKCS11(SECKEYPrivateKey *svrPrivKey, 1874 extern PRBool ssl_GetSessionTicketKeysPKCS11(SECKEYPrivateKey *svrPrivKey,
1845 SECKEYPublicKey *svrPubKey, void *pwArg, 1875 SECKEYPublicKey *svrPubKey, void *pwArg,
1846 unsigned char *keyName, PK11SymKey **aesKey, 1876 unsigned char *keyName, PK11SymKey **aesKey,
1847 PK11SymKey **macKey); 1877 PK11SymKey **macKey);
1848 1878
1849 /* Tell clients to consider tickets valid for this long. */ 1879 /* Tell clients to consider tickets valid for this long. */
1850 #define TLS_EX_SESS_TICKET_LIFETIME_HINT (2 * 24 * 60 * 60) /* 2 days */ 1880 #define TLS_EX_SESS_TICKET_LIFETIME_HINT (2 * 24 * 60 * 60) /* 2 days */
1851 #define TLS_EX_SESS_TICKET_VERSION (0x0100) 1881 #define TLS_EX_SESS_TICKET_VERSION (0x0100)
1852 1882
1853 extern SECStatus ssl3_ValidateNextProtoNego(const unsigned char* data, 1883 extern SECStatus ssl3_ValidateNextProtoNego(const unsigned char* data,
1854 unsigned int length); 1884 unsigned int length);
1855 1885
1856 extern SECStatus ssl3_GetTLSUniqueChannelBinding(sslSocket *ss, 1886 extern SECStatus ssl3_GetTLSUniqueChannelBinding(sslSocket *ss,
1857 unsigned char *out, 1887 unsigned char *out,
1858 unsigned int *outLen, 1888 unsigned int *outLen,
1859 unsigned int outLenMax); 1889 unsigned int outLenMax);
1860 1890
1861 /* Construct a new NSPR socket for the app to use */ 1891 /* Construct a new NSPR socket for the app to use */
1862 extern PRFileDesc *ssl_NewPRSocket(sslSocket *ss, PRFileDesc *fd); 1892 extern PRFileDesc *ssl_NewPRSocket(sslSocket *ss, PRFileDesc *fd);
1863 extern void ssl_FreePRSocket(PRFileDesc *fd); 1893 extern void ssl_FreePRSocket(PRFileDesc *fd);
1864 1894
1865 /* Internal config function so SSL2 can initialize the present state of 1895 /* Internal config function so SSL3 can initialize the present state of
1866 * various ciphers */ 1896 * various ciphers */
1867 extern int ssl3_config_match_init(sslSocket *); 1897 extern int ssl3_config_match_init(sslSocket *);
1868 1898
1899
1869 /* Create a new ref counted key pair object from two keys. */ 1900 /* Create a new ref counted key pair object from two keys. */
1870 extern ssl3KeyPair * ssl3_NewKeyPair( SECKEYPrivateKey * privKey, 1901 extern ssl3KeyPair * ssl3_NewKeyPair( SECKEYPrivateKey * privKey,
1871 SECKEYPublicKey * pubKey); 1902 SECKEYPublicKey * pubKey);
1872 1903
1873 /* get a new reference (bump ref count) to an ssl3KeyPair. */ 1904 /* get a new reference (bump ref count) to an ssl3KeyPair. */
1874 extern ssl3KeyPair * ssl3_GetKeyPairRef(ssl3KeyPair * keyPair); 1905 extern ssl3KeyPair * ssl3_GetKeyPairRef(ssl3KeyPair * keyPair);
1875 1906
1876 /* Decrement keypair's ref count and free if zero. */ 1907 /* Decrement keypair's ref count and free if zero. */
1877 extern void ssl3_FreeKeyPair(ssl3KeyPair * keyPair); 1908 extern void ssl3_FreeKeyPair(ssl3KeyPair * keyPair);
1878 1909
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 extern int dtls_RecordGetRecvd(DTLSRecvdRecords *records, PRUint64 seq); 1986 extern int dtls_RecordGetRecvd(DTLSRecvdRecords *records, PRUint64 seq);
1956 extern void dtls_RecordSetRecvd(DTLSRecvdRecords *records, PRUint64 seq); 1987 extern void dtls_RecordSetRecvd(DTLSRecvdRecords *records, PRUint64 seq);
1957 extern void dtls_RehandshakeCleanup(sslSocket *ss); 1988 extern void dtls_RehandshakeCleanup(sslSocket *ss);
1958 extern SSL3ProtocolVersion 1989 extern SSL3ProtocolVersion
1959 dtls_TLSVersionToDTLSVersion(SSL3ProtocolVersion tlsv); 1990 dtls_TLSVersionToDTLSVersion(SSL3ProtocolVersion tlsv);
1960 extern SSL3ProtocolVersion 1991 extern SSL3ProtocolVersion
1961 dtls_DTLSVersionToTLSVersion(SSL3ProtocolVersion dtlsv); 1992 dtls_DTLSVersionToTLSVersion(SSL3ProtocolVersion dtlsv);
1962 1993
1963 /********************** misc calls *********************/ 1994 /********************** misc calls *********************/
1964 1995
1996 #ifdef DEBUG
1997 extern void ssl3_CheckCipherSuiteOrderConsistency();
1998 #endif
1999
1965 extern int ssl_MapLowLevelError(int hiLevelError); 2000 extern int ssl_MapLowLevelError(int hiLevelError);
1966 2001
1967 extern PRUint32 ssl_Time(void); 2002 extern PRUint32 ssl_Time(void);
1968 2003
1969 extern void SSL_AtomicIncrementLong(long * x); 2004 extern void SSL_AtomicIncrementLong(long * x);
1970 2005
1971 SECStatus SSL_DisableDefaultExportCipherSuites(void); 2006 SECStatus SSL_DisableDefaultExportCipherSuites(void);
1972 SECStatus SSL_DisableExportCipherSuites(PRFileDesc * fd); 2007 SECStatus SSL_DisableExportCipherSuites(PRFileDesc * fd);
1973 PRBool SSL_IsExportCipherSuite(PRUint16 cipherSuite); 2008 PRBool SSL_IsExportCipherSuite(PRUint16 cipherSuite);
1974 2009
(...skipping 16 matching lines...) Expand all
1991 #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS) 2026 #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
1992 #define SSL_GETPID getpid 2027 #define SSL_GETPID getpid
1993 #elif defined(WIN32) 2028 #elif defined(WIN32)
1994 extern int __cdecl _getpid(void); 2029 extern int __cdecl _getpid(void);
1995 #define SSL_GETPID _getpid 2030 #define SSL_GETPID _getpid
1996 #else 2031 #else
1997 #define SSL_GETPID() 0 2032 #define SSL_GETPID() 0
1998 #endif 2033 #endif
1999 2034
2000 #endif /* __sslimpl_h_ */ 2035 #endif /* __sslimpl_h_ */
OLDNEW
« no previous file with comments | « net/third_party/nss/ssl/sslenum.c ('k') | net/third_party/nss/ssl/sslinit.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698