diff options
author | beck <> | 2023-07-08 12:21:58 +0000 |
---|---|---|
committer | beck <> | 2023-07-08 12:21:58 +0000 |
commit | 4fff81a3a2e2fb3d68e73e2fcc951cee3548c554 (patch) | |
tree | 789e1276988198ecf8411c8f5bb376e2ea404f91 /src/lib/libcrypto/bn/bn_lib.c | |
parent | de1ea0d71a59536dfa9a5b0b755c13d3d6eddbeb (diff) | |
download | openbsd-4fff81a3a2e2fb3d68e73e2fcc951cee3548c554.tar.gz openbsd-4fff81a3a2e2fb3d68e73e2fcc951cee3548c554.tar.bz2 openbsd-4fff81a3a2e2fb3d68e73e2fcc951cee3548c554.zip |
Hide symbols in bn
ok tb@
Diffstat (limited to 'src/lib/libcrypto/bn/bn_lib.c')
-rw-r--r-- | src/lib/libcrypto/bn/bn_lib.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c index bac0290efa..74359dab37 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.88 2023/06/21 07:48:41 jsing Exp $ */ | 1 | /* $OpenBSD: bn_lib.c,v 1.89 2023/07/08 12:21:58 beck 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 | * |
@@ -81,6 +81,7 @@ BN_new(void) | |||
81 | 81 | ||
82 | return bn; | 82 | return bn; |
83 | } | 83 | } |
84 | LCRYPTO_ALIAS(BN_new); | ||
84 | 85 | ||
85 | void | 86 | void |
86 | BN_init(BIGNUM *a) | 87 | BN_init(BIGNUM *a) |
@@ -96,6 +97,7 @@ BN_clear(BIGNUM *a) | |||
96 | a->top = 0; | 97 | a->top = 0; |
97 | a->neg = 0; | 98 | a->neg = 0; |
98 | } | 99 | } |
100 | LCRYPTO_ALIAS(BN_clear); | ||
99 | 101 | ||
100 | void | 102 | void |
101 | BN_free(BIGNUM *bn) | 103 | BN_free(BIGNUM *bn) |
@@ -113,24 +115,28 @@ BN_free(BIGNUM *bn) | |||
113 | 115 | ||
114 | freezero(bn, sizeof(*bn)); | 116 | freezero(bn, sizeof(*bn)); |
115 | } | 117 | } |
118 | LCRYPTO_ALIAS(BN_free); | ||
116 | 119 | ||
117 | void | 120 | void |
118 | BN_clear_free(BIGNUM *bn) | 121 | BN_clear_free(BIGNUM *bn) |
119 | { | 122 | { |
120 | BN_free(bn); | 123 | BN_free(bn); |
121 | } | 124 | } |
125 | LCRYPTO_ALIAS(BN_clear_free); | ||
122 | 126 | ||
123 | void | 127 | void |
124 | BN_set_flags(BIGNUM *b, int n) | 128 | BN_set_flags(BIGNUM *b, int n) |
125 | { | 129 | { |
126 | b->flags |= n; | 130 | b->flags |= n; |
127 | } | 131 | } |
132 | LCRYPTO_ALIAS(BN_set_flags); | ||
128 | 133 | ||
129 | int | 134 | int |
130 | BN_get_flags(const BIGNUM *b, int n) | 135 | BN_get_flags(const BIGNUM *b, int n) |
131 | { | 136 | { |
132 | return b->flags & n; | 137 | return b->flags & n; |
133 | } | 138 | } |
139 | LCRYPTO_ALIAS(BN_get_flags); | ||
134 | 140 | ||
135 | void | 141 | void |
136 | BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags) | 142 | BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags) |
@@ -143,6 +149,7 @@ BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags) | |||
143 | *dest = *b; | 149 | *dest = *b; |
144 | dest->flags = dest_flags; | 150 | dest->flags = dest_flags; |
145 | } | 151 | } |
152 | LCRYPTO_ALIAS(BN_with_flags); | ||
146 | 153 | ||
147 | static const BN_ULONG bn_value_one_data = 1; | 154 | static const BN_ULONG bn_value_one_data = 1; |
148 | static const BIGNUM bn_value_one = { | 155 | static const BIGNUM bn_value_one = { |
@@ -158,18 +165,21 @@ BN_value_one(void) | |||
158 | { | 165 | { |
159 | return &bn_value_one; | 166 | return &bn_value_one; |
160 | } | 167 | } |
168 | LCRYPTO_ALIAS(BN_value_one); | ||
161 | 169 | ||
162 | int | 170 | int |
163 | BN_num_bits_word(BN_ULONG w) | 171 | BN_num_bits_word(BN_ULONG w) |
164 | { | 172 | { |
165 | return BN_BITS2 - bn_clzw(w); | 173 | return BN_BITS2 - bn_clzw(w); |
166 | } | 174 | } |
175 | LCRYPTO_ALIAS(BN_num_bits_word); | ||
167 | 176 | ||
168 | int | 177 | int |
169 | BN_num_bits(const BIGNUM *bn) | 178 | BN_num_bits(const BIGNUM *bn) |
170 | { | 179 | { |
171 | return bn_bitsize(bn); | 180 | return bn_bitsize(bn); |
172 | } | 181 | } |
182 | LCRYPTO_ALIAS(BN_num_bits); | ||
173 | 183 | ||
174 | void | 184 | void |
175 | bn_correct_top(BIGNUM *a) | 185 | bn_correct_top(BIGNUM *a) |
@@ -253,6 +263,7 @@ BN_dup(const BIGNUM *a) | |||
253 | } | 263 | } |
254 | return t; | 264 | return t; |
255 | } | 265 | } |
266 | LCRYPTO_ALIAS(BN_dup); | ||
256 | 267 | ||
257 | static inline void | 268 | static inline void |
258 | bn_copy_words(BN_ULONG *ap, const BN_ULONG *bp, int n) | 269 | bn_copy_words(BN_ULONG *ap, const BN_ULONG *bp, int n) |
@@ -284,6 +295,7 @@ BN_copy(BIGNUM *a, const BIGNUM *b) | |||
284 | 295 | ||
285 | return (a); | 296 | return (a); |
286 | } | 297 | } |
298 | LCRYPTO_ALIAS(BN_copy); | ||
287 | 299 | ||
288 | int | 300 | int |
289 | bn_copy(BIGNUM *dst, const BIGNUM *src) | 301 | bn_copy(BIGNUM *dst, const BIGNUM *src) |
@@ -322,6 +334,7 @@ BN_swap(BIGNUM *a, BIGNUM *b) | |||
322 | b->flags = (flags_old_b & BN_FLG_MALLOCED) | | 334 | b->flags = (flags_old_b & BN_FLG_MALLOCED) | |
323 | (flags_old_a & BN_FLG_STATIC_DATA); | 335 | (flags_old_a & BN_FLG_STATIC_DATA); |
324 | } | 336 | } |
337 | LCRYPTO_ALIAS(BN_swap); | ||
325 | 338 | ||
326 | BN_ULONG | 339 | BN_ULONG |
327 | BN_get_word(const BIGNUM *a) | 340 | BN_get_word(const BIGNUM *a) |
@@ -333,6 +346,7 @@ BN_get_word(const BIGNUM *a) | |||
333 | /* a->top == 0 */ | 346 | /* a->top == 0 */ |
334 | return 0; | 347 | return 0; |
335 | } | 348 | } |
349 | LCRYPTO_ALIAS(BN_get_word); | ||
336 | 350 | ||
337 | int | 351 | int |
338 | BN_set_word(BIGNUM *a, BN_ULONG w) | 352 | BN_set_word(BIGNUM *a, BN_ULONG w) |
@@ -344,6 +358,7 @@ BN_set_word(BIGNUM *a, BN_ULONG w) | |||
344 | a->top = (w ? 1 : 0); | 358 | a->top = (w ? 1 : 0); |
345 | return (1); | 359 | return (1); |
346 | } | 360 | } |
361 | LCRYPTO_ALIAS(BN_set_word); | ||
347 | 362 | ||
348 | int | 363 | int |
349 | BN_ucmp(const BIGNUM *a, const BIGNUM *b) | 364 | BN_ucmp(const BIGNUM *a, const BIGNUM *b) |
@@ -362,6 +377,7 @@ BN_ucmp(const BIGNUM *a, const BIGNUM *b) | |||
362 | 377 | ||
363 | return 0; | 378 | return 0; |
364 | } | 379 | } |
380 | LCRYPTO_ALIAS(BN_ucmp); | ||
365 | 381 | ||
366 | int | 382 | int |
367 | BN_cmp(const BIGNUM *a, const BIGNUM *b) | 383 | BN_cmp(const BIGNUM *a, const BIGNUM *b) |
@@ -382,6 +398,7 @@ BN_cmp(const BIGNUM *a, const BIGNUM *b) | |||
382 | 398 | ||
383 | return BN_ucmp(a, b); | 399 | return BN_ucmp(a, b); |
384 | } | 400 | } |
401 | LCRYPTO_ALIAS(BN_cmp); | ||
385 | 402 | ||
386 | int | 403 | int |
387 | BN_set_bit(BIGNUM *a, int n) | 404 | BN_set_bit(BIGNUM *a, int n) |
@@ -404,6 +421,7 @@ BN_set_bit(BIGNUM *a, int n) | |||
404 | a->d[i] |= (((BN_ULONG)1) << j); | 421 | a->d[i] |= (((BN_ULONG)1) << j); |
405 | return (1); | 422 | return (1); |
406 | } | 423 | } |
424 | LCRYPTO_ALIAS(BN_set_bit); | ||
407 | 425 | ||
408 | int | 426 | int |
409 | BN_clear_bit(BIGNUM *a, int n) | 427 | BN_clear_bit(BIGNUM *a, int n) |
@@ -422,6 +440,7 @@ BN_clear_bit(BIGNUM *a, int n) | |||
422 | bn_correct_top(a); | 440 | bn_correct_top(a); |
423 | return (1); | 441 | return (1); |
424 | } | 442 | } |
443 | LCRYPTO_ALIAS(BN_clear_bit); | ||
425 | 444 | ||
426 | int | 445 | int |
427 | BN_is_bit_set(const BIGNUM *a, int n) | 446 | BN_is_bit_set(const BIGNUM *a, int n) |
@@ -436,6 +455,7 @@ BN_is_bit_set(const BIGNUM *a, int n) | |||
436 | return 0; | 455 | return 0; |
437 | return (int)(((a->d[i]) >> j) & ((BN_ULONG)1)); | 456 | return (int)(((a->d[i]) >> j) & ((BN_ULONG)1)); |
438 | } | 457 | } |
458 | LCRYPTO_ALIAS(BN_is_bit_set); | ||
439 | 459 | ||
440 | int | 460 | int |
441 | BN_mask_bits(BIGNUM *a, int n) | 461 | BN_mask_bits(BIGNUM *a, int n) |
@@ -458,12 +478,14 @@ BN_mask_bits(BIGNUM *a, int n) | |||
458 | bn_correct_top(a); | 478 | bn_correct_top(a); |
459 | return (1); | 479 | return (1); |
460 | } | 480 | } |
481 | LCRYPTO_ALIAS(BN_mask_bits); | ||
461 | 482 | ||
462 | void | 483 | void |
463 | BN_set_negative(BIGNUM *bn, int neg) | 484 | BN_set_negative(BIGNUM *bn, int neg) |
464 | { | 485 | { |
465 | bn->neg = ~BN_is_zero(bn) & bn_ct_ne_zero(neg); | 486 | bn->neg = ~BN_is_zero(bn) & bn_ct_ne_zero(neg); |
466 | } | 487 | } |
488 | LCRYPTO_ALIAS(BN_set_negative); | ||
467 | 489 | ||
468 | /* | 490 | /* |
469 | * Constant-time conditional swap of a and b. | 491 | * Constant-time conditional swap of a and b. |
@@ -517,6 +539,7 @@ BN_consttime_swap(BN_ULONG condition, BIGNUM *a, BIGNUM *b, int nwords) | |||
517 | } | 539 | } |
518 | #undef BN_CONSTTIME_SWAP | 540 | #undef BN_CONSTTIME_SWAP |
519 | } | 541 | } |
542 | LCRYPTO_ALIAS(BN_consttime_swap); | ||
520 | 543 | ||
521 | /* | 544 | /* |
522 | * Constant-time conditional swap of a and b. | 545 | * Constant-time conditional swap of a and b. |
@@ -575,18 +598,21 @@ BN_zero(BIGNUM *a) | |||
575 | a->neg = 0; | 598 | a->neg = 0; |
576 | a->top = 0; | 599 | a->top = 0; |
577 | } | 600 | } |
601 | LCRYPTO_ALIAS(BN_zero); | ||
578 | 602 | ||
579 | int | 603 | int |
580 | BN_one(BIGNUM *a) | 604 | BN_one(BIGNUM *a) |
581 | { | 605 | { |
582 | return BN_set_word(a, 1); | 606 | return BN_set_word(a, 1); |
583 | } | 607 | } |
608 | LCRYPTO_ALIAS(BN_one); | ||
584 | 609 | ||
585 | int | 610 | int |
586 | BN_abs_is_word(const BIGNUM *a, const BN_ULONG w) | 611 | BN_abs_is_word(const BIGNUM *a, const BN_ULONG w) |
587 | { | 612 | { |
588 | return (a->top == 1 && a->d[0] == w) || (w == 0 && a->top == 0); | 613 | return (a->top == 1 && a->d[0] == w) || (w == 0 && a->top == 0); |
589 | } | 614 | } |
615 | LCRYPTO_ALIAS(BN_abs_is_word); | ||
590 | 616 | ||
591 | int | 617 | int |
592 | BN_is_zero(const BIGNUM *bn) | 618 | BN_is_zero(const BIGNUM *bn) |
@@ -599,30 +625,35 @@ BN_is_zero(const BIGNUM *bn) | |||
599 | 625 | ||
600 | return bits == 0; | 626 | return bits == 0; |
601 | } | 627 | } |
628 | LCRYPTO_ALIAS(BN_is_zero); | ||
602 | 629 | ||
603 | int | 630 | int |
604 | BN_is_one(const BIGNUM *a) | 631 | BN_is_one(const BIGNUM *a) |
605 | { | 632 | { |
606 | return BN_abs_is_word(a, 1) && !a->neg; | 633 | return BN_abs_is_word(a, 1) && !a->neg; |
607 | } | 634 | } |
635 | LCRYPTO_ALIAS(BN_is_one); | ||
608 | 636 | ||
609 | int | 637 | int |
610 | BN_is_word(const BIGNUM *a, const BN_ULONG w) | 638 | BN_is_word(const BIGNUM *a, const BN_ULONG w) |
611 | { | 639 | { |
612 | return BN_abs_is_word(a, w) && (w == 0 || !a->neg); | 640 | return BN_abs_is_word(a, w) && (w == 0 || !a->neg); |
613 | } | 641 | } |
642 | LCRYPTO_ALIAS(BN_is_word); | ||
614 | 643 | ||
615 | int | 644 | int |
616 | BN_is_odd(const BIGNUM *a) | 645 | BN_is_odd(const BIGNUM *a) |
617 | { | 646 | { |
618 | return a->top > 0 && (a->d[0] & 1); | 647 | return a->top > 0 && (a->d[0] & 1); |
619 | } | 648 | } |
649 | LCRYPTO_ALIAS(BN_is_odd); | ||
620 | 650 | ||
621 | int | 651 | int |
622 | BN_is_negative(const BIGNUM *a) | 652 | BN_is_negative(const BIGNUM *a) |
623 | { | 653 | { |
624 | return a->neg != 0; | 654 | return a->neg != 0; |
625 | } | 655 | } |
656 | LCRYPTO_ALIAS(BN_is_negative); | ||
626 | 657 | ||
627 | char * | 658 | char * |
628 | BN_options(void) | 659 | BN_options(void) |
@@ -642,6 +673,7 @@ BN_options(void) | |||
642 | } | 673 | } |
643 | return (data); | 674 | return (data); |
644 | } | 675 | } |
676 | LCRYPTO_ALIAS(BN_options); | ||
645 | 677 | ||
646 | /* | 678 | /* |
647 | * Bits of security, see SP800-57, section 5.6.11, table 2. | 679 | * Bits of security, see SP800-57, section 5.6.11, table 2. |
@@ -673,6 +705,7 @@ BN_security_bits(int L, int N) | |||
673 | 705 | ||
674 | return bits >= secbits ? secbits : bits; | 706 | return bits >= secbits ? secbits : bits; |
675 | } | 707 | } |
708 | LCRYPTO_ALIAS(BN_security_bits); | ||
676 | 709 | ||
677 | BN_GENCB * | 710 | BN_GENCB * |
678 | BN_GENCB_new(void) | 711 | BN_GENCB_new(void) |
@@ -684,6 +717,7 @@ BN_GENCB_new(void) | |||
684 | 717 | ||
685 | return cb; | 718 | return cb; |
686 | } | 719 | } |
720 | LCRYPTO_ALIAS(BN_GENCB_new); | ||
687 | 721 | ||
688 | void | 722 | void |
689 | BN_GENCB_free(BN_GENCB *cb) | 723 | BN_GENCB_free(BN_GENCB *cb) |
@@ -692,6 +726,7 @@ BN_GENCB_free(BN_GENCB *cb) | |||
692 | return; | 726 | return; |
693 | free(cb); | 727 | free(cb); |
694 | } | 728 | } |
729 | LCRYPTO_ALIAS(BN_GENCB_free); | ||
695 | 730 | ||
696 | /* Populate a BN_GENCB structure with an "old"-style callback */ | 731 | /* Populate a BN_GENCB structure with an "old"-style callback */ |
697 | void | 732 | void |
@@ -701,6 +736,7 @@ BN_GENCB_set_old(BN_GENCB *gencb, void (*cb)(int, int, void *), void *cb_arg) | |||
701 | gencb->cb.cb_1 = cb; | 736 | gencb->cb.cb_1 = cb; |
702 | gencb->arg = cb_arg; | 737 | gencb->arg = cb_arg; |
703 | } | 738 | } |
739 | LCRYPTO_ALIAS(BN_GENCB_set_old); | ||
704 | 740 | ||
705 | /* Populate a BN_GENCB structure with a "new"-style callback */ | 741 | /* Populate a BN_GENCB structure with a "new"-style callback */ |
706 | void | 742 | void |
@@ -710,9 +746,11 @@ BN_GENCB_set(BN_GENCB *gencb, int (*cb)(int, int, BN_GENCB *), void *cb_arg) | |||
710 | gencb->cb.cb_2 = cb; | 746 | gencb->cb.cb_2 = cb; |
711 | gencb->arg = cb_arg; | 747 | gencb->arg = cb_arg; |
712 | } | 748 | } |
749 | LCRYPTO_ALIAS(BN_GENCB_set); | ||
713 | 750 | ||
714 | void * | 751 | void * |
715 | BN_GENCB_get_arg(BN_GENCB *cb) | 752 | BN_GENCB_get_arg(BN_GENCB *cb) |
716 | { | 753 | { |
717 | return cb->arg; | 754 | return cb->arg; |
718 | } | 755 | } |
756 | LCRYPTO_ALIAS(BN_GENCB_get_arg); | ||