summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn.h
diff options
context:
space:
mode:
authortb <>2021-12-04 15:59:52 +0000
committertb <>2021-12-04 15:59:52 +0000
commit11b62384befd3820c2cb65f8efff914c802abb8f (patch)
treee53a008f830373cbac55d866e13cad37683e6e04 /src/lib/libcrypto/bn/bn.h
parente37ca09a6c0f7eb15f33d536aa0fdbb4241c633f (diff)
downloadopenbsd-11b62384befd3820c2cb65f8efff914c802abb8f.tar.gz
openbsd-11b62384befd3820c2cb65f8efff914c802abb8f.tar.bz2
openbsd-11b62384befd3820c2cb65f8efff914c802abb8f.zip
Provide function implementations for various BN_* macros
BN_abs_is_word, BN_is_{zero,one,word,odd}, BN_one, BN_zero_ex are now implemented as functions for internal use. They will be exposed publicly to replace the macros reaching into BIGNUM in the next bump. ok inoguchi jsing
Diffstat (limited to 'src/lib/libcrypto/bn/bn.h')
-rw-r--r--src/lib/libcrypto/bn/bn.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h
index 20212bf171..e9837cbbd6 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.46 2021/12/04 15:53:01 tb Exp $ */ 1/* $OpenBSD: bn.h,v 1.47 2021/12/04 15:59:52 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 *
@@ -409,10 +409,21 @@ void *BN_GENCB_get_arg(BN_GENCB *cb);
409 (b) >= 308 ? 8 : \ 409 (b) >= 308 ? 8 : \
410 (b) >= 55 ? 27 : \ 410 (b) >= 55 ? 27 : \
411 /* b >= 6 */ 34) 411 /* b >= 6 */ 34)
412 412
413#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) 413#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
414 414
415/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */ 415#if defined(LIBRESSL_OPAQUE_BN) || defined(LIBRESSL_CRYPTO_INTERNAL)
416int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w);
417int BN_is_zero(const BIGNUM *a);
418int BN_is_one(const BIGNUM *a);
419int BN_is_word(const BIGNUM *a, const BN_ULONG w);
420int BN_is_odd(const BIGNUM *a);
421
422#define BN_one(a) BN_set_word((a), 1)
423
424void BN_zero_ex(BIGNUM *a);
425
426#else
416#define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \ 427#define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \
417 (((w) == 0) && ((a)->top == 0))) 428 (((w) == 0) && ((a)->top == 0)))
418#define BN_is_zero(a) ((a)->top == 0) 429#define BN_is_zero(a) ((a)->top == 0)
@@ -427,6 +438,7 @@ void *BN_GENCB_get_arg(BN_GENCB *cb);
427 _tmp_bn->top = 0; \ 438 _tmp_bn->top = 0; \
428 _tmp_bn->neg = 0; \ 439 _tmp_bn->neg = 0; \
429 } while(0) 440 } while(0)
441#endif /* LIBRESSL_OPAQUE_BN */
430 442
431#ifdef OPENSSL_NO_DEPRECATED 443#ifdef OPENSSL_NO_DEPRECATED
432#define BN_zero(a) BN_zero_ex(a) 444#define BN_zero(a) BN_zero_ex(a)