diff options
| author | tb <> | 2021-12-04 15:53:01 +0000 |
|---|---|---|
| committer | tb <> | 2021-12-04 15:53:01 +0000 |
| commit | b6edb64309ee0e5ec4b6209d18f8243451517729 (patch) | |
| tree | d6e778b0f86a5a6d60eef0b24c751d23a791739e /src | |
| parent | cd068a91eeb270452808f2fb0f3091059390bc4b (diff) | |
| download | openbsd-b6edb64309ee0e5ec4b6209d18f8243451517729.tar.gz openbsd-b6edb64309ee0e5ec4b6209d18f8243451517729.tar.bz2 openbsd-b6edb64309ee0e5ec4b6209d18f8243451517729.zip | |
Provide replacement functions for the BN_{get,set,with}_flags() macros.
ok inoguchi jsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/bn/bn.h | 10 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/bn_lib.c | 26 |
2 files changed, 34 insertions, 2 deletions
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h index cfdf46906b..20212bf171 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.45 2021/12/04 15:48:23 tb Exp $ */ | 1 | /* $OpenBSD: bn.h,v 1.46 2021/12/04 15:53:01 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 | * |
| @@ -228,8 +228,14 @@ extern "C" { | |||
| 228 | #ifndef OPENSSL_NO_DEPRECATED | 228 | #ifndef OPENSSL_NO_DEPRECATED |
| 229 | #define BN_FLG_FREE 0x8000 /* used for debugging */ | 229 | #define BN_FLG_FREE 0x8000 /* used for debugging */ |
| 230 | #endif | 230 | #endif |
| 231 | #if defined(LIBRESSL_OPAQUE_BN) || defined(LIBRESSL_CRYPTO_INTERNAL) | ||
| 232 | void BN_set_flags(BIGNUM *b, int n); | ||
| 233 | int BN_get_flags(const BIGNUM *b, int n); | ||
| 234 | void BN_with_flags(BIGNUM *dest, const BIGNUM *src, int flags); | ||
| 235 | #else | ||
| 231 | #define BN_set_flags(b,n) ((b)->flags|=(n)) | 236 | #define BN_set_flags(b,n) ((b)->flags|=(n)) |
| 232 | #define BN_get_flags(b,n) ((b)->flags&(n)) | 237 | #define BN_get_flags(b,n) ((b)->flags&(n)) |
| 238 | #endif | ||
| 233 | 239 | ||
| 234 | /* Values for |top| in BN_rand() */ | 240 | /* Values for |top| in BN_rand() */ |
| 235 | #define BN_RAND_TOP_ANY -1 | 241 | #define BN_RAND_TOP_ANY -1 |
| @@ -240,6 +246,7 @@ extern "C" { | |||
| 240 | #define BN_RAND_BOTTOM_ANY 0 | 246 | #define BN_RAND_BOTTOM_ANY 0 |
| 241 | #define BN_RAND_BOTTOM_ODD 1 | 247 | #define BN_RAND_BOTTOM_ODD 1 |
| 242 | 248 | ||
| 249 | #if !defined(LIBRESSL_OPAQUE_BN) && !defined(LIBRESSL_CRYPTO_INTERNAL) | ||
| 243 | /* get a clone of a BIGNUM with changed flags, for *temporary* use only | 250 | /* get a clone of a BIGNUM with changed flags, for *temporary* use only |
| 244 | * (the two BIGNUMs cannot not be used in parallel!) */ | 251 | * (the two BIGNUMs cannot not be used in parallel!) */ |
| 245 | #define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \ | 252 | #define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \ |
| @@ -250,6 +257,7 @@ extern "C" { | |||
| 250 | | ((b)->flags & ~BN_FLG_MALLOCED) \ | 257 | | ((b)->flags & ~BN_FLG_MALLOCED) \ |
| 251 | | BN_FLG_STATIC_DATA \ | 258 | | BN_FLG_STATIC_DATA \ |
| 252 | | (n))) | 259 | | (n))) |
| 260 | #endif | ||
| 253 | 261 | ||
| 254 | struct bignum_st { | 262 | struct bignum_st { |
| 255 | BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */ | 263 | BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */ |
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c index 14817629aa..e4085c9d67 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.49 2021/12/04 15:48:23 tb Exp $ */ | 1 | /* $OpenBSD: bn_lib.c,v 1.50 2021/12/04 15:53:01 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 | * |
| @@ -137,6 +137,30 @@ BN_get_params(int which) | |||
| 137 | } | 137 | } |
| 138 | #endif | 138 | #endif |
| 139 | 139 | ||
| 140 | void | ||
| 141 | BN_set_flags(BIGNUM *b, int n) | ||
| 142 | { | ||
| 143 | b->flags |= n; | ||
| 144 | } | ||
| 145 | |||
| 146 | int | ||
| 147 | BN_get_flags(const BIGNUM *b, int n) | ||
| 148 | { | ||
| 149 | return b->flags & n; | ||
| 150 | } | ||
| 151 | |||
| 152 | void | ||
| 153 | BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags) | ||
| 154 | { | ||
| 155 | int dest_flags; | ||
| 156 | |||
| 157 | dest_flags = (dest->flags & BN_FLG_MALLOCED) | | ||
| 158 | (b->flags & ~BN_FLG_MALLOCED) | BN_FLG_STATIC_DATA | flags; | ||
| 159 | |||
| 160 | *dest = *b; | ||
| 161 | dest->flags = dest_flags; | ||
| 162 | } | ||
| 163 | |||
| 140 | const BIGNUM * | 164 | const BIGNUM * |
| 141 | BN_value_one(void) | 165 | BN_value_one(void) |
| 142 | { | 166 | { |
