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

Error signing with RS256 #24

Open
damjtoh opened this issue Mar 21, 2016 · 1 comment
Open

Error signing with RS256 #24

damjtoh opened this issue Mar 21, 2016 · 1 comment

Comments

@damjtoh
Copy link

damjtoh commented Mar 21, 2016

>>> import jws
>>> header = {'alg': 'RS256'}
>>> payload = { 'claim': 'JSON is the raddest.', 'iss': 'brianb' }
>>> signature = jws.sign(header, payload, 'secret')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/jws/__init__.py", line 29, in sign
    signature = signer(_signing_input(head, payload, is_json), key)
  File "/Library/Python/2.7/site-packages/jws/algos.py", line 74, in sign
    return self.padder.new(key).sign(self.hashm)             # pycrypto 2.5
  File "build/bdist.macosx-10.10-intel/egg/Crypto/Signature/PKCS1_v1_5.py", line 106, in sign
AttributeError: 'str' object has no attribute 'n'

I couldn't find anything related to this issue.
I have pycrypto 2.6.1

Thanks.

@ender672
Copy link

@damjtoh - I got that error too when I tried passing a string as the secret key.

Try this:

from Crypto.PublicKey import RSA
key = RSA.importKey('secret')
...
signature = jws.sign(header, payload, key)

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

2 participants