1 -----BEGIN PGP SIGNED MESSAGE-----
4 - --- openssl-0.9.8e/crypto/bn/bn_mont.c 2006-06-16 03:01:14.000000000 +0200
5 +++ openssl-0.9.8-cvs/crypto/bn/bn_mont.c 2007-06-29 10:13:25.000000000 +0200
8 max=(nl+al+1); /* allow for overflow (no?) XXX */
9 if (bn_wexpand(r,max) == NULL) goto err;
10 - - if (bn_wexpand(ret,max) == NULL) goto err;
18 - - /* mont->ri will be a multiple of the word size */
20 - - BN_rshift(ret,r,mont->ri);
22 - - ret->neg = r->neg;
24 + /* mont->ri will be a multiple of the word size and below code
25 + * is kind of BN_rshift(ret,r,mont->ri) equivalent */
34 +# define BRANCH_FREE 1
36 + if (bn_wexpand(ret,ri) == NULL) goto err;
37 + x=0-(((al-ri)>>(sizeof(al)*8-1))&1);
38 + ret->top=x=(ri&~x)|(al&x); /* min(ri,al) */
52 + v=bn_sub_words(rp,ap,np,ri);
53 + /* this ----------------^^ works even in al<ri case
54 + * thanks to zealous zeroing of top of the vector in the
57 + /* if (al==ri && !v) || al>ri) nrp=rp; else nrp=ap; */
58 + /* in other words if subtraction result is real, then
59 + * trick unconditional memcpy below to perform in-place
60 + * "refresh" instead of actual copy. */
61 + m1=0-(size_t)(((al-ri)>>(sizeof(al)*8-1))&1); /* al<ri */
62 + m2=0-(size_t)(((ri-al)>>(sizeof(al)*8-1))&1); /* al>ri */
63 + m1|=m2; /* (al!=ri) */
64 + m1|=(0-(size_t)v); /* (al!=ri || v) */
65 + m1&=~m2; /* (al!=ri || v) && !al>ri */
66 + nrp=(BN_ULONG *)(((size_t)rp&~m1)|((size_t)ap&m1));
69 + /* 'i<ri' is chosen to eliminate dependency on input data, even
70 + * though it results in redundant copy in al<ri case. */
71 + for (i=0,ri-=4; i<ri; i+=4)
73 + BN_ULONG t1,t2,t3,t4;
77 + t3=nrp[i+2]; ap[i+0]=0;
78 + t4=nrp[i+3]; ap[i+1]=0;
79 + rp[i+0]=t1; ap[i+2]=0;
80 + rp[i+1]=t2; ap[i+3]=0;
84 + for (ri+=4; i<ri; i++)
85 + rp[i]=nrp[i], ap[i]=0;
87 + if (bn_wexpand(ret,al) == NULL) goto err;
102 #else /* !MONT_WORD */
105 @@ -278,10 +328,12 @@
106 if (!BN_rshift(ret,t2,mont->ri)) goto err;
107 #endif /* MONT_WORD */
109 +#if !defined(BRANCH_FREE) || BRANCH_FREE==0
110 if (BN_ucmp(ret, &(mont->N)) >= 0)
112 if (!BN_usub(ret,ret,&(mont->N))) goto err;
118 -----BEGIN PGP SIGNATURE-----
119 Version: GnuPG v1.4.5 (GNU/Linux)
121 iQCVAwUBRrGk++6tTP1JpWPZAQJbjwP/W/6mROtxOVU1gvvq/uFHCytNWHVaJfKA
122 7zh+v4OPQEIYekIBkEpNFgTJbHcyIZoyDNnwOetkRXvI4LDqvV1V5/pA5bzrKqDj
123 zv7Hj8R7DGqG8ad0Esf3l7SqqirI3curkIzm5/cALJBJxz/Pp7qyXNzzQgp55UPz
126 -----END PGP SIGNATURE-----