Loading crypto/bn/bn.h +2 −2 Original line number Diff line number Diff line Loading @@ -330,7 +330,7 @@ int BN_bn2mpi(const BIGNUM *a, unsigned char *to); int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b); int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); Loading crypto/bn/bn_add.c +2 −2 Original line number Diff line number Diff line Loading @@ -61,9 +61,9 @@ #include "bn_lcl.h" /* r can == a or b */ int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b) int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) { BIGNUM *tmp; const BIGNUM *tmp; bn_check_top(a); bn_check_top(b); Loading crypto/bn/bn_lib.c +5 −0 Original line number Diff line number Diff line Loading @@ -341,6 +341,11 @@ void BN_CTX_free(BN_CTX *c) Free(c); } /* This is an internal function that should not be used in applications. * It ensures that 'b' has enough room for a 'bits' bit number. It is * mostly used by the various BIGNUM routines. If there is an error, * NULL is returned. if not, 'b' is returned. */ BIGNUM *bn_expand2(BIGNUM *b, int words) { BN_ULONG *A,*a; Loading crypto/bn/bn_prime.c +17 −12 Original line number Diff line number Diff line Loading @@ -225,8 +225,6 @@ err: return(ret); } #define RECP_MUL_MOD static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx, BN_CTX *ctx2, BN_MONT_CTX *mont) { Loading Loading @@ -408,18 +406,22 @@ err: } #if 0 static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx) #define RECP_MUL_MOD static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx, BN_CTX *unused, BN_MONT_CTX *unused2) { int k,i,nb,ret= -1; int k,i,ret= -1; BIGNUM *d,*dd,*tmp; BIGNUM *d1,*d2,*x,*n1,*inv; BIGNUM *d1,*d2,*x,*n1; BN_RECP_CTX recp; d1= &(ctx->bn[ctx->tos]); d2= &(ctx->bn[ctx->tos+1]); x= &(ctx->bn[ctx->tos+2]); n1= &(ctx->bn[ctx->tos+3]); inv=&(ctx->bn[ctx->tos+4]); ctx->tos+=5; ctx->tos+=4; d=d1; dd=d2; Loading @@ -429,8 +431,8 @@ static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx) /* i=BN_num_bits(n); */ #ifdef RECP_MUL_MOD nb=BN_reciprocal(inv,n,ctx); /**/ if (nb == -1) goto err; BN_RECP_CTX_init(&recp); if (BN_RECP_CTX_set(&recp,n,ctx) <= 0) goto err; #endif for (i=k-1; i>=0; i--) Loading @@ -439,7 +441,7 @@ static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx) #ifndef RECP_MUL_MOD if (!BN_mod_mul(dd,d,d,n,ctx)) goto err; #else if (!BN_mod_mul_reciprocal(dd,d,d,n,inv,nb,ctx)) goto err; if (!BN_mod_mul_reciprocal(dd,d,d,&recp,ctx)) goto err; #endif if ( BN_is_one(dd) && !BN_is_one(x) && Loading @@ -453,7 +455,7 @@ static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx) #ifndef RECP_MUL_MOD if (!BN_mod_mul(d,dd,a,n,ctx)) goto err; #else if (!BN_mod_mul_reciprocal(d,dd,a,n,inv,nb,ctx)) goto err; if (!BN_mod_mul_reciprocal(d,dd,a,&recp,ctx)) goto err; #endif } else Loading @@ -468,7 +470,10 @@ static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx) else i=1; ret=i; err: ctx->tos-=5; ctx->tos-=4; #ifdef RECP_MUL_MOD BN_RECP_CTX_free(&recp); #endif return(ret); } #endif doc/crypto/BN_CTX_new.pod 0 → 100644 +48 −0 Original line number Diff line number Diff line =pod =head1 NAME BN_CTX_new, BN_CTX_init, BN_CTX_free - allocate and free BN_CTX structures =head1 SYNOPSIS #include <openssl/bn.h> BN_CTX *BN_CTX_new(void); void BN_CTX_init(BN_CTX *c); void BN_CTX_free(BN_CTX *c); =head1 DESCRIPTION A B<BN_CTX> is a structure that holds temporary variables used by library functions. Thus, it can be avoided to create and destroy the temporary B<BIGNUM> objects whenever a library function is called. BN_CTX_new() allocated and initializes a B<BN_CTX> structure. BN_CTX_init() initializes an existing uninitialized B<BN_CTX>. BN_CTX_free() frees the components of the B<BN_CTX>, and if it was created by BN_CTX_new(), also the structure itself. =head1 RETURN VALUES BN_CTX_new() returns a pointer to the B<BN_CTX>. If the allocation fails, it returns B<NULL> and sets an error code that can be obtained by ERR_get_error(3). BN_CTX_init() and BN_CTX_free() have no return values. =head1 SEE ALSO bn(3), err(3), BN_add(3) =head1 HISTORY BN_CTX_new() and BN_CTX_free() are availabe in all versions on SSLeay and OpenSSL. BN_CTX_init() was added in SSLeay 0.9.1b. =cut Loading
crypto/bn/bn.h +2 −2 Original line number Diff line number Diff line Loading @@ -330,7 +330,7 @@ int BN_bn2mpi(const BIGNUM *a, unsigned char *to); int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b); int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); Loading
crypto/bn/bn_add.c +2 −2 Original line number Diff line number Diff line Loading @@ -61,9 +61,9 @@ #include "bn_lcl.h" /* r can == a or b */ int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b) int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) { BIGNUM *tmp; const BIGNUM *tmp; bn_check_top(a); bn_check_top(b); Loading
crypto/bn/bn_lib.c +5 −0 Original line number Diff line number Diff line Loading @@ -341,6 +341,11 @@ void BN_CTX_free(BN_CTX *c) Free(c); } /* This is an internal function that should not be used in applications. * It ensures that 'b' has enough room for a 'bits' bit number. It is * mostly used by the various BIGNUM routines. If there is an error, * NULL is returned. if not, 'b' is returned. */ BIGNUM *bn_expand2(BIGNUM *b, int words) { BN_ULONG *A,*a; Loading
crypto/bn/bn_prime.c +17 −12 Original line number Diff line number Diff line Loading @@ -225,8 +225,6 @@ err: return(ret); } #define RECP_MUL_MOD static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx, BN_CTX *ctx2, BN_MONT_CTX *mont) { Loading Loading @@ -408,18 +406,22 @@ err: } #if 0 static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx) #define RECP_MUL_MOD static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx, BN_CTX *unused, BN_MONT_CTX *unused2) { int k,i,nb,ret= -1; int k,i,ret= -1; BIGNUM *d,*dd,*tmp; BIGNUM *d1,*d2,*x,*n1,*inv; BIGNUM *d1,*d2,*x,*n1; BN_RECP_CTX recp; d1= &(ctx->bn[ctx->tos]); d2= &(ctx->bn[ctx->tos+1]); x= &(ctx->bn[ctx->tos+2]); n1= &(ctx->bn[ctx->tos+3]); inv=&(ctx->bn[ctx->tos+4]); ctx->tos+=5; ctx->tos+=4; d=d1; dd=d2; Loading @@ -429,8 +431,8 @@ static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx) /* i=BN_num_bits(n); */ #ifdef RECP_MUL_MOD nb=BN_reciprocal(inv,n,ctx); /**/ if (nb == -1) goto err; BN_RECP_CTX_init(&recp); if (BN_RECP_CTX_set(&recp,n,ctx) <= 0) goto err; #endif for (i=k-1; i>=0; i--) Loading @@ -439,7 +441,7 @@ static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx) #ifndef RECP_MUL_MOD if (!BN_mod_mul(dd,d,d,n,ctx)) goto err; #else if (!BN_mod_mul_reciprocal(dd,d,d,n,inv,nb,ctx)) goto err; if (!BN_mod_mul_reciprocal(dd,d,d,&recp,ctx)) goto err; #endif if ( BN_is_one(dd) && !BN_is_one(x) && Loading @@ -453,7 +455,7 @@ static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx) #ifndef RECP_MUL_MOD if (!BN_mod_mul(d,dd,a,n,ctx)) goto err; #else if (!BN_mod_mul_reciprocal(d,dd,a,n,inv,nb,ctx)) goto err; if (!BN_mod_mul_reciprocal(d,dd,a,&recp,ctx)) goto err; #endif } else Loading @@ -468,7 +470,10 @@ static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx) else i=1; ret=i; err: ctx->tos-=5; ctx->tos-=4; #ifdef RECP_MUL_MOD BN_RECP_CTX_free(&recp); #endif return(ret); } #endif
doc/crypto/BN_CTX_new.pod 0 → 100644 +48 −0 Original line number Diff line number Diff line =pod =head1 NAME BN_CTX_new, BN_CTX_init, BN_CTX_free - allocate and free BN_CTX structures =head1 SYNOPSIS #include <openssl/bn.h> BN_CTX *BN_CTX_new(void); void BN_CTX_init(BN_CTX *c); void BN_CTX_free(BN_CTX *c); =head1 DESCRIPTION A B<BN_CTX> is a structure that holds temporary variables used by library functions. Thus, it can be avoided to create and destroy the temporary B<BIGNUM> objects whenever a library function is called. BN_CTX_new() allocated and initializes a B<BN_CTX> structure. BN_CTX_init() initializes an existing uninitialized B<BN_CTX>. BN_CTX_free() frees the components of the B<BN_CTX>, and if it was created by BN_CTX_new(), also the structure itself. =head1 RETURN VALUES BN_CTX_new() returns a pointer to the B<BN_CTX>. If the allocation fails, it returns B<NULL> and sets an error code that can be obtained by ERR_get_error(3). BN_CTX_init() and BN_CTX_free() have no return values. =head1 SEE ALSO bn(3), err(3), BN_add(3) =head1 HISTORY BN_CTX_new() and BN_CTX_free() are availabe in all versions on SSLeay and OpenSSL. BN_CTX_init() was added in SSLeay 0.9.1b. =cut