Loading crypto/bn/Makefile.ssl +2 −2 Original line number Diff line number Diff line Loading @@ -37,12 +37,12 @@ APPS= LIB=$(TOP)/libcrypto.a LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c \ bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \ bn_kron.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c \ bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c \ bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_ctx.o bn_mul.o bn_mod.o \ bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \ bn_kron.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) \ bn_kron.o bn_sqrt.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) \ bn_recp.o bn_mont.o bn_mpi.o bn_exp2.o SRC= $(LIBSRC) Loading crypto/bn/bn.h +8 −1 Original line number Diff line number Diff line Loading @@ -238,7 +238,7 @@ typedef struct bignum_st } BIGNUM; /* Used for temp variables */ #define BN_CTX_NUM 16 #define BN_CTX_NUM 20 #define BN_CTX_NUM_POS 12 typedef struct bignum_ctx { Loading Loading @@ -357,6 +357,7 @@ int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_ int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m); int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx); Loading Loading @@ -414,6 +415,8 @@ int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */ BIGNUM *BN_mod_inverse(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); BIGNUM *BN_mod_sqrt(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe, const BIGNUM *add, const BIGNUM *rem, void (*callback)(int,int,void *),void *cb_arg); Loading Loading @@ -517,6 +520,7 @@ void bn_dump1(FILE *o, const char *a, const BN_ULONG *b,int n); #define BN_F_BN_MOD_INVERSE 110 #define BN_F_BN_MOD_LSHIFT_QUICK 119 #define BN_F_BN_MOD_MUL_RECIPROCAL 111 #define BN_F_BN_MOD_SQRT 121 #define BN_F_BN_MPI2BN 112 #define BN_F_BN_NEW 113 #define BN_F_BN_RAND 114 Loading @@ -531,8 +535,11 @@ void bn_dump1(FILE *o, const char *a, const BN_ULONG *b,int n); #define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105 #define BN_R_INPUT_NOT_REDUCED 110 #define BN_R_INVALID_LENGTH 106 #define BN_R_NOT_A_SQUARE 111 #define BN_R_NOT_INITIALIZED 107 #define BN_R_NO_INVERSE 108 #define BN_R_P_IS_NOT_PRIME 112 #define BN_R_TOO_MANY_ITERATIONS 113 #define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109 #ifdef __cplusplus Loading crypto/bn/bn_err.c +4 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,7 @@ static ERR_STRING_DATA BN_str_functs[]= {ERR_PACK(0,BN_F_BN_MOD_INVERSE,0), "BN_mod_inverse"}, {ERR_PACK(0,BN_F_BN_MOD_LSHIFT_QUICK,0), "BN_mod_lshift_quick"}, {ERR_PACK(0,BN_F_BN_MOD_MUL_RECIPROCAL,0), "BN_mod_mul_reciprocal"}, {ERR_PACK(0,BN_F_BN_MOD_SQRT,0), "BN_mod_sqrt"}, {ERR_PACK(0,BN_F_BN_MPI2BN,0), "BN_mpi2bn"}, {ERR_PACK(0,BN_F_BN_NEW,0), "BN_new"}, {ERR_PACK(0,BN_F_BN_RAND,0), "BN_rand"}, Loading @@ -100,8 +101,11 @@ static ERR_STRING_DATA BN_str_reasons[]= {BN_R_EXPAND_ON_STATIC_BIGNUM_DATA ,"expand on static bignum data"}, {BN_R_INPUT_NOT_REDUCED ,"input not reduced"}, {BN_R_INVALID_LENGTH ,"invalid length"}, {BN_R_NOT_A_SQUARE ,"not a square"}, {BN_R_NOT_INITIALIZED ,"not initialized"}, {BN_R_NO_INVERSE ,"no inverse"}, {BN_R_P_IS_NOT_PRIME ,"p is not prime"}, {BN_R_TOO_MANY_ITERATIONS ,"too many iterations"}, {BN_R_TOO_MANY_TEMPORARY_VARIABLES ,"too many temporary variables"}, {0,NULL} }; Loading crypto/bn/bn_exp.c +31 −8 Original line number Diff line number Diff line Loading @@ -205,6 +205,8 @@ int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, if (a->top == 1 && !a->neg) { BN_ULONG A = a->d[0]; if (m->top == 1) A %= m->d[0]; /* make sure that A is reduced */ ret=BN_mod_exp_mont_word(r,A,p,m,ctx,NULL); } else Loading Loading @@ -235,8 +237,13 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, if (bits == 0) { BN_one(r); return(1); ret = BN_one(r); return ret; } if (BN_is_zero(a)) { ret = BN_zero(r); return ret; } BN_CTX_start(ctx); Loading Loading @@ -355,8 +362,13 @@ int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, bits=BN_num_bits(p); if (bits == 0) { BN_one(rr); return(1); ret = BN_one(rr); return ret; } if (BN_is_zero(a)) { ret = BN_zero(rr); return ret; } BN_CTX_start(ctx); d = BN_CTX_get(ctx); Loading Loading @@ -500,9 +512,15 @@ int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, bits = BN_num_bits(p); if (bits == 0) { BN_one(rr); return(1); ret = BN_one(rr); return ret; } if (a == 0) { ret = BN_zero(rr); return ret; } BN_CTX_start(ctx); d = BN_CTX_get(ctx); r = BN_CTX_get(ctx); Loading Loading @@ -611,8 +629,13 @@ int BN_mod_exp_simple(BIGNUM *r, if (bits == 0) { BN_one(r); return(1); ret = BN_one(r); return ret; } if (BN_is_zero(a)) { ret = BN_one(r); return ret; } BN_CTX_start(ctx); Loading crypto/bn/bn_exp2.c +8 −2 Original line number Diff line number Diff line Loading @@ -141,9 +141,15 @@ int BN_mod_exp2_mont(BIGNUM *rr, const BIGNUM *a1, const BIGNUM *p1, bits2=BN_num_bits(p2); if ((bits1 == 0) && (bits2 == 0)) { BN_one(rr); return(1); ret = BN_one(rr); return ret; } if (BN_is_zero(a1) || BN_is_zero(a2)) { ret = BN_zero(rr); return ret; } bits=(bits1 > bits2)?bits1:bits2; BN_CTX_start(ctx); Loading Loading
crypto/bn/Makefile.ssl +2 −2 Original line number Diff line number Diff line Loading @@ -37,12 +37,12 @@ APPS= LIB=$(TOP)/libcrypto.a LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c \ bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \ bn_kron.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c \ bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c \ bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_ctx.o bn_mul.o bn_mod.o \ bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \ bn_kron.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) \ bn_kron.o bn_sqrt.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) \ bn_recp.o bn_mont.o bn_mpi.o bn_exp2.o SRC= $(LIBSRC) Loading
crypto/bn/bn.h +8 −1 Original line number Diff line number Diff line Loading @@ -238,7 +238,7 @@ typedef struct bignum_st } BIGNUM; /* Used for temp variables */ #define BN_CTX_NUM 16 #define BN_CTX_NUM 20 #define BN_CTX_NUM_POS 12 typedef struct bignum_ctx { Loading Loading @@ -357,6 +357,7 @@ int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_ int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m); int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx); Loading Loading @@ -414,6 +415,8 @@ int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */ BIGNUM *BN_mod_inverse(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); BIGNUM *BN_mod_sqrt(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe, const BIGNUM *add, const BIGNUM *rem, void (*callback)(int,int,void *),void *cb_arg); Loading Loading @@ -517,6 +520,7 @@ void bn_dump1(FILE *o, const char *a, const BN_ULONG *b,int n); #define BN_F_BN_MOD_INVERSE 110 #define BN_F_BN_MOD_LSHIFT_QUICK 119 #define BN_F_BN_MOD_MUL_RECIPROCAL 111 #define BN_F_BN_MOD_SQRT 121 #define BN_F_BN_MPI2BN 112 #define BN_F_BN_NEW 113 #define BN_F_BN_RAND 114 Loading @@ -531,8 +535,11 @@ void bn_dump1(FILE *o, const char *a, const BN_ULONG *b,int n); #define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105 #define BN_R_INPUT_NOT_REDUCED 110 #define BN_R_INVALID_LENGTH 106 #define BN_R_NOT_A_SQUARE 111 #define BN_R_NOT_INITIALIZED 107 #define BN_R_NO_INVERSE 108 #define BN_R_P_IS_NOT_PRIME 112 #define BN_R_TOO_MANY_ITERATIONS 113 #define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109 #ifdef __cplusplus Loading
crypto/bn/bn_err.c +4 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,7 @@ static ERR_STRING_DATA BN_str_functs[]= {ERR_PACK(0,BN_F_BN_MOD_INVERSE,0), "BN_mod_inverse"}, {ERR_PACK(0,BN_F_BN_MOD_LSHIFT_QUICK,0), "BN_mod_lshift_quick"}, {ERR_PACK(0,BN_F_BN_MOD_MUL_RECIPROCAL,0), "BN_mod_mul_reciprocal"}, {ERR_PACK(0,BN_F_BN_MOD_SQRT,0), "BN_mod_sqrt"}, {ERR_PACK(0,BN_F_BN_MPI2BN,0), "BN_mpi2bn"}, {ERR_PACK(0,BN_F_BN_NEW,0), "BN_new"}, {ERR_PACK(0,BN_F_BN_RAND,0), "BN_rand"}, Loading @@ -100,8 +101,11 @@ static ERR_STRING_DATA BN_str_reasons[]= {BN_R_EXPAND_ON_STATIC_BIGNUM_DATA ,"expand on static bignum data"}, {BN_R_INPUT_NOT_REDUCED ,"input not reduced"}, {BN_R_INVALID_LENGTH ,"invalid length"}, {BN_R_NOT_A_SQUARE ,"not a square"}, {BN_R_NOT_INITIALIZED ,"not initialized"}, {BN_R_NO_INVERSE ,"no inverse"}, {BN_R_P_IS_NOT_PRIME ,"p is not prime"}, {BN_R_TOO_MANY_ITERATIONS ,"too many iterations"}, {BN_R_TOO_MANY_TEMPORARY_VARIABLES ,"too many temporary variables"}, {0,NULL} }; Loading
crypto/bn/bn_exp.c +31 −8 Original line number Diff line number Diff line Loading @@ -205,6 +205,8 @@ int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, if (a->top == 1 && !a->neg) { BN_ULONG A = a->d[0]; if (m->top == 1) A %= m->d[0]; /* make sure that A is reduced */ ret=BN_mod_exp_mont_word(r,A,p,m,ctx,NULL); } else Loading Loading @@ -235,8 +237,13 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, if (bits == 0) { BN_one(r); return(1); ret = BN_one(r); return ret; } if (BN_is_zero(a)) { ret = BN_zero(r); return ret; } BN_CTX_start(ctx); Loading Loading @@ -355,8 +362,13 @@ int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, bits=BN_num_bits(p); if (bits == 0) { BN_one(rr); return(1); ret = BN_one(rr); return ret; } if (BN_is_zero(a)) { ret = BN_zero(rr); return ret; } BN_CTX_start(ctx); d = BN_CTX_get(ctx); Loading Loading @@ -500,9 +512,15 @@ int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, bits = BN_num_bits(p); if (bits == 0) { BN_one(rr); return(1); ret = BN_one(rr); return ret; } if (a == 0) { ret = BN_zero(rr); return ret; } BN_CTX_start(ctx); d = BN_CTX_get(ctx); r = BN_CTX_get(ctx); Loading Loading @@ -611,8 +629,13 @@ int BN_mod_exp_simple(BIGNUM *r, if (bits == 0) { BN_one(r); return(1); ret = BN_one(r); return ret; } if (BN_is_zero(a)) { ret = BN_one(r); return ret; } BN_CTX_start(ctx); Loading
crypto/bn/bn_exp2.c +8 −2 Original line number Diff line number Diff line Loading @@ -141,9 +141,15 @@ int BN_mod_exp2_mont(BIGNUM *rr, const BIGNUM *a1, const BIGNUM *p1, bits2=BN_num_bits(p2); if ((bits1 == 0) && (bits2 == 0)) { BN_one(rr); return(1); ret = BN_one(rr); return ret; } if (BN_is_zero(a1) || BN_is_zero(a2)) { ret = BN_zero(rr); return ret; } bits=(bits1 > bits2)?bits1:bits2; BN_CTX_start(ctx); Loading