diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2022-01-14 07:49:50 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2022-01-14 07:49:50 +0000 |
commit | 02d9cbd67f4cb3f6ccf4b8b25441e80e92fb316f (patch) | |
tree | 241aea0c693c463e98fc90ac9554586f2e5960a3 /lib/libcrypto/bn/bn.h | |
parent | 79f416d24d4bcd32a55ee368b8896e7a5d95eed4 (diff) |
Unifdef LIBRESSL_OPAQUE_* and LIBRESSL_NEXT_API
This marks the start of major surgery in libcrypto. Do not attempt to
build the tree for a while (~50 commits).
Diffstat (limited to 'lib/libcrypto/bn/bn.h')
-rw-r--r-- | lib/libcrypto/bn/bn.h | 66 |
1 files changed, 1 insertions, 65 deletions
diff --git a/lib/libcrypto/bn/bn.h b/lib/libcrypto/bn/bn.h index db5e7f908c1..5d9f17c4d94 100644 --- a/lib/libcrypto/bn/bn.h +++ b/lib/libcrypto/bn/bn.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn.h,v 1.50 2021/12/04 16:11:10 tb Exp $ */ +/* $OpenBSD: bn.h,v 1.51 2022/01/14 07:49:49 tb Exp $ */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -228,14 +228,9 @@ extern "C" { #ifndef OPENSSL_NO_DEPRECATED #define BN_FLG_FREE 0x8000 /* used for debugging */ #endif -#if defined(LIBRESSL_OPAQUE_BN) || defined(LIBRESSL_CRYPTO_INTERNAL) void BN_set_flags(BIGNUM *b, int n); int BN_get_flags(const BIGNUM *b, int n); void BN_with_flags(BIGNUM *dest, const BIGNUM *src, int flags); -#else -#define BN_set_flags(b,n) ((b)->flags|=(n)) -#define BN_get_flags(b,n) ((b)->flags&(n)) -#endif /* Values for |top| in BN_rand() */ #define BN_RAND_TOP_ANY -1 @@ -246,19 +241,6 @@ void BN_with_flags(BIGNUM *dest, const BIGNUM *src, int flags); #define BN_RAND_BOTTOM_ANY 0 #define BN_RAND_BOTTOM_ODD 1 -#if !defined(LIBRESSL_OPAQUE_BN) && !defined(LIBRESSL_CRYPTO_INTERNAL) -/* get a clone of a BIGNUM with changed flags, for *temporary* use only - * (the two BIGNUMs cannot not be used in parallel!) */ -#define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \ - (dest)->top=(b)->top, \ - (dest)->dmax=(b)->dmax, \ - (dest)->neg=(b)->neg, \ - (dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \ - | ((b)->flags & ~BN_FLG_MALLOCED) \ - | BN_FLG_STATIC_DATA \ - | (n))) -#endif - /* Move to bn_lcl.h */ struct bignum_st { BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */ @@ -313,7 +295,6 @@ void BN_GENCB_free(BN_GENCB *cb); /* Wrapper function to make using BN_GENCB easier, */ int BN_GENCB_call(BN_GENCB *cb, int a, int b); -#if defined(LIBRESSL_OPAQUE_BN) || defined(LIBRESSL_CRYPTO_INTERNAL) /* Populate a BN_GENCB structure with an "old"-style callback */ void BN_GENCB_set_old(BN_GENCB *gencb, void (*callback)(int, int, void *), void *cb_arg); @@ -321,20 +302,6 @@ void BN_GENCB_set_old(BN_GENCB *gencb, void (*callback)(int, int, void *), /* Populate a BN_GENCB structure with a "new"-style callback */ void BN_GENCB_set(BN_GENCB *gencb, int (*callback)(int, int, BN_GENCB *), void *cb_arg); -#else -/* Macro to populate a BN_GENCB structure with an "old"-style callback */ -#define BN_GENCB_set_old(gencb, callback, cb_arg) { \ - BN_GENCB *tmp_gencb = (gencb); \ - tmp_gencb->ver = 1; \ - tmp_gencb->arg = (cb_arg); \ - tmp_gencb->cb.cb_1 = (callback); } -/* Macro to populate a BN_GENCB structure with a "new"-style callback */ -#define BN_GENCB_set(gencb, callback, cb_arg) { \ - BN_GENCB *tmp_gencb = (gencb); \ - tmp_gencb->ver = 2; \ - tmp_gencb->arg = (cb_arg); \ - tmp_gencb->cb.cb_2 = (callback); } -#endif /* !LIBRESSL_CRYPTO_INTERNAL */ void *BN_GENCB_get_arg(BN_GENCB *cb); @@ -416,7 +383,6 @@ void *BN_GENCB_get_arg(BN_GENCB *cb); #define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) -#if defined(LIBRESSL_OPAQUE_BN) || defined(LIBRESSL_CRYPTO_INTERNAL) int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w); int BN_is_zero(const BIGNUM *a); int BN_is_one(const BIGNUM *a); @@ -427,23 +393,6 @@ int BN_is_odd(const BIGNUM *a); void BN_zero_ex(BIGNUM *a); -#else -#define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \ - (((w) == 0) && ((a)->top == 0))) -#define BN_is_zero(a) ((a)->top == 0) -#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)) - -#define BN_one(a) (BN_set_word((a),1)) -#define BN_zero_ex(a) \ - do { \ - BIGNUM *_tmp_bn = (a); \ - _tmp_bn->top = 0; \ - _tmp_bn->neg = 0; \ - } while(0) -#endif /* LIBRESSL_OPAQUE_BN */ - #ifdef OPENSSL_NO_DEPRECATED #define BN_zero(a) BN_zero_ex(a) #else @@ -490,15 +439,7 @@ int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx); */ 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, @@ -613,13 +554,8 @@ BN_MONT_CTX *BN_MONT_CTX_new(void ); void BN_MONT_CTX_init(BN_MONT_CTX *ctx); int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_MONT_CTX *mont, BN_CTX *ctx); -#if defined(LIBRESSL_OPAQUE_BN) || defined(LIBRESSL_CRYPTO_INTERNAL) int BN_to_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx); -#else -#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\ - (r),(a),&((mont)->RR),(mont),(ctx)) -#endif int BN_from_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx); void BN_MONT_CTX_free(BN_MONT_CTX *mont); |