X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fbn%2Fbn.h;h=103a1bdd09f0c9e52065411957af18de2801b91f;hp=c81f3de8be90ecbe5a64bbdb1770c5bf5f394752;hb=c5d4ab7e35d856c6b3c394b82be07a675b5da661;hpb=a08bcccc674def5ced0f921a7d0612de503b98e0 diff --git a/crypto/bn/bn.h b/crypto/bn/bn.h index c81f3de8be..103a1bdd09 100644 --- a/crypto/bn/bn.h +++ b/crypto/bn/bn.h @@ -59,16 +59,16 @@ #ifndef HEADER_BN_H #define HEADER_BN_H -#ifndef NO_FP_API +#include +#ifndef OPENSSL_NO_FP_API #include /* FILE */ #endif -#include #ifdef __cplusplus extern "C" { #endif -#ifdef VMS +#ifdef OPENSSL_SYS_VMS #undef BN_LLONG /* experimental, so far... */ #endif @@ -87,9 +87,11 @@ extern "C" { * For machines with only one compiler (or shared libraries), this should * be on. Again this in only really a problem on machines * using "long long's", are 32bit, and are not using my assembler code. */ -#if defined(MSDOS) || defined(WINDOWS) || defined(WIN32) || defined(linux) -#undef BN_DIV2W -#define BN_DIV2W +#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \ + defined(OPENSSL_SYS_WIN32) || defined(linux) +# ifndef BN_DIV2W +# define BN_DIV2W +# endif #endif /* assuming long is 64bit - this is the DEC Alpha @@ -141,7 +143,7 @@ extern "C" { #endif #ifdef THIRTY_TWO_BIT -#if defined(WIN32) && !defined(__GNUC__) +#if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__) #define BN_ULLONG unsigned _int64 #else #define BN_ULLONG unsigned long long @@ -152,7 +154,7 @@ extern "C" { #define BN_BYTES 4 #define BN_BITS2 32 #define BN_BITS4 16 -#ifdef WIN32 +#ifdef OPENSSL_SYS_WIN32 /* VC++ doesn't like the LL suffix */ #define BN_MASK (0xffffffffffffffffL) #else @@ -237,18 +239,8 @@ typedef struct bignum_st int flags; } BIGNUM; -/* Used for temp variables */ -#define BN_CTX_NUM 16 -#define BN_CTX_NUM_POS 12 -typedef struct bignum_ctx - { - int tos; - BIGNUM bn[BN_CTX_NUM]; - int flags; - int depth; - int pos[BN_CTX_NUM_POS]; - int too_many; - } BN_CTX; +/* Used for temp variables (declaration hidden in bn_lcl.h) */ +typedef struct bignum_ctx BN_CTX; typedef struct bn_blinding_st { @@ -319,7 +311,7 @@ typedef struct bn_recp_ctx_st /*#define BN_ascii2bn(a) BN_hex2bn(a) */ /*#define BN_bn2ascii(a) BN_bn2hex(a) */ -BIGNUM *BN_value_one(void); +const BIGNUM *BN_value_one(void); char * BN_options(void); BN_CTX *BN_CTX_new(void); void BN_CTX_init(BN_CTX *c); @@ -329,6 +321,8 @@ BIGNUM *BN_CTX_get(BN_CTX *ctx); void BN_CTX_end(BN_CTX *ctx); int BN_rand(BIGNUM *rnd, int bits, int top,int bottom); int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom); +int BN_rand_range(BIGNUM *rnd, BIGNUM *range); +int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range); int BN_num_bits(const BIGNUM *a); int BN_num_bits_word(BN_ULONG); BIGNUM *BN_new(void); @@ -357,6 +351,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); @@ -390,7 +385,7 @@ int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,BN_CTX *ctx); int BN_mask_bits(BIGNUM *a,int n); -#ifndef NO_FP_API +#ifndef OPENSSL_NO_FP_API int BN_print_fp(FILE *fp, const BIGNUM *a); #endif #ifdef HEADER_BIO_H @@ -414,6 +409,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); @@ -492,6 +489,8 @@ void bn_dump1(FILE *o, const char *a, const BN_ULONG *b,int n); # define bn_dump(a,b) #endif +int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom); + /* BEGIN ERROR CODES */ /* The following lines are auto generated by the script mkerr.pl. Any changes * made after this point may be overwritten when the script is next run. @@ -517,26 +516,32 @@ 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 +#define BN_F_BN_RAND_RANGE 122 #define BN_F_BN_USUB 115 /* Reason codes. */ #define BN_R_ARG2_LT_ARG3 100 #define BN_R_BAD_RECIPROCAL 101 +#define BN_R_BIGNUM_TOO_LONG 114 #define BN_R_CALLED_WITH_EVEN_MODULUS 102 #define BN_R_DIV_BY_ZERO 103 #define BN_R_ENCODING_ERROR 104 #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_INVALID_RANGE 115 +#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 } #endif #endif -