From b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 Mon Sep 17 00:00:00 2001 From: beck <> Date: Wed, 15 May 2002 02:29:21 +0000 Subject: OpenSSL 0.9.7 stable 2002 05 08 merge --- src/lib/libcrypto/asn1/a_dup.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src/lib/libcrypto/asn1/a_dup.c') diff --git a/src/lib/libcrypto/asn1/a_dup.c b/src/lib/libcrypto/asn1/a_dup.c index c3bda58a5d..58a017884c 100644 --- a/src/lib/libcrypto/asn1/a_dup.c +++ b/src/lib/libcrypto/asn1/a_dup.c @@ -58,9 +58,9 @@ #include #include "cryptlib.h" -#include +#include -#define READ_CHUNK 2048 +#ifndef NO_OLD_ASN1 char *ASN1_dup(int (*i2d)(), char *(*d2i)(), char *x) { @@ -81,3 +81,27 @@ char *ASN1_dup(int (*i2d)(), char *(*d2i)(), char *x) OPENSSL_free(b); return(ret); } + +#endif + +/* ASN1_ITEM version of dup: this follows the model above except we don't need + * to allocate the buffer. At some point this could be rewritten to directly dup + * the underlying structure instead of doing and encode and decode. + */ + +void *ASN1_item_dup(const ASN1_ITEM *it, void *x) + { + unsigned char *b = NULL, *p; + long i; + void *ret; + + if (x == NULL) return(NULL); + + i=ASN1_item_i2d(x,&b,it); + if (b == NULL) + { ASN1err(ASN1_F_ASN1_DUP,ERR_R_MALLOC_FAILURE); return(NULL); } + p= b; + ret=ASN1_item_d2i(NULL,&p,i, it); + OPENSSL_free(b); + return(ret); + } -- cgit v1.2.3-55-g6feb