[pycrypto] Why p<q in RSA code?

Legrandin gooksankoo at hoiptorrow.mailexpire.com
Wed Jan 19 03:41:39 CST 2011


Hi all,

I have noticed that - when generating an RSA key - a special check is
made to ensure that p<q.
Why is it so?

One comment says "# p shall be smaller than q (for calc of u)", but if
I look at CRT and Garner's algorithms,
there are no requirments on ordering of prime factors. They seem to
work also when p>q.

Is it because Crypto.Util.number.inverse(u,v) requires u<v?
I cannot try it right now, but that is the only explaination I could think of.


More information about the pycrypto mailing list