diff options
| author | tb <> | 2021-12-04 16:02:44 +0000 |
|---|---|---|
| committer | tb <> | 2021-12-04 16:02:44 +0000 |
| commit | c4cc32b24a7a10ab2763bb6be4d835b32e6aa4b1 (patch) | |
| tree | e69efe0002805e09d6a9a57be55ef27e4d28eb49 /src | |
| parent | 351ab4c8a19a3e680ec610b0d6fb491fc26ffe0b (diff) | |
| download | openbsd-c4cc32b24a7a10ab2763bb6be4d835b32e6aa4b1.tar.gz openbsd-c4cc32b24a7a10ab2763bb6be4d835b32e6aa4b1.tar.bz2 openbsd-c4cc32b24a7a10ab2763bb6be4d835b32e6aa4b1.zip | |
Implement the BN_is_negative macro as a function
ok inoguchi jsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/bn/bn.h | 7 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/bn_lib.c | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h index e9837cbbd6..4bfb81d32e 100644 --- a/src/lib/libcrypto/bn/bn.h +++ b/src/lib/libcrypto/bn/bn.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn.h,v 1.47 2021/12/04 15:59:52 tb Exp $ */ | 1 | /* $OpenBSD: bn.h,v 1.48 2021/12/04 16:02:44 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -485,11 +485,16 @@ int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx); | |||
| 485 | * \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise | 485 | * \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise |
| 486 | */ | 486 | */ |
| 487 | void BN_set_negative(BIGNUM *b, int n); | 487 | void BN_set_negative(BIGNUM *b, int n); |
| 488 | |||
| 489 | #if defined(LIBRESSL_OPAQUE_BN) || defined(LIBRESSL_CRYPTO_INTERNAL) | ||
| 490 | int BN_is_negative(const BIGNUM *b); | ||
| 491 | #else | ||
| 488 | /** BN_is_negative returns 1 if the BIGNUM is negative | 492 | /** BN_is_negative returns 1 if the BIGNUM is negative |
| 489 | * \param a pointer to the BIGNUM object | 493 | * \param a pointer to the BIGNUM object |
| 490 | * \return 1 if a < 0 and 0 otherwise | 494 | * \return 1 if a < 0 and 0 otherwise |
| 491 | */ | 495 | */ |
| 492 | #define BN_is_negative(a) ((a)->neg != 0) | 496 | #define BN_is_negative(a) ((a)->neg != 0) |
| 497 | #endif | ||
| 493 | 498 | ||
| 494 | #ifndef LIBRESSL_INTERNAL | 499 | #ifndef LIBRESSL_INTERNAL |
| 495 | int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, | 500 | int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, |
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c index 77ee3b1fdc..2544722ea9 100644 --- a/src/lib/libcrypto/bn/bn_lib.c +++ b/src/lib/libcrypto/bn/bn_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_lib.c,v 1.51 2021/12/04 15:59:52 tb Exp $ */ | 1 | /* $OpenBSD: bn_lib.c,v 1.52 2021/12/04 16:02:44 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -1099,6 +1099,12 @@ BN_is_odd(const BIGNUM *a) | |||
| 1099 | return a->top > 0 && (a->d[0] & 1); | 1099 | return a->top > 0 && (a->d[0] & 1); |
| 1100 | } | 1100 | } |
| 1101 | 1101 | ||
| 1102 | int | ||
| 1103 | BN_is_negative(const BIGNUM *a) | ||
| 1104 | { | ||
| 1105 | return a->neg != 0; | ||
| 1106 | } | ||
| 1107 | |||
| 1102 | BN_GENCB * | 1108 | BN_GENCB * |
| 1103 | BN_GENCB_new(void) | 1109 | BN_GENCB_new(void) |
| 1104 | { | 1110 | { |
