[pycrypto] same RSA.construct fails on OSX

Legrandin gooksankoo at hoiptorrow.mailexpire.com
Fri Jan 20 10:22:50 EST 2012

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)))
> else:
>  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.

Do you need a public key or a private key?

If you need a public key, just use 2 arguments.
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.

More information about the pycrypto mailing list