Implement internally opaque bn access from ts

Reviewed-by: Tim Hudson <tjh@openssl.org>
This commit is contained in:
Matt Caswell 2014-10-28 23:04:10 +00:00
parent aeb556f831
commit 2cbc8d7de5

View File

@ -69,19 +69,20 @@
int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num) int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num)
{ {
BIGNUM num_bn; BIGNUM *num_bn;
int result = 0; int result = 0;
char *hex; char *hex;
BN_init(&num_bn); num_bn = BN_new();
ASN1_INTEGER_to_BN(num, &num_bn); if(!num_bn) return -1;
if ((hex = BN_bn2hex(&num_bn))) ASN1_INTEGER_to_BN(num, num_bn);
if ((hex = BN_bn2hex(num_bn)))
{ {
result = BIO_write(bio, "0x", 2) > 0; result = BIO_write(bio, "0x", 2) > 0;
result = result && BIO_write(bio, hex, strlen(hex)) > 0; result = result && BIO_write(bio, hex, strlen(hex)) > 0;
OPENSSL_free(hex); OPENSSL_free(hex);
} }
BN_free(&num_bn); BN_free(num_bn);
return result; return result;
} }