0

I'm trying to use openssl in python that is cross compiled to run on ARM. For some reason the sha hashing methods are not found. In the python console, I type:

import hashlib

ERROR:root:code for hash sha1 was not found. Traceback (most recent call last):   File "/usr/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)   File "/usr/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha1 ERROR:root:code for hash sha224 was not found. Traceback (most recent call last):   File "/usr/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)   File "/usr/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha224 ERROR:root:code for hash sha256 was not found. Traceback (most recent call last):   File "/usr/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)   File "/usr/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha256 ERROR:root:code for hash sha384 was not found. Traceback (most recent call last):   File "/usr/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)   File "/usr/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha384 ERROR:root:code for hash sha512 was not found. Traceback (most recent call last):   File "/usr/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)   File "/usr/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha512

and if I type it again, I do not get any error message. That is one issue. But the more significant problem is that when I type:

from hashlib import sha1 as sha

I get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name sha1

Any ideas or hints as to where sha is supposed to be implemented? Even sha.py is trying to import sha1 from hashlib.

Another piece of information: When I type "dir(hashlib)" I get

['__all__', '__builtins__', '__doc__', '__file__', '__get_builtin_constructor', '__name__', '__package__', 'algorithms', 'logging', 'md5', 'new']
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
max
  • 9,708
  • 15
  • 89
  • 144
  • possible duplicate of [unsupported hash type when installing plone](http://stackoverflow.com/questions/11433108/unsupported-hash-type-when-installing-plone) – Martijn Pieters Aug 22 '13 at 23:31
  • The reason you don't get any message when you type it again is that `import foo` does nothing if `foo` is already imported. (Well, it effectively does `foo = sys.modules['foo']`… but the point is, it doesn't recompile it or rerun the module-level code.) – abarnert Aug 22 '13 at 23:36
  • Anyway, clearly sha1 is _not_ implemented, so it's not a matter of where to find it, it's a matter of what to install and what to rebuild and how, so it _will_ be implemented. Then you'll be able to access it the same way as always. – abarnert Aug 22 '13 at 23:37
  • It works fine on ubuntu but one of my cross compiled packages has a problem; I was hoping that someone could guide me to track down which package needs to be re-cross compiled. – max Aug 22 '13 at 23:50
  • @max: Did you read the duplicate question Martijn Pieters linked? OpenSSL seems like a pretty likely candidate, so I'd certainly start there first. It may also just be a matter of the way you've configured the Python cross-compile not picking up OpenSSL, if you already have it. – abarnert Aug 23 '13 at 01:07
  • Yes, I read that. I have the openssl system library (version 1.0.0). Before running into the hashlib problem, I was running into errors complaining that my openSLL is version 1 but version 0.9.8 is expected...I fixed that. My understanding is that openSSL uses hashlib not the other way. Am I wrong about that? – max Aug 23 '13 at 15:52

0 Answers0