Montgomery abbreviation form using OpenSSL library

I have N of 1024 bits. I need to convert M (512 bit) message to Montgomery abbreviation form as shown below.

M '= M * R ^ {- 1} mod N

where R = 2 ^ 512 (mod N)

How can I achieve the result?

+3


source to share


1 answer


The following should work if you are using the bignum package from OpenSSL directly.

Use a function BN_mod_exp

to calculate your R = 2 ^ 512 (mod N).

Then you compute the modulo multiplicative inverse of R by calling BN_mod_inverse

. This will give you R ^ -1.



Once done, you just compute your M 'by calling BN_mod_mul

to perform the multiplication using the R ^ -1 you just computed and your original message.

You will find the features mentioned above in the OpenSSL BigNum package. They are in the include file: openssl / bn.h

+2


source







All Articles