diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/a_dup.c')
-rw-r--r-- | src/lib/libcrypto/asn1/a_dup.c | 28 |
1 files changed, 26 insertions, 2 deletions
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 @@ | |||
58 | 58 | ||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
61 | #include <openssl/asn1_mac.h> | 61 | #include <openssl/asn1.h> |
62 | 62 | ||
63 | #define READ_CHUNK 2048 | 63 | #ifndef NO_OLD_ASN1 |
64 | 64 | ||
65 | char *ASN1_dup(int (*i2d)(), char *(*d2i)(), char *x) | 65 | char *ASN1_dup(int (*i2d)(), char *(*d2i)(), char *x) |
66 | { | 66 | { |
@@ -81,3 +81,27 @@ char *ASN1_dup(int (*i2d)(), char *(*d2i)(), char *x) | |||
81 | OPENSSL_free(b); | 81 | OPENSSL_free(b); |
82 | return(ret); | 82 | return(ret); |
83 | } | 83 | } |
84 | |||
85 | #endif | ||
86 | |||
87 | /* ASN1_ITEM version of dup: this follows the model above except we don't need | ||
88 | * to allocate the buffer. At some point this could be rewritten to directly dup | ||
89 | * the underlying structure instead of doing and encode and decode. | ||
90 | */ | ||
91 | |||
92 | void *ASN1_item_dup(const ASN1_ITEM *it, void *x) | ||
93 | { | ||
94 | unsigned char *b = NULL, *p; | ||
95 | long i; | ||
96 | void *ret; | ||
97 | |||
98 | if (x == NULL) return(NULL); | ||
99 | |||
100 | i=ASN1_item_i2d(x,&b,it); | ||
101 | if (b == NULL) | ||
102 | { ASN1err(ASN1_F_ASN1_DUP,ERR_R_MALLOC_FAILURE); return(NULL); } | ||
103 | p= b; | ||
104 | ret=ASN1_item_d2i(NULL,&p,i, it); | ||
105 | OPENSSL_free(b); | ||
106 | return(ret); | ||
107 | } | ||