Re: LIBTOMMATH Test of Montgomery Reduce



On Oct 2, 3:53 pm, Wolfgang.Ehrhardt.PLEASE.REM...@xxxxxxxxxxxxxxxxx
(Wolfgang Ehrhardt) wrote:
On Thu, 2 Oct 2008 09:31:51 -0700 (PDT), amzoti <amz...@xxxxxxxxx>
wrote:





Hi All,

I am hoping that someone that is familiar with libtommath can help
provide guidance or a number to make this work.

There is a routine called bn_mp_montgomery_reduce.c that computes
xR**-1 == x (mod N) via Montgomery Reduction.

The API call mp_montgomery_reduce (x, n, rho) where rho is calculated
by another routine and passed in.

The output is supposed to (beta^(-k) * x) (mod n).

The part of the code that I would like exercised is:

/* if x >= n then x = x - n */
if x >= n then x = x - n
if (mp_cmp_mag (x, n) != MP_LT)  {return s_mp_sub (x, n, x);}

I want the x and n to force the code down the path so that return
statement s+mp_sub(x, n, x) gets exercised.

Basically, I would like an x and an n that does that.

Any ideas or recommendations? (So far - no luck in what I have tried.)

Thanks for any insights!

I guess you are still using DIGIT_BIT=28. With my Pascal version I hit
that statement for

6140126413594^8416471601616 mod 48576280861410361

where ^ is the power operator. Don't know if the C code will hit it
too. But you should have an test case file for exptmod. If not, get
one (and many other) test file(s) from my MPArith archive.

Hope that helps
Wolfgang



~A

--
In order to e-mail me a reply to this message, you will have
to remove PLEASE.REMOVE from the address shown in the header
or get it fromhttp://home.netsurf.de/wolfgang.ehrhardt
(Free open source Crypto, AES, CRC, Hash for Pascal/Delphi)- Hide quoted text -

- Show quoted text -

Wolfgang - thanks a bunch!

I will give that a try and I appreciate your responses!

~A
.