summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/asn1/asn1t.h37
-rw-r--r--src/lib/libcrypto/asn1/tasn_dec.c72
-rw-r--r--src/lib/libcrypto/asn1/tasn_enc.c17
-rw-r--r--src/lib/libcrypto/asn1/tasn_fre.c9
-rw-r--r--src/lib/libcrypto/asn1/tasn_new.c13
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1t.h37
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_dec.c72
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_enc.c17
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_fre.c9
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_new.c13
10 files changed, 14 insertions, 282 deletions
diff --git a/src/lib/libcrypto/asn1/asn1t.h b/src/lib/libcrypto/asn1/asn1t.h
index 1d96df8148..3d6874d874 100644
--- a/src/lib/libcrypto/asn1/asn1t.h
+++ b/src/lib/libcrypto/asn1/asn1t.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn1t.h,v 1.10 2015/02/10 08:05:16 jsing Exp $ */ 1/* $OpenBSD: asn1t.h,v 1.11 2015/02/14 15:23:57 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -549,10 +549,6 @@ const char *sname; /* Structure name */
549 * The 'funcs' field is used for application 549 * The 'funcs' field is used for application
550 * specific functions. 550 * specific functions.
551 * 551 *
552 * For COMPAT types the funcs field gives a
553 * set of functions that handle this type, this
554 * supports the old d2i, i2d convention.
555 *
556 * The EXTERN type uses a new style d2i/i2d. 552 * The EXTERN type uses a new style d2i/i2d.
557 * The new style should be used where possible 553 * The new style should be used where possible
558 * because it avoids things like the d2i IMPLICIT 554 * because it avoids things like the d2i IMPLICIT
@@ -577,8 +573,6 @@ const char *sname; /* Structure name */
577 573
578#define ASN1_ITYPE_CHOICE 0x2 574#define ASN1_ITYPE_CHOICE 0x2
579 575
580#define ASN1_ITYPE_COMPAT 0x3
581
582#define ASN1_ITYPE_EXTERN 0x4 576#define ASN1_ITYPE_EXTERN 0x4
583 577
584#define ASN1_ITYPE_MSTRING 0x5 578#define ASN1_ITYPE_MSTRING 0x5
@@ -621,13 +615,6 @@ typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *puty
621typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); 615typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it);
622typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx); 616typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx);
623 617
624typedef struct ASN1_COMPAT_FUNCS_st {
625 ASN1_new_func *asn1_new;
626 ASN1_free_func *asn1_free;
627 ASN1_d2i_func *asn1_d2i;
628 ASN1_i2d_func *asn1_i2d;
629} ASN1_COMPAT_FUNCS;
630
631typedef struct ASN1_EXTERN_FUNCS_st { 618typedef struct ASN1_EXTERN_FUNCS_st {
632 void *app_data; 619 void *app_data;
633 ASN1_ex_new_func *asn1_ex_new; 620 ASN1_ex_new_func *asn1_ex_new;
@@ -733,28 +720,6 @@ typedef struct ASN1_STREAM_ARG_st {
733 ASN1_ITEM_start(itname) \ 720 ASN1_ITEM_start(itname) \
734 ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \ 721 ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \
735 ASN1_ITEM_end(itname) 722 ASN1_ITEM_end(itname)
736
737/* Macro to implement an ASN1_ITEM in terms of old style funcs */
738
739#define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE)
740
741#define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \
742 static const ASN1_COMPAT_FUNCS sname##_ff = { \
743 (ASN1_new_func *)sname##_new, \
744 (ASN1_free_func *)sname##_free, \
745 (ASN1_d2i_func *)d2i_##sname, \
746 (ASN1_i2d_func *)i2d_##sname, \
747 }; \
748 ASN1_ITEM_start(sname) \
749 ASN1_ITYPE_COMPAT, \
750 tag, \
751 NULL, \
752 0, \
753 &sname##_ff, \
754 0, \
755 #sname \
756 ASN1_ITEM_end(sname)
757
758#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \ 723#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \
759 ASN1_ITEM_start(sname) \ 724 ASN1_ITEM_start(sname) \
760 ASN1_ITYPE_EXTERN, \ 725 ASN1_ITYPE_EXTERN, \
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c
index f633d03e9c..791a10a9c0 100644
--- a/src/lib/libcrypto/asn1/tasn_dec.c
+++ b/src/lib/libcrypto/asn1/tasn_dec.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_dec.c,v 1.24 2014/06/12 15:49:27 deraadt Exp $ */ 1/* $OpenBSD: tasn_dec.c,v 1.25 2015/02/14 15:23:57 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -155,19 +155,17 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
155 const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx) 155 const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx)
156{ 156{
157 const ASN1_TEMPLATE *tt, *errtt = NULL; 157 const ASN1_TEMPLATE *tt, *errtt = NULL;
158 const ASN1_COMPAT_FUNCS *cf;
159 const ASN1_EXTERN_FUNCS *ef; 158 const ASN1_EXTERN_FUNCS *ef;
160 const ASN1_AUX *aux = it->funcs; 159 const ASN1_AUX *aux = it->funcs;
161 ASN1_aux_cb *asn1_cb; 160 ASN1_aux_cb *asn1_cb;
162 const unsigned char *p = NULL, *q; 161 const unsigned char *p = NULL, *q;
163 unsigned char *wp = NULL; /* BIG FAT WARNING! BREAKS CONST WHERE USED */ 162 unsigned char oclass;
164 unsigned char imphack = 0, oclass;
165 char seq_eoc, seq_nolen, cst, isopt; 163 char seq_eoc, seq_nolen, cst, isopt;
166 long tmplen; 164 long tmplen;
167 int i; 165 int i;
168 int otag; 166 int otag;
169 int ret = 0; 167 int ret = 0;
170 ASN1_VALUE **pchptr, *ptmpval; 168 ASN1_VALUE **pchptr;
171 169
172 if (!pval) 170 if (!pval)
173 return 0; 171 return 0;
@@ -236,70 +234,6 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
236 return ef->asn1_ex_d2i(pval, in, len, 234 return ef->asn1_ex_d2i(pval, in, len,
237 it, tag, aclass, opt, ctx); 235 it, tag, aclass, opt, ctx);
238 236
239 case ASN1_ITYPE_COMPAT:
240 /* we must resort to old style evil hackery */
241 cf = it->funcs;
242
243 /* If OPTIONAL see if it is there */
244 if (opt) {
245 int exptag;
246 p = *in;
247 if (tag == -1)
248 exptag = it->utype;
249 else
250 exptag = tag;
251 /* Don't care about anything other than presence
252 * of expected tag */
253
254 ret = asn1_check_tlen(NULL, NULL, NULL, NULL, NULL,
255 &p, len, exptag, aclass, 1, ctx);
256 if (!ret) {
257 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I,
258 ERR_R_NESTED_ASN1_ERROR);
259 goto err;
260 }
261 if (ret == -1)
262 return -1;
263 }
264
265 /* This is the old style evil hack IMPLICIT handling:
266 * since the underlying code is expecting a tag and
267 * class other than the one present we change the
268 * buffer temporarily then change it back afterwards.
269 * This doesn't and never did work for tags > 30.
270 *
271 * Yes this is *horrible* but it is only needed for
272 * old style d2i which will hopefully not be around
273 * for much longer.
274 * FIXME: should copy the buffer then modify it so
275 * the input buffer can be const: we should *always*
276 * copy because the old style d2i might modify the
277 * buffer.
278 */
279
280 if (tag != -1) {
281 wp = *(unsigned char **)in;
282 imphack = *wp;
283 if (p == NULL) {
284 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I,
285 ERR_R_NESTED_ASN1_ERROR);
286 goto err;
287 }
288 *wp = (unsigned char)((*p & V_ASN1_CONSTRUCTED) |
289 it->utype);
290 }
291
292 ptmpval = cf->asn1_d2i(pval, in, len);
293
294 if (tag != -1)
295 *wp = imphack;
296
297 if (ptmpval)
298 return 1;
299
300 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
301 goto err;
302
303 case ASN1_ITYPE_CHOICE: 237 case ASN1_ITYPE_CHOICE:
304 if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL)) 238 if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))
305 goto auxerr; 239 goto auxerr;
diff --git a/src/lib/libcrypto/asn1/tasn_enc.c b/src/lib/libcrypto/asn1/tasn_enc.c
index 67d774a9c1..c59033e54d 100644
--- a/src/lib/libcrypto/asn1/tasn_enc.c
+++ b/src/lib/libcrypto/asn1/tasn_enc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_enc.c,v 1.15 2015/02/14 15:21:49 miod Exp $ */ 1/* $OpenBSD: tasn_enc.c,v 1.16 2015/02/14 15:23:57 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -131,9 +131,7 @@ ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it,
131 int tag, int aclass) 131 int tag, int aclass)
132{ 132{
133 const ASN1_TEMPLATE *tt = NULL; 133 const ASN1_TEMPLATE *tt = NULL;
134 unsigned char *p = NULL;
135 int i, seqcontlen, seqlen, ndef = 1; 134 int i, seqcontlen, seqlen, ndef = 1;
136 const ASN1_COMPAT_FUNCS *cf;
137 const ASN1_EXTERN_FUNCS *ef; 135 const ASN1_EXTERN_FUNCS *ef;
138 const ASN1_AUX *aux = it->funcs; 136 const ASN1_AUX *aux = it->funcs;
139 ASN1_aux_cb *asn1_cb = 0; 137 ASN1_aux_cb *asn1_cb = 0;
@@ -178,19 +176,6 @@ ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it,
178 ef = it->funcs; 176 ef = it->funcs;
179 return ef->asn1_ex_i2d(pval, out, it, tag, aclass); 177 return ef->asn1_ex_i2d(pval, out, it, tag, aclass);
180 178
181 case ASN1_ITYPE_COMPAT:
182 /* old style hackery... */
183 cf = it->funcs;
184 if (out)
185 p = *out;
186 i = cf->asn1_i2d(*pval, out);
187 /* Fixup for IMPLICIT tag: note this messes up for tags > 30,
188 * but so did the old code. Tags > 30 are very rare anyway.
189 */
190 if (out && (tag != -1))
191 *p = aclass | tag | (*p & V_ASN1_CONSTRUCTED);
192 return i;
193
194 case ASN1_ITYPE_NDEF_SEQUENCE: 179 case ASN1_ITYPE_NDEF_SEQUENCE:
195 /* Use indefinite length constructed if requested */ 180 /* Use indefinite length constructed if requested */
196 if (aclass & ASN1_TFLG_NDEF) 181 if (aclass & ASN1_TFLG_NDEF)
diff --git a/src/lib/libcrypto/asn1/tasn_fre.c b/src/lib/libcrypto/asn1/tasn_fre.c
index 36b668a7f9..30d68786b1 100644
--- a/src/lib/libcrypto/asn1/tasn_fre.c
+++ b/src/lib/libcrypto/asn1/tasn_fre.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_fre.c,v 1.13 2015/02/14 13:32:46 jsing Exp $ */ 1/* $OpenBSD: tasn_fre.c,v 1.14 2015/02/14 15:23:57 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -84,7 +84,6 @@ asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine)
84{ 84{
85 const ASN1_TEMPLATE *tt = NULL, *seqtt; 85 const ASN1_TEMPLATE *tt = NULL, *seqtt;
86 const ASN1_EXTERN_FUNCS *ef; 86 const ASN1_EXTERN_FUNCS *ef;
87 const ASN1_COMPAT_FUNCS *cf;
88 const ASN1_AUX *aux = it->funcs; 87 const ASN1_AUX *aux = it->funcs;
89 ASN1_aux_cb *asn1_cb = NULL; 88 ASN1_aux_cb *asn1_cb = NULL;
90 int i; 89 int i;
@@ -128,12 +127,6 @@ asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine)
128 } 127 }
129 break; 128 break;
130 129
131 case ASN1_ITYPE_COMPAT:
132 cf = it->funcs;
133 if (cf && cf->asn1_free)
134 cf->asn1_free(*pval);
135 break;
136
137 case ASN1_ITYPE_EXTERN: 130 case ASN1_ITYPE_EXTERN:
138 ef = it->funcs; 131 ef = it->funcs;
139 if (ef && ef->asn1_ex_free) 132 if (ef && ef->asn1_ex_free)
diff --git a/src/lib/libcrypto/asn1/tasn_new.c b/src/lib/libcrypto/asn1/tasn_new.c
index 86b2b3facd..132df07637 100644
--- a/src/lib/libcrypto/asn1/tasn_new.c
+++ b/src/lib/libcrypto/asn1/tasn_new.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_new.c,v 1.13 2015/02/14 15:15:27 miod Exp $ */ 1/* $OpenBSD: tasn_new.c,v 1.14 2015/02/14 15:23:57 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -91,7 +91,6 @@ static int
91asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine) 91asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine)
92{ 92{
93 const ASN1_TEMPLATE *tt = NULL; 93 const ASN1_TEMPLATE *tt = NULL;
94 const ASN1_COMPAT_FUNCS *cf;
95 const ASN1_EXTERN_FUNCS *ef; 94 const ASN1_EXTERN_FUNCS *ef;
96 const ASN1_AUX *aux = it->funcs; 95 const ASN1_AUX *aux = it->funcs;
97 ASN1_aux_cb *asn1_cb = NULL; 96 ASN1_aux_cb *asn1_cb = NULL;
@@ -118,15 +117,6 @@ asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine)
118 } 117 }
119 break; 118 break;
120 119
121 case ASN1_ITYPE_COMPAT:
122 cf = it->funcs;
123 if (cf && cf->asn1_new) {
124 *pval = cf->asn1_new();
125 if (!*pval)
126 goto memerr;
127 }
128 break;
129
130 case ASN1_ITYPE_PRIMITIVE: 120 case ASN1_ITYPE_PRIMITIVE:
131 if (it->templates) { 121 if (it->templates) {
132 if (!ASN1_template_new(pval, it->templates)) 122 if (!ASN1_template_new(pval, it->templates))
@@ -243,7 +233,6 @@ asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
243 asn1_primitive_clear(pval, it); 233 asn1_primitive_clear(pval, it);
244 break; 234 break;
245 235
246 case ASN1_ITYPE_COMPAT:
247 case ASN1_ITYPE_CHOICE: 236 case ASN1_ITYPE_CHOICE:
248 case ASN1_ITYPE_SEQUENCE: 237 case ASN1_ITYPE_SEQUENCE:
249 case ASN1_ITYPE_NDEF_SEQUENCE: 238 case ASN1_ITYPE_NDEF_SEQUENCE:
diff --git a/src/lib/libssl/src/crypto/asn1/asn1t.h b/src/lib/libssl/src/crypto/asn1/asn1t.h
index 1d96df8148..3d6874d874 100644
--- a/src/lib/libssl/src/crypto/asn1/asn1t.h
+++ b/src/lib/libssl/src/crypto/asn1/asn1t.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn1t.h,v 1.10 2015/02/10 08:05:16 jsing Exp $ */ 1/* $OpenBSD: asn1t.h,v 1.11 2015/02/14 15:23:57 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -549,10 +549,6 @@ const char *sname; /* Structure name */
549 * The 'funcs' field is used for application 549 * The 'funcs' field is used for application
550 * specific functions. 550 * specific functions.
551 * 551 *
552 * For COMPAT types the funcs field gives a
553 * set of functions that handle this type, this
554 * supports the old d2i, i2d convention.
555 *
556 * The EXTERN type uses a new style d2i/i2d. 552 * The EXTERN type uses a new style d2i/i2d.
557 * The new style should be used where possible 553 * The new style should be used where possible
558 * because it avoids things like the d2i IMPLICIT 554 * because it avoids things like the d2i IMPLICIT
@@ -577,8 +573,6 @@ const char *sname; /* Structure name */
577 573
578#define ASN1_ITYPE_CHOICE 0x2 574#define ASN1_ITYPE_CHOICE 0x2
579 575
580#define ASN1_ITYPE_COMPAT 0x3
581
582#define ASN1_ITYPE_EXTERN 0x4 576#define ASN1_ITYPE_EXTERN 0x4
583 577
584#define ASN1_ITYPE_MSTRING 0x5 578#define ASN1_ITYPE_MSTRING 0x5
@@ -621,13 +615,6 @@ typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, int *puty
621typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it); 615typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it);
622typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx); 616typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx);
623 617
624typedef struct ASN1_COMPAT_FUNCS_st {
625 ASN1_new_func *asn1_new;
626 ASN1_free_func *asn1_free;
627 ASN1_d2i_func *asn1_d2i;
628 ASN1_i2d_func *asn1_i2d;
629} ASN1_COMPAT_FUNCS;
630
631typedef struct ASN1_EXTERN_FUNCS_st { 618typedef struct ASN1_EXTERN_FUNCS_st {
632 void *app_data; 619 void *app_data;
633 ASN1_ex_new_func *asn1_ex_new; 620 ASN1_ex_new_func *asn1_ex_new;
@@ -733,28 +720,6 @@ typedef struct ASN1_STREAM_ARG_st {
733 ASN1_ITEM_start(itname) \ 720 ASN1_ITEM_start(itname) \
734 ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \ 721 ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \
735 ASN1_ITEM_end(itname) 722 ASN1_ITEM_end(itname)
736
737/* Macro to implement an ASN1_ITEM in terms of old style funcs */
738
739#define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE)
740
741#define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \
742 static const ASN1_COMPAT_FUNCS sname##_ff = { \
743 (ASN1_new_func *)sname##_new, \
744 (ASN1_free_func *)sname##_free, \
745 (ASN1_d2i_func *)d2i_##sname, \
746 (ASN1_i2d_func *)i2d_##sname, \
747 }; \
748 ASN1_ITEM_start(sname) \
749 ASN1_ITYPE_COMPAT, \
750 tag, \
751 NULL, \
752 0, \
753 &sname##_ff, \
754 0, \
755 #sname \
756 ASN1_ITEM_end(sname)
757
758#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \ 723#define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \
759 ASN1_ITEM_start(sname) \ 724 ASN1_ITEM_start(sname) \
760 ASN1_ITYPE_EXTERN, \ 725 ASN1_ITYPE_EXTERN, \
diff --git a/src/lib/libssl/src/crypto/asn1/tasn_dec.c b/src/lib/libssl/src/crypto/asn1/tasn_dec.c
index f633d03e9c..791a10a9c0 100644
--- a/src/lib/libssl/src/crypto/asn1/tasn_dec.c
+++ b/src/lib/libssl/src/crypto/asn1/tasn_dec.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_dec.c,v 1.24 2014/06/12 15:49:27 deraadt Exp $ */ 1/* $OpenBSD: tasn_dec.c,v 1.25 2015/02/14 15:23:57 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -155,19 +155,17 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
155 const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx) 155 const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx)
156{ 156{
157 const ASN1_TEMPLATE *tt, *errtt = NULL; 157 const ASN1_TEMPLATE *tt, *errtt = NULL;
158 const ASN1_COMPAT_FUNCS *cf;
159 const ASN1_EXTERN_FUNCS *ef; 158 const ASN1_EXTERN_FUNCS *ef;
160 const ASN1_AUX *aux = it->funcs; 159 const ASN1_AUX *aux = it->funcs;
161 ASN1_aux_cb *asn1_cb; 160 ASN1_aux_cb *asn1_cb;
162 const unsigned char *p = NULL, *q; 161 const unsigned char *p = NULL, *q;
163 unsigned char *wp = NULL; /* BIG FAT WARNING! BREAKS CONST WHERE USED */ 162 unsigned char oclass;
164 unsigned char imphack = 0, oclass;
165 char seq_eoc, seq_nolen, cst, isopt; 163 char seq_eoc, seq_nolen, cst, isopt;
166 long tmplen; 164 long tmplen;
167 int i; 165 int i;
168 int otag; 166 int otag;
169 int ret = 0; 167 int ret = 0;
170 ASN1_VALUE **pchptr, *ptmpval; 168 ASN1_VALUE **pchptr;
171 169
172 if (!pval) 170 if (!pval)
173 return 0; 171 return 0;
@@ -236,70 +234,6 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
236 return ef->asn1_ex_d2i(pval, in, len, 234 return ef->asn1_ex_d2i(pval, in, len,
237 it, tag, aclass, opt, ctx); 235 it, tag, aclass, opt, ctx);
238 236
239 case ASN1_ITYPE_COMPAT:
240 /* we must resort to old style evil hackery */
241 cf = it->funcs;
242
243 /* If OPTIONAL see if it is there */
244 if (opt) {
245 int exptag;
246 p = *in;
247 if (tag == -1)
248 exptag = it->utype;
249 else
250 exptag = tag;
251 /* Don't care about anything other than presence
252 * of expected tag */
253
254 ret = asn1_check_tlen(NULL, NULL, NULL, NULL, NULL,
255 &p, len, exptag, aclass, 1, ctx);
256 if (!ret) {
257 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I,
258 ERR_R_NESTED_ASN1_ERROR);
259 goto err;
260 }
261 if (ret == -1)
262 return -1;
263 }
264
265 /* This is the old style evil hack IMPLICIT handling:
266 * since the underlying code is expecting a tag and
267 * class other than the one present we change the
268 * buffer temporarily then change it back afterwards.
269 * This doesn't and never did work for tags > 30.
270 *
271 * Yes this is *horrible* but it is only needed for
272 * old style d2i which will hopefully not be around
273 * for much longer.
274 * FIXME: should copy the buffer then modify it so
275 * the input buffer can be const: we should *always*
276 * copy because the old style d2i might modify the
277 * buffer.
278 */
279
280 if (tag != -1) {
281 wp = *(unsigned char **)in;
282 imphack = *wp;
283 if (p == NULL) {
284 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I,
285 ERR_R_NESTED_ASN1_ERROR);
286 goto err;
287 }
288 *wp = (unsigned char)((*p & V_ASN1_CONSTRUCTED) |
289 it->utype);
290 }
291
292 ptmpval = cf->asn1_d2i(pval, in, len);
293
294 if (tag != -1)
295 *wp = imphack;
296
297 if (ptmpval)
298 return 1;
299
300 ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
301 goto err;
302
303 case ASN1_ITYPE_CHOICE: 237 case ASN1_ITYPE_CHOICE:
304 if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL)) 238 if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))
305 goto auxerr; 239 goto auxerr;
diff --git a/src/lib/libssl/src/crypto/asn1/tasn_enc.c b/src/lib/libssl/src/crypto/asn1/tasn_enc.c
index 67d774a9c1..c59033e54d 100644
--- a/src/lib/libssl/src/crypto/asn1/tasn_enc.c
+++ b/src/lib/libssl/src/crypto/asn1/tasn_enc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_enc.c,v 1.15 2015/02/14 15:21:49 miod Exp $ */ 1/* $OpenBSD: tasn_enc.c,v 1.16 2015/02/14 15:23:57 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -131,9 +131,7 @@ ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it,
131 int tag, int aclass) 131 int tag, int aclass)
132{ 132{
133 const ASN1_TEMPLATE *tt = NULL; 133 const ASN1_TEMPLATE *tt = NULL;
134 unsigned char *p = NULL;
135 int i, seqcontlen, seqlen, ndef = 1; 134 int i, seqcontlen, seqlen, ndef = 1;
136 const ASN1_COMPAT_FUNCS *cf;
137 const ASN1_EXTERN_FUNCS *ef; 135 const ASN1_EXTERN_FUNCS *ef;
138 const ASN1_AUX *aux = it->funcs; 136 const ASN1_AUX *aux = it->funcs;
139 ASN1_aux_cb *asn1_cb = 0; 137 ASN1_aux_cb *asn1_cb = 0;
@@ -178,19 +176,6 @@ ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it,
178 ef = it->funcs; 176 ef = it->funcs;
179 return ef->asn1_ex_i2d(pval, out, it, tag, aclass); 177 return ef->asn1_ex_i2d(pval, out, it, tag, aclass);
180 178
181 case ASN1_ITYPE_COMPAT:
182 /* old style hackery... */
183 cf = it->funcs;
184 if (out)
185 p = *out;
186 i = cf->asn1_i2d(*pval, out);
187 /* Fixup for IMPLICIT tag: note this messes up for tags > 30,
188 * but so did the old code. Tags > 30 are very rare anyway.
189 */
190 if (out && (tag != -1))
191 *p = aclass | tag | (*p & V_ASN1_CONSTRUCTED);
192 return i;
193
194 case ASN1_ITYPE_NDEF_SEQUENCE: 179 case ASN1_ITYPE_NDEF_SEQUENCE:
195 /* Use indefinite length constructed if requested */ 180 /* Use indefinite length constructed if requested */
196 if (aclass & ASN1_TFLG_NDEF) 181 if (aclass & ASN1_TFLG_NDEF)
diff --git a/src/lib/libssl/src/crypto/asn1/tasn_fre.c b/src/lib/libssl/src/crypto/asn1/tasn_fre.c
index 36b668a7f9..30d68786b1 100644
--- a/src/lib/libssl/src/crypto/asn1/tasn_fre.c
+++ b/src/lib/libssl/src/crypto/asn1/tasn_fre.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_fre.c,v 1.13 2015/02/14 13:32:46 jsing Exp $ */ 1/* $OpenBSD: tasn_fre.c,v 1.14 2015/02/14 15:23:57 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -84,7 +84,6 @@ asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine)
84{ 84{
85 const ASN1_TEMPLATE *tt = NULL, *seqtt; 85 const ASN1_TEMPLATE *tt = NULL, *seqtt;
86 const ASN1_EXTERN_FUNCS *ef; 86 const ASN1_EXTERN_FUNCS *ef;
87 const ASN1_COMPAT_FUNCS *cf;
88 const ASN1_AUX *aux = it->funcs; 87 const ASN1_AUX *aux = it->funcs;
89 ASN1_aux_cb *asn1_cb = NULL; 88 ASN1_aux_cb *asn1_cb = NULL;
90 int i; 89 int i;
@@ -128,12 +127,6 @@ asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine)
128 } 127 }
129 break; 128 break;
130 129
131 case ASN1_ITYPE_COMPAT:
132 cf = it->funcs;
133 if (cf && cf->asn1_free)
134 cf->asn1_free(*pval);
135 break;
136
137 case ASN1_ITYPE_EXTERN: 130 case ASN1_ITYPE_EXTERN:
138 ef = it->funcs; 131 ef = it->funcs;
139 if (ef && ef->asn1_ex_free) 132 if (ef && ef->asn1_ex_free)
diff --git a/src/lib/libssl/src/crypto/asn1/tasn_new.c b/src/lib/libssl/src/crypto/asn1/tasn_new.c
index 86b2b3facd..132df07637 100644
--- a/src/lib/libssl/src/crypto/asn1/tasn_new.c
+++ b/src/lib/libssl/src/crypto/asn1/tasn_new.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_new.c,v 1.13 2015/02/14 15:15:27 miod Exp $ */ 1/* $OpenBSD: tasn_new.c,v 1.14 2015/02/14 15:23:57 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -91,7 +91,6 @@ static int
91asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine) 91asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine)
92{ 92{
93 const ASN1_TEMPLATE *tt = NULL; 93 const ASN1_TEMPLATE *tt = NULL;
94 const ASN1_COMPAT_FUNCS *cf;
95 const ASN1_EXTERN_FUNCS *ef; 94 const ASN1_EXTERN_FUNCS *ef;
96 const ASN1_AUX *aux = it->funcs; 95 const ASN1_AUX *aux = it->funcs;
97 ASN1_aux_cb *asn1_cb = NULL; 96 ASN1_aux_cb *asn1_cb = NULL;
@@ -118,15 +117,6 @@ asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine)
118 } 117 }
119 break; 118 break;
120 119
121 case ASN1_ITYPE_COMPAT:
122 cf = it->funcs;
123 if (cf && cf->asn1_new) {
124 *pval = cf->asn1_new();
125 if (!*pval)
126 goto memerr;
127 }
128 break;
129
130 case ASN1_ITYPE_PRIMITIVE: 120 case ASN1_ITYPE_PRIMITIVE:
131 if (it->templates) { 121 if (it->templates) {
132 if (!ASN1_template_new(pval, it->templates)) 122 if (!ASN1_template_new(pval, it->templates))
@@ -243,7 +233,6 @@ asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
243 asn1_primitive_clear(pval, it); 233 asn1_primitive_clear(pval, it);
244 break; 234 break;
245 235
246 case ASN1_ITYPE_COMPAT:
247 case ASN1_ITYPE_CHOICE: 236 case ASN1_ITYPE_CHOICE:
248 case ASN1_ITYPE_SEQUENCE: 237 case ASN1_ITYPE_SEQUENCE:
249 case ASN1_ITYPE_NDEF_SEQUENCE: 238 case ASN1_ITYPE_NDEF_SEQUENCE: