Loading CHANGES +6 −7 Original line number Diff line number Diff line Loading @@ -462,14 +462,13 @@ Makefile.shared, for Cygwin's sake. [Richard Levitte] *) Extend the BIGNUM API by creating new macros that behave like functions void BN_set_sign(BIGNUM *a, int neg); int BN_get_sign(const BIGNUM *a); *) Extend the BIGNUM API by creating a function void BN_set_negative(BIGNUM *a, int neg); and a macro that behave like int BN_is_negative(const BIGNUM *a); and avoid the need to access 'a->neg' directly in applications. [Nils Larsch <nla@trustcenter.de>] to avoid the need to access 'a->neg' directly in applications. [Nils Larsch] *) Implement fast modular reduction for pseudo-Mersenne primes used in NIST curves (crypto/bn/bn_nist.c, crypto/ec/ecp_nist.c). Loading crypto/asn1/a_enum.c +2 −2 Original line number Diff line number Diff line Loading @@ -149,7 +149,7 @@ ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai) ASN1err(ASN1_F_BN_TO_ASN1_ENUMERATED,ERR_R_NESTED_ASN1_ERROR); goto err; } if(BN_get_sign(bn)) ret->type = V_ASN1_NEG_ENUMERATED; if(BN_is_negative(bn)) ret->type = V_ASN1_NEG_ENUMERATED; else ret->type=V_ASN1_ENUMERATED; j=BN_num_bits(bn); len=((j == 0)?0:((j/8)+1)); Loading Loading @@ -177,6 +177,6 @@ BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn) if ((ret=BN_bin2bn(ai->data,ai->length,bn)) == NULL) ASN1err(ASN1_F_ASN1_ENUMERATED_TO_BN,ASN1_R_BN_LIB); else if(ai->type == V_ASN1_NEG_ENUMERATED) BN_set_sign(ret,1); else if(ai->type == V_ASN1_NEG_ENUMERATED) BN_set_negative(ret,1); return(ret); } crypto/asn1/a_int.c +2 −2 Original line number Diff line number Diff line Loading @@ -416,7 +416,7 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai) ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_NESTED_ASN1_ERROR); goto err; } if (BN_get_sign(bn)) if (BN_is_negative(bn)) ret->type = V_ASN1_NEG_INTEGER; else ret->type=V_ASN1_INTEGER; j=BN_num_bits(bn); Loading Loading @@ -451,7 +451,7 @@ BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai, BIGNUM *bn) if ((ret=BN_bin2bn(ai->data,ai->length,bn)) == NULL) ASN1err(ASN1_F_ASN1_INTEGER_TO_BN,ASN1_R_BN_LIB); else if(ai->type == V_ASN1_NEG_INTEGER) BN_set_sign(ret, 1); BN_set_negative(ret, 1); return(ret); } Loading crypto/asn1/t_pkey.c +1 −1 Original line number Diff line number Diff line Loading @@ -552,7 +552,7 @@ static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf, const char *neg; if (num == NULL) return(1); neg = (BN_get_sign(num))?"-":""; neg = (BN_is_negative(num))?"-":""; if(!BIO_indent(bp,off,128)) return 0; if (BN_is_zero(num)) Loading crypto/bn/bn.h +4 −16 Original line number Diff line number Diff line Loading @@ -90,13 +90,9 @@ extern "C" { * BN_DEBUG - turn on various debugging alterations to the bignum code * BN_DEBUG_RAND - uses random poisoning of unused words to trip up * mismanagement of bignum internals. You must also define BN_DEBUG. * BN_STRICT - disables anything (not already caught by BN_DEBUG) that uses the * old ambiguity over zero representation. At some point, this behaviour should * become standard. */ /* #define BN_DEBUG */ /* #define BN_DEBUG_RAND */ /* #define BN_STRICT */ #ifdef OPENSSL_SYS_VMS #undef BN_LLONG /* experimental, so far... */ Loading Loading @@ -366,11 +362,7 @@ int BN_GENCB_call(BN_GENCB *cb, int a, int b); /* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */ #define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \ (((w) == 0) && ((a)->top == 0))) #ifdef BN_STRICT #define BN_is_zero(a) ((a)->top == 0) #else #define BN_is_zero(a) BN_abs_is_word(a,0) #endif #define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg) #define BN_is_word(a,w) (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg)) #define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1)) Loading @@ -387,14 +379,6 @@ int BN_GENCB_call(BN_GENCB *cb, int a, int b); #else #define BN_zero(a) (BN_set_word((a),0)) #endif /* BN_set_sign(BIGNUM *, int) sets the sign of a BIGNUM * (0 for a non-negative value, 1 for negative) */ #define BN_set_sign(a,b) ((a)->neg = (b)) /* BN_get_sign(BIGNUM *) returns the sign of the BIGNUM */ #define BN_get_sign(a) ((a)->neg) /*#define BN_ascii2bn(a) BN_hex2bn(a) */ /*#define BN_bn2ascii(a) BN_bn2hex(a) */ const BIGNUM *BN_value_one(void); char * BN_options(void); Loading Loading @@ -429,6 +413,10 @@ int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx); /* BN_set_negative(): sets sign of a bignum */ void BN_set_negative(BIGNUM *b, int n); /* BN_get_negative(): returns 1 if the bignum is < 0 and 0 otherwise */ #define BN_is_negative(a) ((a)->neg != 0) int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); Loading Loading
CHANGES +6 −7 Original line number Diff line number Diff line Loading @@ -462,14 +462,13 @@ Makefile.shared, for Cygwin's sake. [Richard Levitte] *) Extend the BIGNUM API by creating new macros that behave like functions void BN_set_sign(BIGNUM *a, int neg); int BN_get_sign(const BIGNUM *a); *) Extend the BIGNUM API by creating a function void BN_set_negative(BIGNUM *a, int neg); and a macro that behave like int BN_is_negative(const BIGNUM *a); and avoid the need to access 'a->neg' directly in applications. [Nils Larsch <nla@trustcenter.de>] to avoid the need to access 'a->neg' directly in applications. [Nils Larsch] *) Implement fast modular reduction for pseudo-Mersenne primes used in NIST curves (crypto/bn/bn_nist.c, crypto/ec/ecp_nist.c). Loading
crypto/asn1/a_enum.c +2 −2 Original line number Diff line number Diff line Loading @@ -149,7 +149,7 @@ ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai) ASN1err(ASN1_F_BN_TO_ASN1_ENUMERATED,ERR_R_NESTED_ASN1_ERROR); goto err; } if(BN_get_sign(bn)) ret->type = V_ASN1_NEG_ENUMERATED; if(BN_is_negative(bn)) ret->type = V_ASN1_NEG_ENUMERATED; else ret->type=V_ASN1_ENUMERATED; j=BN_num_bits(bn); len=((j == 0)?0:((j/8)+1)); Loading Loading @@ -177,6 +177,6 @@ BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn) if ((ret=BN_bin2bn(ai->data,ai->length,bn)) == NULL) ASN1err(ASN1_F_ASN1_ENUMERATED_TO_BN,ASN1_R_BN_LIB); else if(ai->type == V_ASN1_NEG_ENUMERATED) BN_set_sign(ret,1); else if(ai->type == V_ASN1_NEG_ENUMERATED) BN_set_negative(ret,1); return(ret); }
crypto/asn1/a_int.c +2 −2 Original line number Diff line number Diff line Loading @@ -416,7 +416,7 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai) ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_NESTED_ASN1_ERROR); goto err; } if (BN_get_sign(bn)) if (BN_is_negative(bn)) ret->type = V_ASN1_NEG_INTEGER; else ret->type=V_ASN1_INTEGER; j=BN_num_bits(bn); Loading Loading @@ -451,7 +451,7 @@ BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai, BIGNUM *bn) if ((ret=BN_bin2bn(ai->data,ai->length,bn)) == NULL) ASN1err(ASN1_F_ASN1_INTEGER_TO_BN,ASN1_R_BN_LIB); else if(ai->type == V_ASN1_NEG_INTEGER) BN_set_sign(ret, 1); BN_set_negative(ret, 1); return(ret); } Loading
crypto/asn1/t_pkey.c +1 −1 Original line number Diff line number Diff line Loading @@ -552,7 +552,7 @@ static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf, const char *neg; if (num == NULL) return(1); neg = (BN_get_sign(num))?"-":""; neg = (BN_is_negative(num))?"-":""; if(!BIO_indent(bp,off,128)) return 0; if (BN_is_zero(num)) Loading
crypto/bn/bn.h +4 −16 Original line number Diff line number Diff line Loading @@ -90,13 +90,9 @@ extern "C" { * BN_DEBUG - turn on various debugging alterations to the bignum code * BN_DEBUG_RAND - uses random poisoning of unused words to trip up * mismanagement of bignum internals. You must also define BN_DEBUG. * BN_STRICT - disables anything (not already caught by BN_DEBUG) that uses the * old ambiguity over zero representation. At some point, this behaviour should * become standard. */ /* #define BN_DEBUG */ /* #define BN_DEBUG_RAND */ /* #define BN_STRICT */ #ifdef OPENSSL_SYS_VMS #undef BN_LLONG /* experimental, so far... */ Loading Loading @@ -366,11 +362,7 @@ int BN_GENCB_call(BN_GENCB *cb, int a, int b); /* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */ #define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \ (((w) == 0) && ((a)->top == 0))) #ifdef BN_STRICT #define BN_is_zero(a) ((a)->top == 0) #else #define BN_is_zero(a) BN_abs_is_word(a,0) #endif #define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg) #define BN_is_word(a,w) (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg)) #define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1)) Loading @@ -387,14 +379,6 @@ int BN_GENCB_call(BN_GENCB *cb, int a, int b); #else #define BN_zero(a) (BN_set_word((a),0)) #endif /* BN_set_sign(BIGNUM *, int) sets the sign of a BIGNUM * (0 for a non-negative value, 1 for negative) */ #define BN_set_sign(a,b) ((a)->neg = (b)) /* BN_get_sign(BIGNUM *) returns the sign of the BIGNUM */ #define BN_get_sign(a) ((a)->neg) /*#define BN_ascii2bn(a) BN_hex2bn(a) */ /*#define BN_bn2ascii(a) BN_bn2hex(a) */ const BIGNUM *BN_value_one(void); char * BN_options(void); Loading Loading @@ -429,6 +413,10 @@ int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx); /* BN_set_negative(): sets sign of a bignum */ void BN_set_negative(BIGNUM *b, int n); /* BN_get_negative(): returns 1 if the bignum is < 0 and 0 otherwise */ #define BN_is_negative(a) ((a)->neg != 0) int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); Loading