Fixes to various ASN1_INTEGER routines for negative case.
[openssl.git] / crypto / asn1 / f_int.c
index 6b090f6740c2c1f6a142773ae8787eee576651d9..48cc3bfb90d52bb66ca13f0b84d549f3be3f6130 100644 (file)
@@ -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
                {