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

Side by Side Diff: third_party/tlslite/tlslite/TLSConnection.py

Issue 108113006: Revert of Extract Certificate Transparency SCTs from stapled OCSP responses (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@extract_scts
Patch Set: Created 7 years 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
OLDNEW
1 """ 1 """
2 MAIN CLASS FOR TLS LITE (START HERE!). 2 MAIN CLASS FOR TLS LITE (START HERE!).
3 """ 3 """
4 from __future__ import generators 4 from __future__ import generators
5 5
6 import socket 6 import socket
7 from utils.compat import formatExceptionTrace 7 from utils.compat import formatExceptionTrace
8 from TLSRecordLayer import TLSRecordLayer 8 from TLSRecordLayer import TLSRecordLayer
9 from Session import Session 9 from Session import Session
10 from constants import * 10 from constants import *
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 #Mark the connection as open 930 #Mark the connection as open
931 self.session._setResumable(True) 931 self.session._setResumable(True)
932 self._handshakeDone(resumed=False) 932 self._handshakeDone(resumed=False)
933 933
934 934
935 935
936 def handshakeServer(self, sharedKeyDB=None, verifierDB=None, 936 def handshakeServer(self, sharedKeyDB=None, verifierDB=None,
937 certChain=None, privateKey=None, reqCert=False, 937 certChain=None, privateKey=None, reqCert=False,
938 sessionCache=None, settings=None, checker=None, 938 sessionCache=None, settings=None, checker=None,
939 reqCAs=None, tlsIntolerant=0, 939 reqCAs=None, tlsIntolerant=0,
940 signedCertTimestamps=None, fallbackSCSV=False, 940 signedCertTimestamps=None,
941 ocspResponse=None): 941 fallbackSCSV=False):
942 """Perform a handshake in the role of server. 942 """Perform a handshake in the role of server.
943 943
944 This function performs an SSL or TLS handshake. Depending on 944 This function performs an SSL or TLS handshake. Depending on
945 the arguments and the behavior of the client, this function can 945 the arguments and the behavior of the client, this function can
946 perform a shared-key, SRP, or certificate-based handshake. It 946 perform a shared-key, SRP, or certificate-based handshake. It
947 can also perform a combined SRP and server-certificate 947 can also perform a combined SRP and server-certificate
948 handshake. 948 handshake.
949 949
950 Like any handshake function, this can be called on a closed 950 Like any handshake function, this can be called on a closed
951 TLS connection, or on a TLS connection that is already open. 951 TLS connection, or on a TLS connection that is already open.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 @type reqCAs: list of L{array.array} of unsigned bytes 1007 @type reqCAs: list of L{array.array} of unsigned bytes
1008 @param reqCAs: A collection of DER-encoded DistinguishedNames that 1008 @param reqCAs: A collection of DER-encoded DistinguishedNames that
1009 will be sent along with a certificate request. This does not affect 1009 will be sent along with a certificate request. This does not affect
1010 verification. 1010 verification.
1011 1011
1012 @type signedCertTimestamps: str 1012 @type signedCertTimestamps: str
1013 @param signedCertTimestamps: A SignedCertificateTimestampList (as a 1013 @param signedCertTimestamps: A SignedCertificateTimestampList (as a
1014 binary 8-bit string) that will be sent as a TLS extension whenever 1014 binary 8-bit string) that will be sent as a TLS extension whenever
1015 the client announces support for the extension. 1015 the client announces support for the extension.
1016 1016
1017 @type ocspResponse: str
1018 @param ocspResponse: An OCSP response (as a binary 8-bit string) that
1019 will be sent stapled in the handshake whenever the client announces
1020 support for the status_request extension.
1021 Note that the response is sent independent of the ClientHello
1022 status_request extension contents, and is thus only meant for testing
1023 environments. Real OCSP stapling is more complicated as it requires
1024 choosing a suitable response based on the ClientHello status_request
1025 extension contents.
1026
1027 @raise socket.error: If a socket error occurs. 1017 @raise socket.error: If a socket error occurs.
1028 @raise tlslite.errors.TLSAbruptCloseError: If the socket is closed 1018 @raise tlslite.errors.TLSAbruptCloseError: If the socket is closed
1029 without a preceding alert. 1019 without a preceding alert.
1030 @raise tlslite.errors.TLSAlert: If a TLS alert is signalled. 1020 @raise tlslite.errors.TLSAlert: If a TLS alert is signalled.
1031 @raise tlslite.errors.TLSAuthenticationError: If the checker 1021 @raise tlslite.errors.TLSAuthenticationError: If the checker
1032 doesn't like the other party's authentication credentials. 1022 doesn't like the other party's authentication credentials.
1033 """ 1023 """
1034 for result in self.handshakeServerAsync(sharedKeyDB, verifierDB, 1024 for result in self.handshakeServerAsync(sharedKeyDB, verifierDB,
1035 certChain, privateKey, reqCert, sessionCache, settings, 1025 certChain, privateKey, reqCert, sessionCache, settings,
1036 checker, reqCAs, tlsIntolerant, signedCertTimestamps, 1026 checker, reqCAs, tlsIntolerant, signedCertTimestamps,
1037 fallbackSCSV, ocspResponse): 1027 fallbackSCSV):
1038 pass 1028 pass
1039 1029
1040 1030
1041 def handshakeServerAsync(self, sharedKeyDB=None, verifierDB=None, 1031 def handshakeServerAsync(self, sharedKeyDB=None, verifierDB=None,
1042 certChain=None, privateKey=None, reqCert=False, 1032 certChain=None, privateKey=None, reqCert=False,
1043 sessionCache=None, settings=None, checker=None, 1033 sessionCache=None, settings=None, checker=None,
1044 reqCAs=None, tlsIntolerant=0, 1034 reqCAs=None, tlsIntolerant=0,
1045 signedCertTimestamps=None, 1035 signedCertTimestamps=None,
1046 fallbackSCSV=False, ocspResponse=None): 1036 fallbackSCSV=False):
1047 """Start a server handshake operation on the TLS connection. 1037 """Start a server handshake operation on the TLS connection.
1048 1038
1049 This function returns a generator which behaves similarly to 1039 This function returns a generator which behaves similarly to
1050 handshakeServer(). Successive invocations of the generator 1040 handshakeServer(). Successive invocations of the generator
1051 will return 0 if it is waiting to read from the socket, 1 if it is 1041 will return 0 if it is waiting to read from the socket, 1 if it is
1052 waiting to write to the socket, or it will raise StopIteration 1042 waiting to write to the socket, or it will raise StopIteration
1053 if the handshake operation is complete. 1043 if the handshake operation is complete.
1054 1044
1055 @rtype: iterable 1045 @rtype: iterable
1056 @return: A generator; see above for details. 1046 @return: A generator; see above for details.
1057 """ 1047 """
1058 handshaker = self._handshakeServerAsyncHelper(\ 1048 handshaker = self._handshakeServerAsyncHelper(\
1059 sharedKeyDB=sharedKeyDB, 1049 sharedKeyDB=sharedKeyDB,
1060 verifierDB=verifierDB, certChain=certChain, 1050 verifierDB=verifierDB, certChain=certChain,
1061 privateKey=privateKey, reqCert=reqCert, 1051 privateKey=privateKey, reqCert=reqCert,
1062 sessionCache=sessionCache, settings=settings, 1052 sessionCache=sessionCache, settings=settings,
1063 reqCAs=reqCAs, 1053 reqCAs=reqCAs,
1064 tlsIntolerant=tlsIntolerant, 1054 tlsIntolerant=tlsIntolerant,
1065 signedCertTimestamps=signedCertTimestamps, 1055 signedCertTimestamps=signedCertTimestamps,
1066 fallbackSCSV=fallbackSCSV, ocspResponse=ocspResponse) 1056 fallbackSCSV=fallbackSCSV)
1067
1068 for result in self._handshakeWrapperAsync(handshaker, checker): 1057 for result in self._handshakeWrapperAsync(handshaker, checker):
1069 yield result 1058 yield result
1070 1059
1071 1060
1072 def _handshakeServerAsyncHelper(self, sharedKeyDB, verifierDB, 1061 def _handshakeServerAsyncHelper(self, sharedKeyDB, verifierDB,
1073 certChain, privateKey, reqCert, 1062 certChain, privateKey, reqCert,
1074 sessionCache, settings, reqCAs, 1063 sessionCache, settings, reqCAs,
1075 tlsIntolerant, signedCertTimestamps, 1064 tlsIntolerant, signedCertTimestamps,
1076 fallbackSCSV, ocspResponse): 1065 fallbackSCSV):
1077 1066
1078 self._handshakeStart(client=False) 1067 self._handshakeStart(client=False)
1079 1068
1080 if (not sharedKeyDB) and (not verifierDB) and (not certChain): 1069 if (not sharedKeyDB) and (not verifierDB) and (not certChain):
1081 raise ValueError("Caller passed no authentication credentials") 1070 raise ValueError("Caller passed no authentication credentials")
1082 if certChain and not privateKey: 1071 if certChain and not privateKey:
1083 raise ValueError("Caller passed a certChain but no privateKey") 1072 raise ValueError("Caller passed a certChain but no privateKey")
1084 if privateKey and not certChain: 1073 if privateKey and not certChain:
1085 raise ValueError("Caller passed a privateKey but no certChain") 1074 raise ValueError("Caller passed a privateKey but no certChain")
1086 if reqCAs and not reqCert: 1075 if reqCAs and not reqCert:
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 elif cipherSuite in CipherSuite.rsaSuites: 1432 elif cipherSuite in CipherSuite.rsaSuites:
1444 1433
1445 #Send ServerHello, Certificate[, CertificateRequest], 1434 #Send ServerHello, Certificate[, CertificateRequest],
1446 #ServerHelloDone 1435 #ServerHelloDone
1447 msgs = [] 1436 msgs = []
1448 serverHello = ServerHello().create( 1437 serverHello = ServerHello().create(
1449 self.version, serverRandom, 1438 self.version, serverRandom,
1450 sessionID, cipherSuite, certificateType) 1439 sessionID, cipherSuite, certificateType)
1451 serverHello.channel_id = clientHello.channel_id 1440 serverHello.channel_id = clientHello.channel_id
1452 if clientHello.support_signed_cert_timestamps: 1441 if clientHello.support_signed_cert_timestamps:
1453 serverHello.signed_cert_timestamps = signedCertTimestamps 1442 serverHello.signed_cert_timestamps = signedCertTimestamps
1454 serverHello.status_request = (clientHello.status_request and
1455 ocspResponse)
1456 doingChannelID = clientHello.channel_id 1443 doingChannelID = clientHello.channel_id
1457 msgs.append(serverHello) 1444 msgs.append(serverHello)
1458 msgs.append(Certificate(certificateType).create(serverCertChain)) 1445 msgs.append(Certificate(certificateType).create(serverCertChain))
1459 if serverHello.status_request:
1460 msgs.append(CertificateStatus().create(ocspResponse))
1461 if reqCert and reqCAs: 1446 if reqCert and reqCAs:
1462 msgs.append(CertificateRequest().create([], reqCAs)) 1447 msgs.append(CertificateRequest().create([], reqCAs))
1463 elif reqCert: 1448 elif reqCert:
1464 msgs.append(CertificateRequest()) 1449 msgs.append(CertificateRequest())
1465 msgs.append(ServerHelloDone()) 1450 msgs.append(ServerHelloDone())
1466 for result in self._sendMsgs(msgs): 1451 for result in self._sendMsgs(msgs):
1467 yield result 1452 yield result
1468 1453
1469 #From here on, the client's messages must have the right version 1454 #From here on, the client's messages must have the right version
1470 self._versionCheck = True 1455 self._versionCheck = True
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 if len(publicKey) < settings.minKeySize: 1661 if len(publicKey) < settings.minKeySize:
1677 for result in self._sendError(AlertDescription.handshake_failure, 1662 for result in self._sendError(AlertDescription.handshake_failure,
1678 "Other party's public key too small: %d" % len(publicKey)): 1663 "Other party's public key too small: %d" % len(publicKey)):
1679 yield result 1664 yield result
1680 if len(publicKey) > settings.maxKeySize: 1665 if len(publicKey) > settings.maxKeySize:
1681 for result in self._sendError(AlertDescription.handshake_failure, 1666 for result in self._sendError(AlertDescription.handshake_failure,
1682 "Other party's public key too large: %d" % len(publicKey)): 1667 "Other party's public key too large: %d" % len(publicKey)):
1683 yield result 1668 yield result
1684 1669
1685 yield publicKey, certChain 1670 yield publicKey, certChain
OLDNEW
« no previous file with comments | « third_party/tlslite/patches/status_request.patch ('k') | third_party/tlslite/tlslite/constants.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698