From: tb Date: Sat, 4 Dec 2021 16:02:44 +0000 (+0000) Subject: Implement the BN_is_negative macro as a function X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7eab76581522a8858953ba6e999298d4b672ef8e;p=openbsd Implement the BN_is_negative macro as a function ok inoguchi jsing --- diff --git a/lib/libcrypto/bn/bn.h b/lib/libcrypto/bn/bn.h index e9837cbbd61..4bfb81d32e0 100644 --- a/lib/libcrypto/bn/bn.h +++ b/lib/libcrypto/bn/bn.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn.h,v 1.47 2021/12/04 15:59:52 tb Exp $ */ +/* $OpenBSD: bn.h,v 1.48 2021/12/04 16:02:44 tb Exp $ */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -485,11 +485,16 @@ int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx); * \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise */ void BN_set_negative(BIGNUM *b, int n); + +#if defined(LIBRESSL_OPAQUE_BN) || defined(LIBRESSL_CRYPTO_INTERNAL) +int BN_is_negative(const BIGNUM *b); +#else /** BN_is_negative returns 1 if the BIGNUM is negative * \param a pointer to the BIGNUM object * \return 1 if a < 0 and 0 otherwise */ #define BN_is_negative(a) ((a)->neg != 0) +#endif #ifndef LIBRESSL_INTERNAL int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, diff --git a/lib/libcrypto/bn/bn_lib.c b/lib/libcrypto/bn/bn_lib.c index 77ee3b1fdcd..2544722ea9a 100644 --- a/lib/libcrypto/bn/bn_lib.c +++ b/lib/libcrypto/bn/bn_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_lib.c,v 1.51 2021/12/04 15:59:52 tb Exp $ */ +/* $OpenBSD: bn_lib.c,v 1.52 2021/12/04 16:02:44 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1099,6 +1099,12 @@ BN_is_odd(const BIGNUM *a) return a->top > 0 && (a->d[0] & 1); } +int +BN_is_negative(const BIGNUM *a) +{ + return a->neg != 0; +} + BN_GENCB * BN_GENCB_new(void) {