ispell (and minor modifications)
[openssl.git] / crypto / bn / bn_mont.c
index 63db5776818aa6012bc531b168ed955d097893e3..dd691112c2f77cacfc30c0ea2057dc920d53f2db 100644 (file)
  */
 
 /*
- * Details about Montgomery multiplication algorithms can be found at:
- * http://www.ece.orst.edu/ISL/Publications.html
- * http://www.ece.orst.edu/ISL/Koc/papers/j37acmon.pdf
+ * Details about Montgomery multiplication algorithms can be found at
+ * http://security.ece.orst.edu/publications.html, e.g.
+ * http://security.ece.orst.edu/koc/papers/j37acmon.pdf and
+ * sections 3.8 and 4.2 in http://security.ece.orst.edu/koc/papers/r01rsasw.pdf
  */
 
 #include <stdio.h>
@@ -287,7 +288,7 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
 
                mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;
                BN_zero(R);
-               BN_set_bit(R,BN_BITS2);                 /* R = 2^ri */
+               BN_set_bit(R,BN_BITS2);                 /* R */
 
                buf[0]=mod->d[0]; /* tmod = N mod word size */
                buf[1]=0;
@@ -303,7 +304,8 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
                        BN_sub_word(&Ri,1);
                else /* if N mod word size == 1 */
                        BN_set_word(&Ri,BN_MASK2);  /* Ri-- (mod word size) */
-               BN_div(&Ri,NULL,&Ri,&tmod,ctx);          /* Ni = (R*Ri-1)/N */
+               BN_div(&Ri,NULL,&Ri,&tmod,ctx); /* Ni = (R*Ri-1)/N,
+                                                * keep only least significant word: */
                mont->n0=Ri.d[0];
                BN_free(&Ri);
                }