diff options
author | miod <> | 2014-04-15 20:19:57 +0000 |
---|---|---|
committer | miod <> | 2014-04-15 20:19:57 +0000 |
commit | f6394a1bd8f61db79694977e8d0afdfd4e4ff1a1 (patch) | |
tree | 3b957c0020405f9f6e90af181b1ebb5124c6e68a /src/lib/libcrypto/asn1/asn_pack.c | |
parent | 2125ec026993d82b51335463dc7fc5b899a4057a (diff) | |
download | openbsd-f6394a1bd8f61db79694977e8d0afdfd4e4ff1a1.tar.gz openbsd-f6394a1bd8f61db79694977e8d0afdfd4e4ff1a1.tar.bz2 openbsd-f6394a1bd8f61db79694977e8d0afdfd4e4ff1a1.zip |
The NO_ASN1_OLD define was introduced in 0.9.7, 8 years ago, to allow for
obsolete (and mostly internal) routines to be compiled out.
We don't expect any reasonable software to stick to these interfaces, so better
clean up the view and unifdef -DNO_ASN1_OLD.
The astute reader will notice the existence of NO_OLD_ASN1 which serves a
similar purpose, but is more entangled. Its time will come, soon.
Diffstat (limited to 'src/lib/libcrypto/asn1/asn_pack.c')
-rw-r--r-- | src/lib/libcrypto/asn1/asn_pack.c | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/src/lib/libcrypto/asn1/asn_pack.c b/src/lib/libcrypto/asn1/asn_pack.c index ad738217d7..1886508654 100644 --- a/src/lib/libcrypto/asn1/asn_pack.c +++ b/src/lib/libcrypto/asn1/asn_pack.c | |||
@@ -60,93 +60,6 @@ | |||
60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
61 | #include <openssl/asn1.h> | 61 | #include <openssl/asn1.h> |
62 | 62 | ||
63 | #ifndef NO_ASN1_OLD | ||
64 | |||
65 | /* ASN1 packing and unpacking functions */ | ||
66 | |||
67 | /* Turn an ASN1 encoded SEQUENCE OF into a STACK of structures */ | ||
68 | |||
69 | STACK_OF(OPENSSL_BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len, | ||
70 | d2i_of_void *d2i, void (*free_func)(OPENSSL_BLOCK)) | ||
71 | { | ||
72 | STACK_OF(OPENSSL_BLOCK) *sk; | ||
73 | const unsigned char *pbuf; | ||
74 | pbuf = buf; | ||
75 | if (!(sk = d2i_ASN1_SET(NULL, &pbuf, len, d2i, free_func, | ||
76 | V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL))) | ||
77 | ASN1err(ASN1_F_ASN1_SEQ_UNPACK,ASN1_R_DECODE_ERROR); | ||
78 | return sk; | ||
79 | } | ||
80 | |||
81 | /* Turn a STACK structures into an ASN1 encoded SEQUENCE OF structure in a | ||
82 | * OPENSSL_malloc'ed buffer | ||
83 | */ | ||
84 | |||
85 | unsigned char *ASN1_seq_pack(STACK_OF(OPENSSL_BLOCK) *safes, i2d_of_void *i2d, | ||
86 | unsigned char **buf, int *len) | ||
87 | { | ||
88 | int safelen; | ||
89 | unsigned char *safe, *p; | ||
90 | if (!(safelen = i2d_ASN1_SET(safes, NULL, i2d, V_ASN1_SEQUENCE, | ||
91 | V_ASN1_UNIVERSAL, IS_SEQUENCE))) { | ||
92 | ASN1err(ASN1_F_ASN1_SEQ_PACK,ASN1_R_ENCODE_ERROR); | ||
93 | return NULL; | ||
94 | } | ||
95 | if (!(safe = OPENSSL_malloc (safelen))) { | ||
96 | ASN1err(ASN1_F_ASN1_SEQ_PACK,ERR_R_MALLOC_FAILURE); | ||
97 | return NULL; | ||
98 | } | ||
99 | p = safe; | ||
100 | i2d_ASN1_SET(safes, &p, i2d, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, | ||
101 | IS_SEQUENCE); | ||
102 | if (len) *len = safelen; | ||
103 | if (buf) *buf = safe; | ||
104 | return safe; | ||
105 | } | ||
106 | |||
107 | /* Extract an ASN1 object from an ASN1_STRING */ | ||
108 | |||
109 | void *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i) | ||
110 | { | ||
111 | const unsigned char *p; | ||
112 | char *ret; | ||
113 | |||
114 | p = oct->data; | ||
115 | if(!(ret = d2i(NULL, &p, oct->length))) | ||
116 | ASN1err(ASN1_F_ASN1_UNPACK_STRING,ASN1_R_DECODE_ERROR); | ||
117 | return ret; | ||
118 | } | ||
119 | |||
120 | /* Pack an ASN1 object into an ASN1_STRING */ | ||
121 | |||
122 | ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d, ASN1_STRING **oct) | ||
123 | { | ||
124 | unsigned char *p; | ||
125 | ASN1_STRING *octmp; | ||
126 | |||
127 | if (!oct || !*oct) { | ||
128 | if (!(octmp = ASN1_STRING_new ())) { | ||
129 | ASN1err(ASN1_F_ASN1_PACK_STRING,ERR_R_MALLOC_FAILURE); | ||
130 | return NULL; | ||
131 | } | ||
132 | if (oct) *oct = octmp; | ||
133 | } else octmp = *oct; | ||
134 | |||
135 | if (!(octmp->length = i2d(obj, NULL))) { | ||
136 | ASN1err(ASN1_F_ASN1_PACK_STRING,ASN1_R_ENCODE_ERROR); | ||
137 | return NULL; | ||
138 | } | ||
139 | if (!(p = OPENSSL_malloc (octmp->length))) { | ||
140 | ASN1err(ASN1_F_ASN1_PACK_STRING,ERR_R_MALLOC_FAILURE); | ||
141 | return NULL; | ||
142 | } | ||
143 | octmp->data = p; | ||
144 | i2d (obj, &p); | ||
145 | return octmp; | ||
146 | } | ||
147 | |||
148 | #endif | ||
149 | |||
150 | /* ASN1_ITEM versions of the above */ | 63 | /* ASN1_ITEM versions of the above */ |
151 | 64 | ||
152 | ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct) | 65 | ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct) |