You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importnacl.encodingimportnacl.signingmessage=b"Attack at Dawn"# Generate a new random signing keysigning_key=nacl.signing.SigningKey.generate()
# Sign a message with the signing keysigned=signing_key.sign(message, encoder=nacl.encoding.HexEncoder)
# Obtain the verify key for a given signing keyverify_key=signing_key.verify_key# Check the validity of a message's signature# The message and the signature can either be passed separately or# concatenated together. These are supposed to be equivalent:verify_key.verify(signed, encoder=nacl.encoding.HexEncoder) #this line verifiesverify_key.verify(signed.message, signed.signature, encoder=nacl.encoding.HexEncoder) #this line also verifies, since they are the sameprint("All is well")
This works fine.
However, if we change the encoding type to URLSafeBase64Encoder, as in the following minimum example
importnacl.encodingimportnacl.signingmessage=b"Attack at Dawn"# Generate a new random signing keysigning_key=nacl.signing.SigningKey.generate()
# Sign a message with the signing keysigned=signing_key.sign(message, encoder=nacl.encoding.URLSafeBase64Encoder)
# Obtain the verify key for a given signing keyverify_key=signing_key.verify_key# Check the validity of a message's signature# The message and the signature can either be passed separately or# concatenated together. These are supposed to be equivalent:verify_key.verify(signed, encoder=nacl.encoding.URLSafeBase64Encoder) #this line verifiesverify_key.verify(signed.message, signed.signature, encoder=nacl.encoding.URLSafeBase64Encoder) #THIS LINE DOES NOT VERIFYprint("All is well")
I get the following trace
Traceback (most recent call last):
File "testing_nacl.py", line 19, in <module>
verify_key.verify(signed.message, signed.signature, encoder=nacl.encoding.URLSafeBase64Encoder) #THIS LINE DOES NOT VERIFY
File "/home/username/.local/lib/python3.5/site-packages/nacl/signing.py", line 112, in verify
return nacl.bindings.crypto_sign_open(smessage, self._key)
File "/home/username/.local/lib/python3.5/site-packages/nacl/bindings/crypto_sign.py", line 111, in crypto_sign_open
raise exc.BadSignatureError("Signature was forged or corrupt")
nacl.exceptions.BadSignatureError: Signature was forged or corrupt
I think there is a bug with the URLSafeBase64Encoder in this case.
The text was updated successfully, but these errors were encountered:
This kind of weirdness is the reason why we are discussing, about removing support from the encoding= parameter since @alex comment in #504 (comment) and my later #523 PR.
I have been experimenting with pynacl (1.3.0) using python3 (3.5.2)
Using the examples on https://pynacl.readthedocs.io/en/stable/signing/, I construct this minimum example:
This works fine.
However, if we change the encoding type to URLSafeBase64Encoder, as in the following minimum example
I get the following trace
I think there is a bug with the URLSafeBase64Encoder in this case.
The text was updated successfully, but these errors were encountered: