summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2021-12-04 16:02:45 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2021-12-04 16:02:45 +0000
commitd593164b5531ff8e7e77f8cb66f88c808a7ba200 (patch)
tree19542b76801a934046d0b9ef5251ede366678363 /lib
parent5929e5f267e809826d04ce16898bbe785463710c (diff)
Implement the BN_is_negative macro as a function
ok inoguchi jsing
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrypto/bn/bn.h7
-rw-r--r--lib/libcrypto/bn/bn_lib.c8
2 files changed, 13 insertions, 2 deletions
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)
{