diff options
Diffstat (limited to 'src/lib/libcrypto/bn/bn_convert.c')
-rw-r--r-- | src/lib/libcrypto/bn/bn_convert.c | 47 |
1 files changed, 1 insertions, 46 deletions
diff --git a/src/lib/libcrypto/bn/bn_convert.c b/src/lib/libcrypto/bn/bn_convert.c index 788e90cc8d..f09c9091e7 100644 --- a/src/lib/libcrypto/bn/bn_convert.c +++ b/src/lib/libcrypto/bn/bn_convert.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_convert.c,v 1.14 2023/07/09 18:27:22 tb Exp $ */ | 1 | /* $OpenBSD: bn_convert.c,v 1.15 2023/07/09 18:37:58 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 | * |
@@ -771,48 +771,3 @@ BN_mpi2bn(const unsigned char *d, int n, BIGNUM *ain) | |||
771 | return (a); | 771 | return (a); |
772 | } | 772 | } |
773 | LCRYPTO_ALIAS(BN_mpi2bn); | 773 | LCRYPTO_ALIAS(BN_mpi2bn); |
774 | |||
775 | #ifndef OPENSSL_NO_BIO | ||
776 | int | ||
777 | BN_print_fp(FILE *fp, const BIGNUM *a) | ||
778 | { | ||
779 | BIO *b; | ||
780 | int ret; | ||
781 | |||
782 | if ((b = BIO_new(BIO_s_file())) == NULL) | ||
783 | return (0); | ||
784 | BIO_set_fp(b, fp, BIO_NOCLOSE); | ||
785 | ret = BN_print(b, a); | ||
786 | BIO_free(b); | ||
787 | return (ret); | ||
788 | } | ||
789 | LCRYPTO_ALIAS(BN_print_fp); | ||
790 | |||
791 | int | ||
792 | BN_print(BIO *bp, const BIGNUM *a) | ||
793 | { | ||
794 | int i, j, v, z = 0; | ||
795 | int ret = 0; | ||
796 | |||
797 | if ((a->neg) && (BIO_write(bp, "-", 1) != 1)) | ||
798 | goto end; | ||
799 | if (BN_is_zero(a) && (BIO_write(bp, "0", 1) != 1)) | ||
800 | goto end; | ||
801 | for (i = a->top - 1; i >= 0; i--) { | ||
802 | for (j = BN_BITS2 - 4; j >= 0; j -= 4) { | ||
803 | /* strip leading zeros */ | ||
804 | v = ((int)(a->d[i] >> (long)j)) & 0x0f; | ||
805 | if (z || (v != 0)) { | ||
806 | if (BIO_write(bp, &hex_digits[v], 1) != 1) | ||
807 | goto end; | ||
808 | z = 1; | ||
809 | } | ||
810 | } | ||
811 | } | ||
812 | ret = 1; | ||
813 | |||
814 | end: | ||
815 | return (ret); | ||
816 | } | ||
817 | LCRYPTO_ALIAS(BN_print); | ||
818 | #endif | ||