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

test failure #128

Closed
sanderux opened this issue Aug 17, 2016 · 6 comments
Closed

test failure #128

sanderux opened this issue Aug 17, 2016 · 6 comments
Labels
bug unintented behaviour in tlslite-ng code

Comments

@sanderux
Copy link

I;m having trouble:

  • Python 2.7.3
  • installed via pip
  • cloned source
  • make test
root@ml ~/tlslite-ng# make test
cd tests/ && python ./tlstest.py server localhost:4433 . & sleep 1
cd tests/ && python ./tlstest.py client localhost:4433 .
Test 0 - anonymous handshake
Test 0 - Anonymous server handshake
Test 1 - good X.509
Test 1 - good X509 (plus SNI)
Traceback (most recent call last):
  File "./tlstest.py", line 1279, in <module>
    clientTestCmd(sys.argv[2:])
  File "./tlstest.py", line 118, in clientTestCmd
    connection.handshakeClientCert(serverName=address[0])
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 350, in handshakeClientCert
    for result in handshaker:
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 366, in _handshakeClientAsync
    for result in self._handshakeWrapperAsync(handshaker, checker):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1906, in _handshakeWrapperAsync
    for result in handshaker:
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 545, in _handshakeClientAsyncHelper
    nextProto):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 964, in _clientFinished
    for result in self._sendFinished(masterSecret, cipherSuite, nextProto):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1847, in _sendFinished
    for result in self._sendMsg(finished):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 590, in _sendMsg
    for result in self._sendMsgThroughSocket(msgFragment):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 597, in _sendMsgThroughSocket
    for result in self._recordLayer.sendRecord(msg):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 469, in sendRecord
    data = self._encryptThenSeal(data, contentType)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 417, in _encryptThenSeal
    buf = self._writeState.encContext.seal(nonce, buf, authData)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/chacha20_poly1305.py", line 55, in seal
    otk = self.poly1305_key_gen(self.key, nonce)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/chacha20_poly1305.py", line 36, in poly1305_key_gen
    poly = ChaCha(key, nonce)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/chacha.py", line 137, in __init__
    self.key = ChaCha._bytearray_to_words(key)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/chacha.py", line 122, in _bytearray_to_words
    compat26Str(data[i*4:(i+1)*4])))
struct.error: unpack requires a string argument of length 4
make: *** [test] Error 1
root@ml ~/tlslite-ng# Traceback (most recent call last):
  File "./tlstest.py", line 1281, in <module>
    serverTestCmd(sys.argv[2:])
  File "./tlstest.py", line 764, in serverTestCmd
    connection.handshakeServer(certChain=x509Chain, privateKey=x509Key)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1102, in handshakeServer
    nextProtos=nextProtos, anon=anon):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1131, in handshakeServerAsync
    for result in self._handshakeWrapperAsync(handshaker, checker):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1906, in _handshakeWrapperAsync
    for result in handshaker:
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1316, in _handshakeServerAsyncHelper
    nextProtos):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1807, in _serverFinished
    expect_next_protocol=nextProtos is not None):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1895, in _getFinished
    HandshakeType.finished):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 646, in _getMsg
    for result in self._getNextRecord():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 817, in _getNextRecord
    for result in self._getNextRecordFromSocket():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 841, in _getNextRecordFromSocket
    for result in self._recordLayer.recvRecord():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 695, in recvRecord
    for result in self._recordSocket.recv():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 188, in recv
    for record in self._recvHeader():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 122, in _recvHeader
    for result in self._sockRecvAll(1):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 109, in _sockRecvAll
    raise TLSAbruptCloseError()
tlslite.errors.TLSAbruptCloseError: TLSAbruptCloseError()

running regular example:

root@ml tlslite-ng/tests# tls.py server -k serverX509Key.pem -c serverX509Cert.pem localhost:4443
I am an HTTPS test server, I will listen on localhost:4443
Serving files from /root/tlslite-ng/tests
Using certificate and private key...
About to handshake...
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 48303)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 593, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/integration/tlssocketservermixin.py", line 55, in finish_request
    if self.handshake(tlsConnection) == True:
  File "/usr/local/bin/tls.py", line 345, in handshake
    reqCert=reqCert)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1102, in handshakeServer
    nextProtos=nextProtos, anon=anon):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1131, in handshakeServerAsync
    for result in self._handshakeWrapperAsync(handshaker, checker):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1906, in _handshakeWrapperAsync
    for result in handshaker:
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1316, in _handshakeServerAsyncHelper
    nextProtos):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1807, in _serverFinished
    expect_next_protocol=nextProtos is not None):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1895, in _getFinished
    HandshakeType.finished):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 646, in _getMsg
    for result in self._getNextRecord():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 817, in _getNextRecord
    for result in self._getNextRecordFromSocket():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 841, in _getNextRecordFromSocket
    for result in self._recordLayer.recvRecord():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 695, in recvRecord
    for result in self._recordSocket.recv():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 188, in recv
    for record in self._recvHeader():
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 122, in _recvHeader
    for result in self._sockRecvAll(1):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 109, in _sockRecvAll
    raise TLSAbruptCloseError()
TLSAbruptCloseError: TLSAbruptCloseError()
----------------------------------------

Response from client

root@ml tlslite-ng/tests# tls.py client localhost:4443                          Traceback (most recent call last):
  File "/usr/local/bin/tls.py", line 387, in <module>
    clientCmd(sys.argv[2:])
  File "/usr/local/bin/tls.py", line 264, in clientCmd
    settings=settings, serverName=address[0])
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 350, in handshakeClientCert
    for result in handshaker:
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 366, in _handshakeClientAsync
    for result in self._handshakeWrapperAsync(handshaker, checker):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1906, in _handshakeWrapperAsync
    for result in handshaker:
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 545, in _handshakeClientAsyncHelper
    nextProto):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 964, in _clientFinished
    for result in self._sendFinished(masterSecret, cipherSuite, nextProto):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsconnection.py", line 1847, in _sendFinished
    for result in self._sendMsg(finished):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 590, in _sendMsg
    for result in self._sendMsgThroughSocket(msgFragment):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/tlsrecordlayer.py", line 597, in _sendMsgThroughSocket
    for result in self._recordLayer.sendRecord(msg):
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 469, in sendRecord
    data = self._encryptThenSeal(data, contentType)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/recordlayer.py", line 417, in _encryptThenSeal
    buf = self._writeState.encContext.seal(nonce, buf, authData)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/chacha20_poly1305.py", line 55, in seal
    otk = self.poly1305_key_gen(self.key, nonce)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/chacha20_poly1305.py", line 36, in poly1305_key_gen
    poly = ChaCha(key, nonce)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/chacha.py", line 137, in __init__
    self.key = ChaCha._bytearray_to_words(key)
  File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/chacha.py", line 122, in _bytearray_to_words
    compat26Str(data[i*4:(i+1)*4])))
struct.error: unpack requires a string argument of length 4

@tomato42 any help appreciated

@tomato42
Copy link
Member

Which version have you installed through pip?

I can't reproduce it with current master/v0.6.0-beta1 (f9950c8), but I'm using python-2.7.5-48.el7. Which distribution are you using?

@sanderux
Copy link
Author

tlslite-ng==0.6.0-beta1

PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"

Linux ml 2.6.32-34-pve #1 SMP Fri Dec 19 07:42:04 CET 2014 x86_64 GNU/Linux

@sanderux
Copy link
Author

I could try it on ubuntu 16.04 tonight if that helps

@tomato42
Copy link
Member

tomato42 commented Aug 24, 2016

Travis-CI is running on Ubuntu: https://travis-ci.org/tomato42/tlslite-ng/jobs/152900519 and those tests are ran there...

I'll try with Debian

@tomato42
Copy link
Member

ok, so it looks like the Python 2.7.3 on Debian is closer to current Python 2.6 than to 2.7, try the code from PR #129 it should fix it

@sanderux
Copy link
Author

that fixed it, thnx

@tomato42 tomato42 added the bug unintented behaviour in tlslite-ng code label Aug 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unintented behaviour in tlslite-ng code
Projects
None yet
Development

No branches or pull requests

2 participants