[pycrypto] providing signature in base64
Cornelius Kölbel
cornelius.koelbel at lsexperts.de
Wed May 9 11:56:06 EDT 2012
Hi,
i discovered the number.bytes_to_long function, which does the trick,
but the signature validation still fails.
I assume I would have to b64decode my signature prior to converting it.
But it fails :-/
ret = RSAKey.verify(hash, (number.bytes_to_long(sign.decode("base64")),) )
print ret
ret = RSAKey.verify(hash, (number.bytes_to_long(base64.b64decode(sign)),))
print ret
Any hint on that?
The signature was created with openssl/M2Crypto.
And I'd like to mirgate to pycrypto.
Kind regards
Cornelius
Am 09.05.2012 16:28, schrieb Cornelius Kölbel:
> Hello,
>
> I have a signature provided in base64 like this:
>
> XQgVBkxrmJXqN2+xkJx8dGRecadoLi61vjBTsl+kYibji0pf6ZsxYF2ewniV7pIbtjQxxIridBRtLo9d1Rpq6QvjvuVbVzqqimQeFZnQTp9scSfAbKCtDe1F4lEWCLP6s/6op3jgPpmgd0p5kPaA4iWLM5IjleT7kxgniggBXIky1aMq4L8DtLujcfHNLeJyXpw9TDPg/2KEYZGT1WqiXIeIuYPt7UySOVnmgIoQYstu7C5Vsy5hjzBfhpVvKaPjXEDeETL4UoO2S9H+hu0x932HyyiNTYCpY9VFQnptsVtTkkOvEqhY3xxYix4nzeU+vXc4hFFnhAZMJbPYmuPy5w==
>
> but I am breaking my head how to pass this to the verify function.
>
> I create the RSA Object from a PEM encoded public key. This works fine.
>
> But when I try to unpack the base64 encoded signature, I do not get ONE
> long but a tuple with 32 long int.
>
> long_signature= struct.unpack('Q'*32, sign.decode("base64"))
> hash = sha256(licStr).digest()
> RSAKey = RSA.importKey(public)
> ret = RSAKey.verify(hash, long_signature)
>
> I know that this is more a matter of how to handle the unpack function,
> but did not find anything about this.
>
> Thanks a lot and kind regards
> Cornelius
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.dlitz.net/pipermail/pycrypto/attachments/20120509/b26bc819/attachment.pgp>
More information about the pycrypto
mailing list