[ pycrypto-Bugs-1251206 ] Traceback unpickling DSA keys if _fastmath.so unavailable

"SourceForge.net" <[email protected]> Wed, 03 Aug 2005 11:03:53 -0700
Newsgroups gmane.comp.python.cryptography.cvs
Message-ID <[email protected]>
Bugs item #1251206, was opened at 2005-08-03 11:03
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=120937&aid=1251206&group_id=20937

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: matt chisholm (glyphobet)
Assigned to: Nobody/Anonymous (nobody)
Summary: Traceback unpickling DSA keys if _fastmath.so unavailable

Initial Comment:
If I create a DSA key and save the public and private
keys to a file using pickle.dump() on a system where
Crypto.PublicKey._fastmath is available:


import pickle
from Crypto.PublicKey import DSA as pklib
from Crypto.Util import randpool
r = randpool.KeyboardRandomPool()
r.randomize()
pub_key_file = open(pub_key_path, 'wb')
pri_key_file = open(pri_key_path, 'wb')
r.add_event()
key = pklib.generate(2**10, r.get_bytes)
pickle.dump(key            , pri_key_file, protocol=2)
pickle.dump(key.publickey(), pub_key_file, protocol=2)


then I cannot pickle.load() those keys on another
system where _fastmath is not available. 


private_key_file = open(pri_key_path, 'rb')
key = pickle.load(private_key_file)


Instead, I get the following traceback:


Traceback (most recent call last):
  File "auto-update/sign_file.py", line 15, in ?
    key = pickle.load(private_key_file)
  File "/usr/lib/python2.3/pickle.py", line 1390, in load
    return Unpickler(file).load()
  File "/usr/lib/python2.3/pickle.py", line 872, in load
    dispatch[key](self)
  File "/usr/lib/python2.3/pickle.py", line 1237, in
load_build
    setstate(state)
  File
"/usr/lib/python2.3/site-packages/Crypto/PublicKey/DSA.py",
line 202, in __setstate__
    self.key = _fastmath.dsa_construct(y,g,p,q,x)
AttributeError: 'NoneType' object has no attribute
'dsa_construct'


If I create the DSA keys on a system without _fastmath,
I can load them on the system with _fastmath with no
problems.


Versions:

System #1:
Linux 2.4.26 debian testing, all stock packages
Python 2.3.5 (#2, May 29 2005, 00:34:43)
[GCC 3.3.6 (Debian 1:3.3.6-5)] on linux2
pycrypto 2.0+dp1-2
_fastmath.so available

System #2:
Linux 2.6.10-5-686 ubuntu hoary, all stock packages
Python 2.4.1 (#2, Mar 30 2005, 21:51:10)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
pycrypto 2.0+dp1-2ubuntu1
_fastmath.so *not* available

System #3:
Windows XP SP2
Python 2.3.4 (from python.org)
pycrypto 2.0 (from http://twisted.sourceforge.net/contrib/)
_fastmath.so *not* available

Please contact me if you need more information.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=120937&aid=1251206&group_id=20937


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click