PyCrypto 2.6: Crypto.SelfTest.Util.test_number.MiscTests.test_negative_number_roundtrip_mpzToLongObj_longObjToMPZ fails with disabled support for GMP and MPIR

Bug #1004781 reported by Arfrever Frehtes Taifersar Arahesis
50
This bug affects 7 people
Affects Status Importance Assigned to Milestone
Python-Crypto
Fix Committed
Undecided
Unassigned

Bug Description

In PyCrypto 2.6 Crypto.SelfTest.Util.test_number.MiscTests.test_negative_number_roundtrip_mpzToLongObj_longObjToMPZ() fails with disabled support for GMP and MPIR. This test was absent in PyCrypto 2.5.

$ ./configure --without-gmp --without-mpir
...
$ python2.7 setup.py build
...
$ python2.7 setup.py test
running test
...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................SelfTest: You can ignore the RandomPool_DeprecationWarning that follows.
........E...................
======================================================================
ERROR: test_negative_number_roundtrip_mpzToLongObj_longObjToMPZ (Crypto.SelfTest.Util.test_number.MiscTests)
Test that mpzToLongObj and longObjToMPZ (internal functions) roundtrip negative numbers correctly.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "build/lib.linux-x86_64-2.7/Crypto/SelfTest/Util/test_number.py", line 283, in test_negative_number_roundtrip_mpzToLongObj_longObjToMPZ
    k = number._fastmath.rsa_construct(n, e)
AttributeError: 'NoneType' object has no attribute 'rsa_construct'

----------------------------------------------------------------------
Ran 1031 tests in 208.341s

FAILED (errors=1)
Traceback (most recent call last):
  File "setup.py", line 456, in <module>
    core.setup(**kw)
  File "/usr/lib64/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "setup.py", line 336, in run
    SelfTest.run(module=moduleObj, verbosity=self.verbose, stream=sys.stdout, config=self.config)
  File "build/lib.linux-x86_64-2.7/Crypto/SelfTest/__init__.py", line 74, in run
    raise SelfTestError("Self-test failed", result)
Crypto.SelfTest.SelfTestError: ('Self-test failed', <unittest.runner.TextTestResult run=1031 errors=1 failures=0>)

Revision history for this message
Darsey Litzenberger (dlitz) wrote :

Thanks for the bug report.

Sebastian Ramacher fixed this bug in the following pull request:

  https://github.com/dlitz/pycrypto/pull/22
  https://github.com/sebastinas/pycrypto/commit/d31f7df39a6d3db73a16909de4669d337b69c40c

It's now been merged into the pycrypto master branch.

Changed in pycrypto:
status: New → Incomplete
status: Incomplete → Fix Committed
Revision history for this message
Anil (anil-philip) wrote :

With help from the mpir dev list, I built mpir.lib Do you know where I should put it in pycrypto-2.6 ?
I ask because they are all python files so it is not clear where I should drop in a lib file.
building mpir:
For those wanting to build a newer version of mpir, just go to mpir-2.5.1\win and run the two batch files in a command window. You will need to download yasm, rename and copy over yasm.exe to C:\Program Files\Microsoft Visual Studio 9.0\VC\bin.

Revision history for this message
Peter Munch-Ellingsen (peterme) wrote :

I'm still getting this bug in the latest version (2.6.1)

Revision history for this message
oraclemaster (mauro-rospocher) wrote :

I'm still getting this bug in the latest version (2.6.1).

Revision history for this message
Akos Csurai (ethcsak) wrote :

At redhat I had to install
yum install gmp-devel
after
./configure
python setup.py build
...
building 'Crypto.PublicKey._fastmath' extension
....
python setup.py install
python setup.py test
...
running test
............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................SelfTest: You can ignore the RandomPool_DeprecationWarning that follows.
..............................
----------------------------------------------------------------------
Ran 1066 tests in 9.664s

OK

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.