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

Tests are broken #75

Open
kpcyrd opened this issue Sep 28, 2019 · 4 comments
Open

Tests are broken #75

kpcyrd opened this issue Sep 28, 2019 · 4 comments

Comments

@kpcyrd
Copy link

kpcyrd commented Sep 28, 2019

I'm getting the following from ./run_tests.sh on archlinux:

testDecodeMpi (testBasic.ProtoTest) ... passed
testEncodeMpi (testBasic.ProtoTest) ... passed
testGenericMsg (testBasic.ProtoTest) ... passed
testGenericTLV (testBasic.ProtoTest) ... passed
testPackData (testBasic.ProtoTest) ... passed
testQuery (testBasic.ProtoTest) ... passed
testUnpackData (testBasic.ProtoTest) ... passed
test_AESCTR_counter_counter (test_compatcrypto.CompatCryptoTest) ... ERROR
test_AESCTR_default_counter (test_compatcrypto.CompatCryptoTest) ... ERROR
test_AESCTR_number_counter (test_compatcrypto.CompatCryptoTest) ... ERROR
test_SHA1 (test_compatcrypto.CompatCryptoTest) ... passed
test_SHA1HMAC (test_compatcrypto.CompatCryptoTest) ... passed
test_SHA256 (test_compatcrypto.CompatCryptoTest) ... passed
test_SHA256HMAC (test_compatcrypto.CompatCryptoTest) ... passed
test_getrandbits (test_compatcrypto.CompatCryptoTest) ... passed
test_randrange (test_compatcrypto.CompatCryptoTest) ... passed
test_SHA256HMAC160 (test_crypt.CryptTest) ... passed
test_conversation (test_otr.OtrTest) ... ERROR
======================================================================
1) ERROR: test_AESCTR_counter_counter (test_compatcrypto.CompatCryptoTest)
----------------------------------------------------------------------
   Traceback (most recent call last):
    tests/test_compatcrypto.py line 67 in test_AESCTR_counter_counter
      aes_encrypter = potr.compatcrypto.AESCTR(key, potr.compatcrypto.Counter(2013))
    src/potr/compatcrypto/pycrypto.py line 51 in AESCTR
      return Cipher.AES.new(key, Cipher.AES.MODE_CTR, counter=counter)
    /usr/lib/python3.7/site-packages/Crypto/Cipher/AES.py line 232 in new
      return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
    /usr/lib/python3.7/site-packages/Crypto/Cipher/__init__.py line 79 in _create_cipher
      return modes[mode](factory, **kwargs)
    /usr/lib/python3.7/site-packages/Crypto/Cipher/_mode_ctr.py line 366 in _create_ctr_cipher
      _counter = dict(counter)
   TypeError: 'Counter' object is not iterable
======================================================================
2) ERROR: test_AESCTR_default_counter (test_compatcrypto.CompatCryptoTest)
----------------------------------------------------------------------
   Traceback (most recent call last):
    tests/test_compatcrypto.py line 47 in test_AESCTR_default_counter
      aes_encrypter = potr.compatcrypto.AESCTR(key)
    src/potr/compatcrypto/pycrypto.py line 51 in AESCTR
      return Cipher.AES.new(key, Cipher.AES.MODE_CTR, counter=counter)
    /usr/lib/python3.7/site-packages/Crypto/Cipher/AES.py line 232 in new
      return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
    /usr/lib/python3.7/site-packages/Crypto/Cipher/__init__.py line 79 in _create_cipher
      return modes[mode](factory, **kwargs)
    /usr/lib/python3.7/site-packages/Crypto/Cipher/_mode_ctr.py line 366 in _create_ctr_cipher
      _counter = dict(counter)
   TypeError: 'Counter' object is not iterable
======================================================================
3) ERROR: test_AESCTR_number_counter (test_compatcrypto.CompatCryptoTest)
----------------------------------------------------------------------
   Traceback (most recent call last):
    tests/test_compatcrypto.py line 57 in test_AESCTR_number_counter
      aes_encrypter = potr.compatcrypto.AESCTR(key, 2010)
    src/potr/compatcrypto/pycrypto.py line 51 in AESCTR
      return Cipher.AES.new(key, Cipher.AES.MODE_CTR, counter=counter)
    /usr/lib/python3.7/site-packages/Crypto/Cipher/AES.py line 232 in new
      return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
    /usr/lib/python3.7/site-packages/Crypto/Cipher/__init__.py line 79 in _create_cipher
      return modes[mode](factory, **kwargs)
    /usr/lib/python3.7/site-packages/Crypto/Cipher/_mode_ctr.py line 366 in _create_ctr_cipher
      _counter = dict(counter)
   TypeError: 'Counter' object is not iterable
======================================================================
4) ERROR: test_conversation (test_otr.OtrTest)
----------------------------------------------------------------------
   Traceback (most recent call last):
    tests/test_otr.py line 74 in test_conversation
      post_office.send('bob', message1)
    tests/test_otr.py line 20 in send
      self.mailboxes[address](message)
    tests/test_otr.py line 64 in to_bob
      msg, _ = bob_alice.receiveMessage(message)
    src/potr/context.py line 196 in receiveMessage
      self.handleQuery(message, appdata=appdata)
    src/potr/context.py line 392 in handleQuery
      self.authStartV2(appdata=appdata)
    src/potr/context.py line 400 in authStartV2
      self.crypto.startAKE(appdata=appdata)
    src/potr/crypt.py line 264 in startAKE
      self.ake = AuthKeyExchange(self.ctx.user.getPrivkey(), self.goEncrypted)
    src/potr/context.py line 525 in getPrivkey
      self.privkey = compatcrypto.generateDefaultKey()
    src/potr/compatcrypto/common.py line 35 in generateDefaultKey
      return pkTypes[DEFAULT_KEYTYPE].generate()
    src/potr/compatcrypto/pycrypto.py line 131 in generate
      return cls((privkey.key.y, privkey.key.g, privkey.key.p, privkey.key.q,
    /usr/lib/python3.7/site-packages/Crypto/PublicKey/DSA.py line 206 in __getattr__
      raise AttributeError(item)
   AttributeError: key
   -------------------- >> begin captured logging << --------------------
   potr.context: DEBUG: <proto.Query(versions={2})>
   --------------------- >> end captured logging << ---------------------

-----------------------------------------------------------------------------
18 tests run in 0.479 seconds. 
4 errors (14 tests passed)
@koolfy
Copy link
Contributor

koolfy commented Nov 25, 2019

Looks a lot like what I got the very first time I tried to run potr with pycryptodome instead of the pycrypto lib that was the default back then :)

If that's so, I know, I'm working on it (so slowly that it's hard to measure though...). work is being done in this separate branch: https://github.com/python-otr/pure-python-otr/tree/bugfix/issue%2368-use-pycryptodome

My original intent was to not break the master, but from what I understand Arch and other distros are phasing out pycrypto in favor of pycryptodome (which is good) as it's (mostly) a drop-in replacement (which it actually isn't entirely, but everytime I see a change, it was for the BETTER, honestly.)

So the way I see it, the current master is broken by default, and I'm sure if I check with the PoeZio guys and other people using potr in real life, I'm convinced they resort to making it work with some python environment packaging voodoo that they would all want to stop doing...

I'm verbosely tracking my progress on that front in this issue: #68
I would close this issue as duplicate, but I don't want to appear rude or anything :(

It breaks my heart that I still don't have a potr working against pycryptodome, so if you want to check my ramblings on the other issue and the current state of the pycryptodome branch, and give a hand, you'd make a lot of people very happy! Not just me :)

@koolfy
Copy link
Contributor

koolfy commented Nov 25, 2019

Yeah, the hacks to work around the pycryptodome incompatibility are very real: NixOS/nixpkgs#62743

@SoapGentoo
Copy link

This is really important for Gentoo too: pure-python-otr is the last remaining consumer of pycrypto in Gentoo, and if this doesn't get fixed at some point, we will have to remove pure-python-otr from the Gentoo repositories.

@koolfy
Copy link
Contributor

koolfy commented May 8, 2020

I understand, I'm working on it, sorry it's being so slow it's entirely my fault :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants