Exception during sign. 'SHA512' object has no attribute 'oid'
See original GitHub issueI created a key pair like so:
> openssl genrsa -out key.pem 4096
> openssl rsa -in key.pem -pubout -out pubkey.pem
Then in the python REPL:
>>> from jwt.contrib.algorithms.pycrypto import RSAAlgorithm
>>> import jwt
>>> jwt.register_algorithm('RS512', RSAAlgorithm(RSAAlgorithm.SHA512))
>>> with open('.keys/key.pem') as fo: private_key_bytes = fo.read()
...
>>> result = jwt.encode({'name':'John'}, private_key_bytes, algorithm='RS512')
This raises an exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.10-intel/egg/jwt/api.py", line 103, in encode
File "build/bdist.macosx-10.10-intel/egg/jwt/contrib/algorithms/pycrypto.py", line 44, in sign
File "site-packages/Crypto/Signature/PKCS1_v1_5.py", line 110, in sign
em = EMSA_PKCS1_V1_5_ENCODE(mhash, k)
File "site-packages/Crypto/Signature/PKCS1_v1_5.py", line 211, in EMSA_PKCS1_V1_5_ENCODE
digestAlgo = DerSequence([hash.oid, DerNull().encode()])
AttributeError: 'SHA512' object has no attribute 'oid'
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
'NoneType' object has no attribute 'oid' while using ...
python - PyCrypto: Attribute Error: 'NoneType' object has no attribute 'oid' while using PKCS1_v1_5 - Stack Overflow. Stack Overflow for Teams ...
Read more >X.509 Reference — Cryptography 39.0.0.dev1 documentation
Returns the HashAlgorithm which was used in signing this certificate. Can be None if signature did not use separate hash ( ED25519 ,...
Read more >PyCryptodome Documentation - Read the Docs
A CBC cipher object has a read-only attribute iv, holding the Initialization Vector (bytes). Example (encryption):. >>> import json.
Read more >Bug #502291 “Support for PKCS#1 v1.5 signatures (RFC3447)”
This patch adds support for PKCS#1 v1.5 signatures. The sign() and verify() methods for an RSA key object are extended to accept an...
Read more >Changelog — PyCryptodome 3.11.0 documentation
Padding.unpad() was raising an incorrect exception in case of ... New attribute oid for Hash objects with ASN.1 Object ID; Added Crypto.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
PyCrypto just seems to be building badly in this virtualenv, so I’m going to close this. Thanks
I used pip installs instead of installing from cloned git repos.