X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=crypto%2Fbn%2Fbn_mulw.c;h=abfc7e4d6c29c7c51f479c9c8fa656598fd183bb;hb=58964a492275ca9a59a0cd9c8155cb2491b4b909;hp=d9031273953ecb3414112128e604187c72c2e004;hpb=d02b48c63a58ea4367a0e905979f140b7d090f86;p=thirdparty%2Fopenssl.git diff --git a/crypto/bn/bn_mulw.c b/crypto/bn/bn_mulw.c index d903127395..abfc7e4d6c 100644 --- a/crypto/bn/bn_mulw.c +++ b/crypto/bn/bn_mulw.c @@ -1,5 +1,5 @@ /* crypto/bn/bn_mulw.c */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written @@ -62,7 +62,7 @@ #ifdef BN_LLONG -BN_ULONG bn_mul_add_word(rp,ap,num,w) +BN_ULONG bn_mul_add_words(rp,ap,num,w) BN_ULONG *rp,*ap; int num; BN_ULONG w; @@ -86,7 +86,7 @@ BN_ULONG w; return(c1); } -BN_ULONG bn_mul_word(rp,ap,num,w) +BN_ULONG bn_mul_words(rp,ap,num,w) BN_ULONG *rp,*ap; int num; BN_ULONG w; @@ -138,9 +138,45 @@ int n; } } +BN_ULONG bn_add_words(r,a,b,n) +BN_ULONG *r,*a,*b; +int n; + { + BN_ULLONG ll; + + ll=0; + for (;;) + { + ll+= (BN_ULLONG)a[0]+b[0]; + r[0]=(BN_ULONG)ll&BN_MASK2; + ll>>=BN_BITS2; + if (--n <= 0) break; + + ll+= (BN_ULLONG)a[1]+b[1]; + r[1]=(BN_ULONG)ll&BN_MASK2; + ll>>=BN_BITS2; + if (--n <= 0) break; + + ll+= (BN_ULLONG)a[2]+b[2]; + r[2]=(BN_ULONG)ll&BN_MASK2; + ll>>=BN_BITS2; + if (--n <= 0) break; + + ll+= (BN_ULLONG)a[3]+b[3]; + r[3]=(BN_ULONG)ll&BN_MASK2; + ll>>=BN_BITS2; + if (--n <= 0) break; + + a+=4; + b+=4; + r+=4; + } + return(ll&BN_MASK2); + } + #else -BN_ULONG bn_mul_add_word(rp,ap,num,w) +BN_ULONG bn_mul_add_words(rp,ap,num,w) BN_ULONG *rp,*ap; int num; BN_ULONG w; @@ -167,7 +203,7 @@ BN_ULONG w; return(c); } -BN_ULONG bn_mul_word(rp,ap,num,w) +BN_ULONG bn_mul_words(rp,ap,num,w) BN_ULONG *rp,*ap; int num; BN_ULONG w; @@ -217,6 +253,33 @@ int n; } } +BN_ULONG bn_add_words(r,a,b,n) +BN_ULONG *r,*a,*b; +int n; + { + BN_ULONG t1,t2; + int carry,i; + + carry=0; + for (i=0; i= ((~t1)&BN_MASK2)); + t2=(t1+t2+1)&BN_MASK2; + } + else + { + t2=(t1+t2)&BN_MASK2; + carry=(t2 (BN_ULONG)1<