summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/asn1/a_enum.c24
-rw-r--r--src/lib/libcrypto/asn1/asn1_locl.h4
-rw-r--r--src/lib/libcrypto/asn1/tasn_dec.c14
3 files changed, 33 insertions, 9 deletions
diff --git a/src/lib/libcrypto/asn1/a_enum.c b/src/lib/libcrypto/asn1/a_enum.c
index b0b851028a..b35fe43666 100644
--- a/src/lib/libcrypto/asn1/a_enum.c
+++ b/src/lib/libcrypto/asn1/a_enum.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_enum.c,v 1.26 2022/08/10 12:06:28 tb Exp $ */ 1/* $OpenBSD: a_enum.c,v 1.27 2022/09/03 18:45:51 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -346,6 +346,28 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
346} 346}
347 347
348int 348int
349c2i_ASN1_ENUMERATED_cbs(ASN1_ENUMERATED **out_aenum, CBS *cbs)
350{
351 ASN1_ENUMERATED *aenum = NULL;
352
353 if (out_aenum == NULL)
354 return 0;
355
356 if (*out_aenum != NULL) {
357 ASN1_INTEGER_free(*out_aenum);
358 *out_aenum = NULL;
359 }
360
361 if (!c2i_ASN1_INTEGER_cbs((ASN1_INTEGER **)&aenum, cbs))
362 return 0;
363
364 aenum->type = V_ASN1_ENUMERATED | (aenum->type & V_ASN1_NEG);
365 *out_aenum = aenum;
366
367 return 1;
368}
369
370int
349i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a, unsigned char **out) 371i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a, unsigned char **out)
350{ 372{
351 return ASN1_item_i2d((ASN1_VALUE *)a, out, &ASN1_ENUMERATED_it); 373 return ASN1_item_i2d((ASN1_VALUE *)a, out, &ASN1_ENUMERATED_it);
diff --git a/src/lib/libcrypto/asn1/asn1_locl.h b/src/lib/libcrypto/asn1/asn1_locl.h
index ec853250f2..e2c57fd8c4 100644
--- a/src/lib/libcrypto/asn1/asn1_locl.h
+++ b/src/lib/libcrypto/asn1/asn1_locl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn1_locl.h,v 1.35 2022/06/29 08:56:44 beck Exp $ */ 1/* $OpenBSD: asn1_locl.h,v 1.36 2022/09/03 18:45:51 jsing 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 2006. 3 * project 2006.
4 */ 4 */
@@ -209,6 +209,8 @@ int asn1_tag2charwidth(int tag);
209int asn1_abs_set_unused_bits(ASN1_BIT_STRING *abs, uint8_t unused_bits); 209int asn1_abs_set_unused_bits(ASN1_BIT_STRING *abs, uint8_t unused_bits);
210int c2i_ASN1_BIT_STRING_cbs(ASN1_BIT_STRING **out_abs, CBS *cbs); 210int c2i_ASN1_BIT_STRING_cbs(ASN1_BIT_STRING **out_abs, CBS *cbs);
211 211
212int c2i_ASN1_ENUMERATED_cbs(ASN1_ENUMERATED **out_aenum, CBS *cbs);
213
212int asn1_aint_get_uint64(CBS *cbs, uint64_t *out_val); 214int asn1_aint_get_uint64(CBS *cbs, uint64_t *out_val);
213int asn1_aint_set_uint64(uint64_t val, uint8_t **out_data, int *out_len); 215int asn1_aint_set_uint64(uint64_t val, uint8_t **out_data, int *out_len);
214int asn1_aint_get_int64(CBS *cbs, int negative, int64_t *out_val); 216int asn1_aint_get_int64(CBS *cbs, int negative, int64_t *out_val);
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c
index 235685484c..22d8006d0a 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.78 2022/06/29 08:56:44 beck Exp $ */ 1/* $OpenBSD: tasn_dec.c,v 1.79 2022/09/03 18:45:51 jsing 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 */
@@ -277,7 +277,6 @@ static int
277asn1_c2i_primitive(ASN1_VALUE **pval, CBS *content, int utype, const ASN1_ITEM *it) 277asn1_c2i_primitive(ASN1_VALUE **pval, CBS *content, int utype, const ASN1_ITEM *it)
278{ 278{
279 ASN1_STRING *stmp; 279 ASN1_STRING *stmp;
280 ASN1_INTEGER **tint;
281 ASN1_BOOLEAN *tbool; 280 ASN1_BOOLEAN *tbool;
282 uint8_t u8val; 281 uint8_t u8val;
283 int ret = 0; 282 int ret = 0;
@@ -318,13 +317,14 @@ asn1_c2i_primitive(ASN1_VALUE **pval, CBS *content, int utype, const ASN1_ITEM *
318 goto err; 317 goto err;
319 break; 318 break;
320 319
321 case V_ASN1_INTEGER:
322 case V_ASN1_ENUMERATED: 320 case V_ASN1_ENUMERATED:
323 tint = (ASN1_INTEGER **)pval; 321 if (!c2i_ASN1_ENUMERATED_cbs((ASN1_ENUMERATED **)pval, content))
324 if (!c2i_ASN1_INTEGER_cbs(tint, content)) 322 goto err;
323 break;
324
325 case V_ASN1_INTEGER:
326 if (!c2i_ASN1_INTEGER_cbs((ASN1_INTEGER **)pval, content))
325 goto err; 327 goto err;
326 /* Fixup type to match the expected form */
327 (*tint)->type = utype | ((*tint)->type & V_ASN1_NEG);
328 break; 328 break;
329 329
330 case V_ASN1_OCTET_STRING: 330 case V_ASN1_OCTET_STRING: