In  openssl-0.9.7g/crypto/asn1/t_509.c, there is this function:

int X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig)
{
        unsigned char *s;
        int i, n;
        if (BIO_puts(bp,"    Signature Algorithm: ") <= 0) return 0;
        if (i2a_ASN1_OBJECT(bp, sigalg->algorithm) <= 0) return 0;

        n=sig->length;
        s=sig->data;
        for (i=0; i<n; i++)
                {
                if ((i%18) == 0)
                        if (BIO_write(bp,"\n        ",9) <= 0) return 0;
                        if (BIO_printf(bp,"%02x%s",s[i],
                                ((i+1) == n)?"":":") <= 0) return 0;
                }
        if (BIO_write(bp,"\n",1) != 1) return 0;
        return 1;
}

That indenting looks wrong (originally I thought that there were {} missing, 
but now realise it should look something like:
int X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig)
{
        unsigned char *s;
        int i, n;
        if (BIO_puts(bp,"    Signature Algorithm: ") <= 0) return 0;
        if (i2a_ASN1_OBJECT(bp, sigalg->algorithm) <= 0) return 0;

        n=sig->length;
        s=sig->data;
        for (i=0; i<n; i++)
                {
                if ((i%18) == 0) /* put in a blank line every so often... */
                        if (BIO_write(bp,"\n        ",9) <= 0) return 0;
                if (BIO_printf(bp,"%02x%s",s[i], ((i+1) == n)?"":":") <= 0)
                        return 0;
                }
        if (BIO_write(bp,"\n",1) != 1) return 0;
        return 1;
}

Note: I'm not worried about the placement of the return statements - I just 
moved that one because of probable line wrapping....

Brad

Attachment: pgpsKkMAyGbUG.pgp
Description: PGP signature

Reply via email to