diff options
Diffstat (limited to 'crypto/asn1')
-rw-r--r-- | crypto/asn1/a_int.c | 6 | ||||
-rw-r--r-- | crypto/asn1/f_int.c | 8 |
2 files changed, 13 insertions, 1 deletions
diff --git a/crypto/asn1/a_int.c b/crypto/asn1/a_int.c index b0fc97e..496704b 100644 --- a/crypto/asn1/a_int.c +++ b/crypto/asn1/a_int.c @@ -399,6 +399,12 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai) len=((j == 0)?0:((j/8)+1)); ret->data=(unsigned char *)OPENSSL_malloc(len+4); ret->length=BN_bn2bin(bn,ret->data); + /* Correct zero case */ + if(!ret->length) + { + ret->data[0] = 0; + ret->length = 1; + } return(ret); err: if (ret != ai) M_ASN1_INTEGER_free(ret); diff --git a/crypto/asn1/f_int.c b/crypto/asn1/f_int.c index 6b090f6..48cc3bf 100644 --- a/crypto/asn1/f_int.c +++ b/crypto/asn1/f_int.c @@ -69,10 +69,16 @@ int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a) if (a == NULL) return(0); + if (a->type & V_ASN1_NEG) + { + if (BIO_write(bp, "-", 1) != 1) goto err; + n = 1; + } + if (a->length == 0) { if (BIO_write(bp,"00",2) != 2) goto err; - n=2; + n += 2; } else { |