diff options
author | jsing <> | 2022-09-03 18:45:51 +0000 |
---|---|---|
committer | jsing <> | 2022-09-03 18:45:51 +0000 |
commit | 5bb948dd8541248e1d3ad5dc62cd87323e2df812 (patch) | |
tree | 6b5b1c2abda78a05e0b9d022e64e28467a06c779 /src/lib/libcrypto/asn1/a_enum.c | |
parent | 08cad1d5d4e840186d932d4ee28fa6e1463e3f28 (diff) | |
download | openbsd-5bb948dd8541248e1d3ad5dc62cd87323e2df812.tar.gz openbsd-5bb948dd8541248e1d3ad5dc62cd87323e2df812.tar.bz2 openbsd-5bb948dd8541248e1d3ad5dc62cd87323e2df812.zip |
Provide c2i_ASN1_ENUMERATED_cbs() and call it from asn1_c2i_primitive().
This avoids asn1_c2i_primitive() from needing knowledge about the internals
of ASN1_INTEGER and ASN1_ENUMERATED.
ok tb@
Diffstat (limited to 'src/lib/libcrypto/asn1/a_enum.c')
-rw-r--r-- | src/lib/libcrypto/asn1/a_enum.c | 24 |
1 files changed, 23 insertions, 1 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 | ||
348 | int | 348 | int |
349 | c2i_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 | |||
370 | int | ||
349 | i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a, unsigned char **out) | 371 | i2d_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); |