Skip to content

Commit

Permalink
Merge ddd7772 into 14f2c60
Browse files Browse the repository at this point in the history
  • Loading branch information
tomato42 committed May 25, 2015
2 parents 14f2c60 + ddd7772 commit a481636
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 143 deletions.
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,21 @@ matrix:
env: PYCRYPTO=true GMPY=true

before_install:
- |
echo -e "TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST\n" \
"TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG\n" \
"TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST\n" \
"TRAVIS_COMMIT=$TRAVIS_COMMIT\n" \
"TRAVIS_PYTHON_VERSION=$TRAVIS_PYTHON_VERSION"
- |
# workaround https://github.com/travis-ci/travis-ci/issues/2666
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
PR_FIRST=$(curl -s https://github.com/${TRAVIS_REPO_SLUG}/pull/${TRAVIS_PULL_REQUEST}.patch | head -1 | grep -o -E '\b[0-9a-f]{40}\b' | tr -d '\n')
URL="https://github.com/${TRAVIS_REPO_SLUG}/pull/${TRAVIS_PULL_REQUEST}.patch"
# `--location` makes curl follow redirects
PR_FIRST=$(curl --silent --show-error --location $URL | head -1 | grep -o -E '\b[0-9a-f]{40}\b' | tr -d '\n')
TRAVIS_COMMIT_RANGE=$PR_FIRST^..$TRAVIS_COMMIT
fi
- echo "TRAVIS_COMMIT_RANGE=$TRAVIS_COMMIT_RANGE"
- git fetch origin master:refs/remotes/origin/master

install:
Expand Down
18 changes: 18 additions & 0 deletions tlslite/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,21 @@ class TLSUnsupportedError(TLSError):
class TLSInternalError(TLSError):
"""The internal state of object is unexpected or invalid"""
pass

class TLSRecordOverflow(TLSInternalError):
"""Read record is too big to handle"""
pass

class TLSDecryptionFailed(TLSInternalError):
"""Decryptioin was impossible"""
pass

class TLSBadRecordMAC(TLSInternalError):
"""MAC or padding of record was invalid"""
pass

class TLSSocketClosed(TLSInternalError):
"""Socket was closed unexpectedly while writing messages"""
def __init__(self, reason):
super(TLSSocketClosed, self).__init__()
self.reason = reason
34 changes: 17 additions & 17 deletions tlslite/tlsconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,10 +636,10 @@ def _clientResume(self, session, serverHello, clientRandom,
yield result

#Calculate pending connection states
self._calcPendingStates(session.cipherSuite,
session.masterSecret,
clientRandom, serverHello.random,
cipherImplementations)
self.calcPendingStates(session.cipherSuite,
session.masterSecret,
clientRandom, serverHello.random,
cipherImplementations)

#Exchange ChangeCipherSpec and Finished messages
for result in self._getFinished(session.masterSecret):
Expand Down Expand Up @@ -916,9 +916,9 @@ def _clientFinished(self, premasterSecret, clientRandom, serverRandom,

masterSecret = calcMasterSecret(self.version, premasterSecret,
clientRandom, serverRandom)
self._calcPendingStates(cipherSuite, masterSecret,
clientRandom, serverRandom,
cipherImplementations)
self.calcPendingStates(cipherSuite, masterSecret,
clientRandom, serverRandom,
cipherImplementations)

#Exchange ChangeCipherSpec and Finished messages
for result in self._sendFinished(masterSecret, nextProto):
Expand Down Expand Up @@ -1319,11 +1319,11 @@ def _serverGetClientHello(self, settings, certChain, verifierDB,
self._versionCheck = True

#Calculate pending connection states
self._calcPendingStates(session.cipherSuite,
session.masterSecret,
clientHello.random,
serverHello.random,
settings.cipherImplementations)
self.calcPendingStates(session.cipherSuite,
session.masterSecret,
clientHello.random,
serverHello.random,
settings.cipherImplementations)

#Exchange ChangeCipherSpec and Finished messages
for result in self._sendFinished(session.masterSecret):
Expand Down Expand Up @@ -1617,9 +1617,9 @@ def _serverFinished(self, premasterSecret, clientRandom, serverRandom,
clientRandom, serverRandom)

#Calculate pending connection states
self._calcPendingStates(cipherSuite, masterSecret,
clientRandom, serverRandom,
cipherImplementations)
self.calcPendingStates(cipherSuite, masterSecret,
clientRandom, serverRandom,
cipherImplementations)

#Exchange ChangeCipherSpec and Finished messages
for result in self._getFinished(masterSecret,
Expand All @@ -1643,7 +1643,7 @@ def _sendFinished(self, masterSecret, nextProto=None):
yield result

#Switch to pending write state
self._changeWriteState()
self.changeWriteState()

if nextProto is not None:
nextProtoMsg = NextProtocol().create(nextProto)
Expand Down Expand Up @@ -1673,7 +1673,7 @@ def _getFinished(self, masterSecret, expect_next_protocol=False, nextProto=None)
yield result

#Switch to pending read state
self._changeReadState()
self.changeReadState()

#Server Finish - Are we waiting for a next protocol echo?
if expect_next_protocol:
Expand Down

0 comments on commit a481636

Please sign in to comment.