diff options
author | jsing <> | 2022-11-23 03:00:12 +0000 |
---|---|---|
committer | jsing <> | 2022-11-23 03:00:12 +0000 |
commit | 7b09303e41bcba8067b9975f2c3fa8ad2ef3fc33 (patch) | |
tree | 680f6ee15c15ffdfe0bf4522febf18cfd8ef7dbb | |
parent | 986e0f87cf7be08cd0149ec67b08f76b49e2db95 (diff) | |
download | openbsd-7b09303e41bcba8067b9975f2c3fa8ad2ef3fc33.tar.gz openbsd-7b09303e41bcba8067b9975f2c3fa8ad2ef3fc33.tar.bz2 openbsd-7b09303e41bcba8067b9975f2c3fa8ad2ef3fc33.zip |
Turn bn_wexpand() into a function.
Any sensible compiler will likely inline this anyway (and even if it does
not, one extra function call/return is the least of the performance
overhead for this code).
ok tb@
-rw-r--r-- | src/lib/libcrypto/bn/bn_lcl.h | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_lib.c | 13 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/lib/libcrypto/bn/bn_lcl.h b/src/lib/libcrypto/bn/bn_lcl.h index 4fac4e7f55..63289f66fb 100644 --- a/src/lib/libcrypto/bn/bn_lcl.h +++ b/src/lib/libcrypto/bn/bn_lcl.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_lcl.h,v 1.36 2022/11/23 02:44:01 jsing Exp $ */ | 1 | /* $OpenBSD: bn_lcl.h,v 1.37 2022/11/23 03:00:12 jsing 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 | * |
@@ -521,9 +521,8 @@ BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, | |||
521 | int cl, int dl); | 521 | int cl, int dl); |
522 | int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num); | 522 | int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num); |
523 | 523 | ||
524 | #define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words))) | ||
525 | BIGNUM *bn_expand2(BIGNUM *a, int words); | ||
526 | BIGNUM *bn_expand(BIGNUM *a, int bits); | 524 | BIGNUM *bn_expand(BIGNUM *a, int bits); |
525 | BIGNUM *bn_wexpand(BIGNUM *a, int words); | ||
527 | 526 | ||
528 | /* Bignum consistency macros | 527 | /* Bignum consistency macros |
529 | * There is one "API" macro, bn_fix_top(), for stripping leading zeroes from | 528 | * There is one "API" macro, bn_fix_top(), for stripping leading zeroes from |
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c index 7ec338b926..7c85e7ad08 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.57 2022/11/23 02:46:09 jsing Exp $ */ | 1 | /* $OpenBSD: bn_lib.c,v 1.58 2022/11/23 03:00:12 jsing 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 | * |
@@ -334,7 +334,7 @@ bn_expand_internal(const BIGNUM *b, int words) | |||
334 | * It is mostly used by the various BIGNUM routines. If there is an error, | 334 | * It is mostly used by the various BIGNUM routines. If there is an error, |
335 | * NULL is returned. If not, 'b' is returned. */ | 335 | * NULL is returned. If not, 'b' is returned. */ |
336 | 336 | ||
337 | BIGNUM * | 337 | static BIGNUM * |
338 | bn_expand2(BIGNUM *b, int words) | 338 | bn_expand2(BIGNUM *b, int words) |
339 | { | 339 | { |
340 | bn_check_top(b); | 340 | bn_check_top(b); |
@@ -387,6 +387,15 @@ bn_expand(BIGNUM *a, int bits) | |||
387 | } | 387 | } |
388 | 388 | ||
389 | BIGNUM * | 389 | BIGNUM * |
390 | bn_wexpand(BIGNUM *a, int words) | ||
391 | { | ||
392 | if (words <= a->dmax) | ||
393 | return a; | ||
394 | |||
395 | return bn_expand2(a, words); | ||
396 | } | ||
397 | |||
398 | BIGNUM * | ||
390 | BN_dup(const BIGNUM *a) | 399 | BN_dup(const BIGNUM *a) |
391 | { | 400 | { |
392 | BIGNUM *t; | 401 | BIGNUM *t; |