Commit 24484759 authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

Extend callback function to support print customization.

parent 5abe32d8
Loading
Loading
Loading
Loading
+12 −2
Original line number Original line Diff line number Diff line
@@ -3,7 +3,7 @@
 * project 2000.
 * project 2000.
 */
 */
/* ====================================================================
/* ====================================================================
 * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.
 * Copyright (c) 2000-2005 The OpenSSL Project.  All rights reserved.
 *
 *
 * Redistribution and use in source and binary forms, with or without
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * modification, are permitted provided that the following conditions
@@ -695,7 +695,8 @@ typedef struct ASN1_PRIMITIVE_FUNCS_st {
 * then an external type is more appropriate.
 * then an external type is more appropriate.
 */
 */


typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it);
typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,
				void *exarg);


typedef struct ASN1_AUX_st {
typedef struct ASN1_AUX_st {
	void *app_data;
	void *app_data;
@@ -706,6 +707,13 @@ typedef struct ASN1_AUX_st {
	int enc_offset;		/* Offset of ASN1_ENCODING structure */
	int enc_offset;		/* Offset of ASN1_ENCODING structure */
} ASN1_AUX;
} ASN1_AUX;


/* For print related callbacks exarg points to this structure */
typedef struct ASN1_PRINT_ARG_st {
	BIO *out;
	int indent;
	ASN1_PCTX *pctx;
} ASN1_PRINT_ARG;

/* Flags in ASN1_AUX */
/* Flags in ASN1_AUX */


/* Use a reference count */
/* Use a reference count */
@@ -725,6 +733,8 @@ typedef struct ASN1_AUX_st {
#define ASN1_OP_D2I_POST	5
#define ASN1_OP_D2I_POST	5
#define ASN1_OP_I2D_PRE		6
#define ASN1_OP_I2D_PRE		6
#define ASN1_OP_I2D_POST	7
#define ASN1_OP_I2D_POST	7
#define ASN1_OP_PRINT_PRE	8
#define ASN1_OP_PRINT_POST	9


/* Macro to implement a primitive type */
/* Macro to implement a primitive type */
#define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)
#define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)
+3 −2
Original line number Original line Diff line number Diff line
@@ -3,7 +3,7 @@
 * project 1999.
 * project 1999.
 */
 */
/* ====================================================================
/* ====================================================================
 * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
 * Copyright (c) 1999-2005 The OpenSSL Project.  All rights reserved.
 *
 *
 * Redistribution and use in source and binary forms, with or without
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * modification, are permitted provided that the following conditions
@@ -62,7 +62,8 @@
#include <openssl/x509.h>
#include <openssl/x509.h>
#include <openssl/objects.h>
#include <openssl/objects.h>


static int nsseq_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
static int nsseq_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
							void *exarg)
{
{
	if(operation == ASN1_OP_NEW_POST) {
	if(operation == ASN1_OP_NEW_POST) {
		NETSCAPE_CERT_SEQUENCE *nsseq;
		NETSCAPE_CERT_SEQUENCE *nsseq;
+3 −2
Original line number Original line Diff line number Diff line
@@ -3,7 +3,7 @@
 * project 1999.
 * project 1999.
 */
 */
/* ====================================================================
/* ====================================================================
 * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
 * Copyright (c) 1999-2005 The OpenSSL Project.  All rights reserved.
 *
 *
 * Redistribution and use in source and binary forms, with or without
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * modification, are permitted provided that the following conditions
@@ -62,7 +62,8 @@
#include <openssl/x509.h>
#include <openssl/x509.h>


/* Minor tweak to operation: zero private key data */
/* Minor tweak to operation: zero private key data */
static int pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
static int pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
							void *exarg)
{
{
	/* Since the structure must still be valid use ASN1_OP_FREE_PRE */
	/* Since the structure must still be valid use ASN1_OP_FREE_PRE */
	if(operation == ASN1_OP_FREE_PRE) {
	if(operation == ASN1_OP_FREE_PRE) {
+4 −4
Original line number Original line Diff line number Diff line
@@ -300,7 +300,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,




		case ASN1_ITYPE_CHOICE:
		case ASN1_ITYPE_CHOICE:
		if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it))
		if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))
				goto auxerr;
				goto auxerr;


		/* Allocate structure */
		/* Allocate structure */
@@ -350,7 +350,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,


		asn1_set_choice_selector(pval, i, it);
		asn1_set_choice_selector(pval, i, it);
		*in = p;
		*in = p;
		if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it))
		if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it, NULL))
				goto auxerr;
				goto auxerr;
		return 1;
		return 1;


@@ -397,7 +397,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
			goto err;
			goto err;
			}
			}


		if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it))
		if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))
				goto auxerr;
				goto auxerr;


		/* Get each field entry */
		/* Get each field entry */
@@ -499,7 +499,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
		if (!asn1_enc_save(pval, *in, p - *in, it))
		if (!asn1_enc_save(pval, *in, p - *in, it))
			goto auxerr;
			goto auxerr;
		*in = p;
		*in = p;
		if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it))
		if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it, NULL))
				goto auxerr;
				goto auxerr;
		return 1;
		return 1;


+4 −4
Original line number Original line Diff line number Diff line
@@ -157,7 +157,7 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
		return asn1_i2d_ex_primitive(pval, out, it, -1, aclass);
		return asn1_i2d_ex_primitive(pval, out, it, -1, aclass);


		case ASN1_ITYPE_CHOICE:
		case ASN1_ITYPE_CHOICE:
		if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it))
		if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))
				return 0;
				return 0;
		i = asn1_get_choice_selector(pval, it);
		i = asn1_get_choice_selector(pval, it);
		if ((i >= 0) && (i < it->tcount))
		if ((i >= 0) && (i < it->tcount))
@@ -170,7 +170,7 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
								-1, aclass);
								-1, aclass);
			}
			}
		/* Fixme: error condition if selector out of range */
		/* Fixme: error condition if selector out of range */
		if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it))
		if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL))
				return 0;
				return 0;
		break;
		break;


@@ -215,7 +215,7 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
			aclass = (aclass & ~ASN1_TFLG_TAG_CLASS)
			aclass = (aclass & ~ASN1_TFLG_TAG_CLASS)
					| V_ASN1_UNIVERSAL;
					| V_ASN1_UNIVERSAL;
			}
			}
		if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it))
		if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))
				return 0;
				return 0;
		/* First work out sequence content length */
		/* First work out sequence content length */
		for (i = 0, tt = it->templates; i < it->tcount; tt++, i++)
		for (i = 0, tt = it->templates; i < it->tcount; tt++, i++)
@@ -249,7 +249,7 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
			}
			}
		if (ndef == 2)
		if (ndef == 2)
			ASN1_put_eoc(out);
			ASN1_put_eoc(out);
		if (asn1_cb  && !asn1_cb(ASN1_OP_I2D_POST, pval, it))
		if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL))
				return 0;
				return 0;
		return seqlen;
		return seqlen;


Loading