summaryrefslogtreecommitdiff
path: root/crypto/bn/bn_print.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/bn/bn_print.c')
-rw-r--r--crypto/bn/bn_print.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/crypto/bn/bn_print.c b/crypto/bn/bn_print.c
index 5fb8473f37..bebb466d08 100644
--- a/crypto/bn/bn_print.c
+++ b/crypto/bn/bn_print.c
@@ -62,7 +62,7 @@
#include <openssl/buffer.h>
#include "bn_lcl.h"
-static const char *Hex="0123456789ABCDEF";
+static const char Hex[]="0123456789ABCDEF";
/* Must 'OPENSSL_free' the returned data */
char *BN_bn2hex(const BIGNUM *a)
@@ -134,7 +134,7 @@ char *BN_bn2dec(const BIGNUM *a)
}
else
{
- if (BN_get_sign(t))
+ if (BN_is_negative(t))
*p++ = '-';
i=0;
@@ -294,6 +294,27 @@ err:
return(0);
}
+int BN_asc2bn(BIGNUM **bn, const char *a)
+ {
+ const char *p = a;
+ if (*p == '-')
+ p++;
+
+ if (p[0] == '0' && (p[1] == 'X' || p[1] == 'x'))
+ {
+ if (!BN_hex2bn(bn, p + 2))
+ return 0;
+ }
+ else
+ {
+ if (!BN_dec2bn(bn, p))
+ return 0;
+ }
+ if (*a == '-')
+ (*bn)->neg = 1;
+ return 1;
+ }
+
#ifndef OPENSSL_NO_BIO
#ifndef OPENSSL_NO_FP_API
int BN_print_fp(FILE *fp, const BIGNUM *a)