[pycrypto] same RSA.construct fails on OSX
antoine at nagafix.co.uk
Fri Jan 20 11:04:27 EST 2012
On 01/20/2012 10:22 PM, Legrandin wrote:
> Hi Antoine,
>> I've just found that simply removing p (or 'd' as it should be called..)
>> is enough to fix it, so the code becomes:
>> if d==0:
>> k = RSA.construct((long(m), long(e)))
>> k = RSA.construct((long(m), long(e), long(d)))
> In the first case you generate a public key no matter which library
> you have installed.
> In the second case you generate a private key, but only if you are on 2.5.
What do you think is meant to happen with versions prior to 2.5?
This exact code has been behaving as expected for years. The resulting
private key has been used with other libraries (bouncy castle for one).
> Do you need a public key or a private key?
As per above, public if d==0, private otherwise.
> If you need a public key, just use 2 arguments.
Yes, the only change needed here for 2.5 is that the third argument
cannot be specified with a value of 0 as was the case previously.
> If you need a private key and you want it to work with all pycrypto
> versions, go and look for the remaining 2 parameters (p and q)... ;-)
>>> With previous version you had to provide at least 5 elements,
>>> m+e+d+p+q (I don't recall how they complain if you provide only 3).
>> According to the docs, it's 2 minimum (as above), anyone know if the
>> code above is going to have problems running on distros with old
>> versions of pycrypto?
> I would simply assume it will have problem with previous versions:
> it's clearly off spec for them.
For the record, it works OK with the default values for p and q, even
with previous versions which is great.
More information about the pycrypto