1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE> [pycrypto] providing signature in base64
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:pycrypto%40lists.dlitz.net?Subject=Re%3A%20%5Bpycrypto%5D%20providing%20signature%20in%20base64&In-Reply-To=%3C4FAA9396.9090603%40lsexperts.de%3E">
<META NAME="robots" CONTENT="index,nofollow">
<style type="text/css">
pre {
white-space: pre-wrap; /* css-2.1, curent FF, Opera, Safari */
}
</style>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="000579.html">
<LINK REL="Next" HREF="000581.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[pycrypto] providing signature in base64</H1>
<B>Cornelius Kölbel</B>
<A HREF="mailto:pycrypto%40lists.dlitz.net?Subject=Re%3A%20%5Bpycrypto%5D%20providing%20signature%20in%20base64&In-Reply-To=%3C4FAA9396.9090603%40lsexperts.de%3E"
TITLE="[pycrypto] providing signature in base64">cornelius.koelbel at lsexperts.de
</A><BR>
<I>Wed May 9 11:56:06 EDT 2012</I>
<P><UL>
<LI>Previous message: <A HREF="000579.html">[pycrypto] providing signature in base64
</A></li>
<LI>Next message: <A HREF="000581.html">[pycrypto] providing signature in base64
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#580">[ date ]</a>
<a href="thread.html#580">[ thread ]</a>
<a href="subject.html#580">[ subject ]</a>
<a href="author.html#580">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>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:
><i> Hello,
</I>><i>
</I>><i> I have a signature provided in base64 like this:
</I>><i>
</I>><i> XQgVBkxrmJXqN2+xkJx8dGRecadoLi61vjBTsl+kYibji0pf6ZsxYF2ewniV7pIbtjQxxIridBRtLo9d1Rpq6QvjvuVbVzqqimQeFZnQTp9scSfAbKCtDe1F4lEWCLP6s/6op3jgPpmgd0p5kPaA4iWLM5IjleT7kxgniggBXIky1aMq4L8DtLujcfHNLeJyXpw9TDPg/2KEYZGT1WqiXIeIuYPt7UySOVnmgIoQYstu7C5Vsy5hjzBfhpVvKaPjXEDeETL4UoO2S9H+hu0x932HyyiNTYCpY9VFQnptsVtTkkOvEqhY3xxYix4nzeU+vXc4hFFnhAZMJbPYmuPy5w==
</I>><i>
</I>><i> but I am breaking my head how to pass this to the verify function.
</I>><i>
</I>><i> I create the RSA Object from a PEM encoded public key. This works fine.
</I>><i>
</I>><i> But when I try to unpack the base64 encoded signature, I do not get ONE
</I>><i> long but a tuple with 32 long int.
</I>><i>
</I>><i> long_signature= struct.unpack('Q'*32, sign.decode("base64"))
</I>><i> hash = sha256(licStr).digest()
</I>><i> RSAKey = RSA.importKey(public)
</I>><i> ret = RSAKey.verify(hash, long_signature)
</I>><i>
</I>><i> I know that this is more a matter of how to handle the unpack function,
</I>><i> but did not find anything about this.
</I>><i>
</I>><i> Thanks a lot and kind regards
</I>><i> Cornelius
</I>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <<A HREF="http://lists.dlitz.net/pipermail/pycrypto/attachments/20120509/b26bc819/attachment.pgp">http://lists.dlitz.net/pipermail/pycrypto/attachments/20120509/b26bc819/attachment.pgp</A>>
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="000579.html">[pycrypto] providing signature in base64
</A></li>
<LI>Next message: <A HREF="000581.html">[pycrypto] providing signature in base64
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#580">[ date ]</a>
<a href="thread.html#580">[ thread ]</a>
<a href="subject.html#580">[ subject ]</a>
<a href="author.html#580">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto">More information about the pycrypto
mailing list</a><br>
</body></html>
|