Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various changes from Chromium, redux, part 1. #87

Merged
merged 4 commits into from
Mar 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified README
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion tests/httpsserver.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# /bin/sh
#!/bin/sh
python ../scripts/tls.py server -k serverX509Key.pem -c serverX509Cert.pem -t TACK1.pem localhost:4443
Empty file modified tests/index.html
100755 → 100644
Empty file.
59 changes: 50 additions & 9 deletions tests/tlstest.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,31 @@ def connect():
#print(" Next-Protocol Negotiated: %s" % connection.next_proto)
assert(connection.next_proto == b'spdy/2')
connection.close()

print('Test 25 - good standard XMLRPC https client')

print("Test 25.a - FALLBACK_SCSV")
synchro.recv(1)
connection = connect()
settings = HandshakeSettings()
settings.sendFallbackSCSV = True
connection.handshakeClientCert(settings=settings)
testConnClient(connection)
connection.close()

print("Test 25.b - FALLBACK_SCSV")
synchro.recv(1)
connection = connect()
settings = HandshakeSettings()
settings.sendFallbackSCSV = True
settings.maxVersion = (3, 2)
try:
connection.handshakeClientCert(settings=settings)
assert()
except TLSRemoteAlert as alert:
if alert.description != AlertDescription.inappropriate_fallback:
raise
connection.close()

print('Test 26 - good standard XMLRPC https client')
address = address[0], address[1]+1
synchro.recv(1)
try:
Expand All @@ -441,30 +464,30 @@ def connect():
synchro.recv(1)
assert server.pow(2,4) == 16

print('Test 26 - good tlslite XMLRPC client')
print('Test 27 - good tlslite XMLRPC client')
transport = XMLRPCTransport(ignoreAbruptClose=True)
server = xmlrpclib.Server('https://%s:%s' % address, transport)
synchro.recv(1)
assert server.add(1,2) == 3
synchro.recv(1)
assert server.pow(2,4) == 16

print('Test 27 - good XMLRPC ignored protocol')
print('Test 28 - good XMLRPC ignored protocol')
server = xmlrpclib.Server('http://%s:%s' % address, transport)
synchro.recv(1)
assert server.add(1,2) == 3
synchro.recv(1)
assert server.pow(2,4) == 16
print("Test 28 - Internet servers test")

print("Test 29 - Internet servers test")
try:
i = IMAP4_TLS("cyrus.andrew.cmu.edu")
i.login("anonymous", "[email protected]")
i.logout()
print("Test 28: IMAP4 good")
print("Test 30: IMAP4 good")
p = POP3_TLS("pop.gmail.com")
p.quit()
print("Test 29: POP3 good")
print("Test 31: POP3 good")
except socket.error as e:
print("Non-critical error: socket error trying to reach internet server: ", e)

Expand Down Expand Up @@ -843,7 +866,25 @@ def server_bind(self):
testConnServer(connection)
connection.close()

print("Tests 25-27 - XMLRPXC server")
print("Test 25.a - FALLBACK_SCSV")
synchro.send(b'R')
connection = connect()
connection.handshakeServer(certChain=x509Chain, privateKey=x509Key)
testConnServer(connection)
connection.close()

print("Test 25.b - FALLBACK_SCSV")
synchro.send(b'R')
connection = connect()
try:
connection.handshakeServer(certChain=x509Chain, privateKey=x509Key)
assert()
except TLSLocalAlert as alert:
if alert.description != AlertDescription.inappropriate_fallback:
raise
connection.close()

print("Tests 26-28 - XMLRPXC server")
address = address[0], address[1]+1
class Server(TLSXMLRPCServer):

Expand Down
Empty file modified tests/verifierDB
100755 → 100644
Empty file.
Empty file modified tlslite/__init__.py
100755 → 100644
Empty file.
Empty file modified tlslite/basedb.py
100755 → 100644
Empty file.
Empty file modified tlslite/checker.py
100755 → 100644
Empty file.
4 changes: 4 additions & 0 deletions tlslite/constants.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class AlertDescription:
protocol_version = 70
insufficient_security = 71
internal_error = 80
inappropriate_fallback = 86
user_canceled = 90
no_renegotiation = 100
unknown_psk_identity = 115
Expand All @@ -115,6 +116,9 @@ class CipherSuite:
# We actually don't do any renegotiation, but this
# prevents renegotiation attacks
TLS_EMPTY_RENEGOTIATION_INFO_SCSV = 0x00FF

# draft-ietf-tls-downgrade-scsv-03
TLS_FALLBACK_SCSV = 0x5600

TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA = 0xC01A
TLS_SRP_SHA_WITH_AES_128_CBC_SHA = 0xC01D
Expand Down
1 change: 1 addition & 0 deletions tlslite/errors.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class TLSAlert(TLSError):
AlertDescription.protocol_version: "protocol_version",\
AlertDescription.insufficient_security: "insufficient_security",\
AlertDescription.internal_error: "internal_error",\
AlertDescription.inappropriate_fallback: "inappropriate_fallback",\
AlertDescription.user_canceled: "user_canceled",\
AlertDescription.no_renegotiation: "no_renegotiation",\
AlertDescription.unknown_psk_identity: "unknown_psk_identity"}
Expand Down
5 changes: 5 additions & 0 deletions tlslite/handshakesettings.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ class HandshakeSettings(object):

Note that TACK support is not standardized by IETF and uses a temporary
TLS Extension number, so should NOT be used in production software.

@type sendFallbackSCSV: bool
@ivar sendFallbackSCSV: Whether to, as a client, send FALLBACK_SCSV.
"""
def __init__(self):
self.minKeySize = 1023
Expand All @@ -106,6 +109,7 @@ def __init__(self):
self.minVersion = (3,1)
self.maxVersion = (3,3)
self.useExperimentalTackExtension = False
self.sendFallbackSCSV = False

# Validates the min/max fields, and certificateTypes
# Filters out unsupported cipherNames and cipherImplementations
Expand All @@ -119,6 +123,7 @@ def _filter(self):
other.certificateTypes = self.certificateTypes
other.minVersion = self.minVersion
other.maxVersion = self.maxVersion
other.sendFallbackSCSV = self.sendFallbackSCSV

if not cipherfactory.tripleDESPresent:
other.cipherNames = [e for e in self.cipherNames if e != "3des"]
Expand Down
Empty file modified tlslite/integration/__init__.py
100755 → 100644
Empty file.
Empty file modified tlslite/integration/asyncstatemachine.py
100755 → 100644
Empty file.
Empty file modified tlslite/integration/clienthelper.py
100755 → 100644
Empty file.
Empty file modified tlslite/integration/httptlsconnection.py
100755 → 100644
Empty file.
Empty file modified tlslite/integration/imap4_tls.py
100755 → 100644
Empty file.
Empty file modified tlslite/integration/pop3_tls.py
100755 → 100644
Empty file.
Empty file modified tlslite/integration/smtp_tls.py
100755 → 100644
Empty file.
Empty file modified tlslite/integration/tlsasyncdispatchermixin.py
100755 → 100644
Empty file.
Empty file modified tlslite/integration/tlssocketservermixin.py
100755 → 100644
Empty file.
Empty file modified tlslite/integration/xmlrpctransport.py
100755 → 100644
Empty file.
Empty file modified tlslite/mathtls.py
100755 → 100644
Empty file.
Empty file modified tlslite/messages.py
100755 → 100644
Empty file.
Empty file modified tlslite/session.py
100755 → 100644
Empty file.
Empty file modified tlslite/sessioncache.py
100755 → 100644
Empty file.
17 changes: 15 additions & 2 deletions tlslite/tlsconnection.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,12 @@ def _clientSendClientHello(self, settings, session, srpUsername,
else:
assert(False)

#Add any SCSVs. These are not real cipher suites, but signaling
#values which reuse the cipher suite field in the ClientHello.
wireCipherSuites = list(cipherSuites)
if settings.sendFallbackSCSV:
wireCipherSuites.append(CipherSuite.TLS_FALLBACK_SCSV)

#Initialize acceptable certificate types
certificateTypes = settings._getCertificateTypes()

Expand All @@ -519,7 +525,7 @@ def _clientSendClientHello(self, settings, session, srpUsername,
else:
clientHello = ClientHello()
clientHello.create(settings.maxVersion, getRandomBytes(32),
session.sessionID, cipherSuites,
session.sessionID, wireCipherSuites,
certificateTypes,
session.srpUsername,
reqTack, nextProtos is not None,
Expand All @@ -529,7 +535,7 @@ def _clientSendClientHello(self, settings, session, srpUsername,
else:
clientHello = ClientHello()
clientHello.create(settings.maxVersion, getRandomBytes(32),
bytearray(0), cipherSuites,
bytearray(0), wireCipherSuites,
certificateTypes,
srpUsername,
reqTack, nextProtos is not None,
Expand Down Expand Up @@ -1257,6 +1263,13 @@ def _serverGetClientHello(self, settings, certChain, verifierDB,
#Set the version to the client's version
self.version = clientHello.client_version

#Detect if the client performed an inappropriate fallback.
if clientHello.client_version < settings.maxVersion and \
CipherSuite.TLS_FALLBACK_SCSV in clientHello.cipher_suites:
for result in self._sendError(\
AlertDescription.inappropriate_fallback):
yield result

#If resumption was requested and we have a session cache...
if clientHello.session_id and sessionCache:
session = None
Expand Down
4 changes: 2 additions & 2 deletions tlslite/tlsrecordlayer.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,9 @@ def _sendMsg(self, msg, randomizeFirstBlock = True):
b = self.fixedIVBlock + b

#Add padding: b = b+ (macBytes + paddingBytes)
currentLength = len(b) + len(macBytes) + 1
currentLength = len(b) + len(macBytes)
blockLength = self._writeState.encContext.block_size
paddingLength = blockLength-(currentLength % blockLength)
paddingLength = blockLength - 1 - (currentLength % blockLength)

paddingBytes = bytearray([paddingLength] * (paddingLength+1))
if self.fault == Fault.badPadding:
Expand Down
Empty file modified tlslite/utils/__init__.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/aes.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/asn1parser.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/cipherfactory.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/codec.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/compat.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/cryptomath.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/datefuncs.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/keyfactory.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/openssl_aes.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/openssl_rc4.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/openssl_rsakey.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/openssl_tripledes.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/pycrypto_aes.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/pycrypto_rc4.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/pycrypto_rsakey.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/pycrypto_tripledes.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/python_aes.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/python_rc4.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/python_rsakey.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/rc4.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/rijndael.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/rsakey.py
100755 → 100644
Empty file.
Empty file modified tlslite/utils/tripledes.py
100755 → 100644
Empty file.
Empty file modified tlslite/verifierdb.py
100755 → 100644
Empty file.
Empty file modified tlslite/x509.py
100755 → 100644
Empty file.
Empty file modified tlslite/x509certchain.py
100755 → 100644
Empty file.