From: Dr. Stephen Henson Date: Fri, 8 Feb 2008 13:07:04 +0000 (+0000) Subject: Support custom primitive type printing routines and add one to LONG type. X-Git-Tag: OpenSSL_0_9_8k^2~557 X-Git-Url: https://git.openssl.org/?p=openssl.git;a=commitdiff_plain;h=9e5df8e44849d0113e3b5530478dcaeac401fc64 Support custom primitive type printing routines and add one to LONG type. --- diff --git a/crypto/asn1/asn1t.h b/crypto/asn1/asn1t.h index fc7ea0d1b2..fff8030f7d 100644 --- a/crypto/asn1/asn1t.h +++ b/crypto/asn1/asn1t.h @@ -654,6 +654,7 @@ typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval, typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); +typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx); typedef struct ASN1_COMPAT_FUNCS_st { ASN1_new_func *asn1_new; @@ -680,6 +681,7 @@ typedef struct ASN1_PRIMITIVE_FUNCS_st { ASN1_ex_free_func *prim_clear; ASN1_primitive_c2i *prim_c2i; ASN1_primitive_i2c *prim_i2c; + ASN1_primitive_print *prim_print; } ASN1_PRIMITIVE_FUNCS; /* This is the ASN1_AUX structure: it handles various diff --git a/crypto/asn1/tasn_prn.c b/crypto/asn1/tasn_prn.c index d9f32bd890..d2830a5ead 100644 --- a/crypto/asn1/tasn_prn.c +++ b/crypto/asn1/tasn_prn.c @@ -522,8 +522,12 @@ static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld, ASN1_STRING *str; int ret = 1, needlf = 1; const char *pname; + const ASN1_PRIMITIVE_FUNCS *pf; + pf = it->funcs; if (!asn1_print_fsname(out, indent, fname, sname, pctx)) return 0; + if (pf && pf->prim_print) + return pf->prim_print(out, fld, it, indent, pctx); str = (ASN1_STRING *)*fld; if (it->itype == ASN1_ITYPE_MSTRING) utype = str->type & ~V_ASN1_NEG; diff --git a/crypto/asn1/x_long.c b/crypto/asn1/x_long.c index 0db233cb95..6c7fc2213f 100644 --- a/crypto/asn1/x_long.c +++ b/crypto/asn1/x_long.c @@ -71,6 +71,7 @@ static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it); static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it); static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); +static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx); static ASN1_PRIMITIVE_FUNCS long_pf = { NULL, 0, @@ -78,7 +79,8 @@ static ASN1_PRIMITIVE_FUNCS long_pf = { long_free, long_free, /* Clear should set to initial value */ long_c2i, - long_i2c + long_i2c, + long_print }; ASN1_ITEM_start(LONG) @@ -169,3 +171,9 @@ static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, memcpy(cp, <mp, sizeof(long)); return 1; } + +static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, + int indent, const ASN1_PCTX *pctx) + { + return BIO_printf(out, "%ld\n", *(long *)pval); + }