On Fri, Dec 03, 2010 at 01:43:17PM -0500, Victor Duchovni wrote:
> I don't understand the code in BN_nist_mod_192(), which calls
> nist_cp_bn(), it has rather obscure pointer manipulation:
>
> /*
> * we need 'if (carry==0 || result>=modulus) result-=modulus;'
> * as comparison implies subtraction, we can write
> * 'tmp=result-modulus; if (!carry || !borrow) result=tmp;'
> * this is what happens below, but without explicit if:-) a.
> */
> mask =
> 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP);
> mask &= 0-(size_t)carry;
> ---> res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask));
> nist_cp_bn(r_d, res, BN_NIST_192_TOP);
On closer inspection, the mask is expected to always be all zeros or
all ones, so this should select the value of one of the two pointers,
assuming this is twos-complement arithmentic and (0-1) is 0xffff...fff
then res should be either "c_d" or "r_d". Somehow this did not work
for you compiler. You may need to report what assembly code this
produced and see where things went wrong...
--
Viktor.
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [email protected]
Automated List Manager [email protected]