From a1aa360082915390f4dce8cb202c7a908f0801d7 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Sat, 25 Dec 2021 08:52:44 +0000 Subject: Consolidate code/templates for ASN.1 types. Where an ASN.1 type has its own file, move the ASN.1 item template and template related functions into the file. Discussed with tb@ --- src/lib/libcrypto/asn1/a_enum.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/lib/libcrypto/asn1/a_enum.c') diff --git a/src/lib/libcrypto/asn1/a_enum.c b/src/lib/libcrypto/asn1/a_enum.c index e0e64f0a81..f48543ef3f 100644 --- a/src/lib/libcrypto/asn1/a_enum.c +++ b/src/lib/libcrypto/asn1/a_enum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_enum.c,v 1.21 2021/12/15 18:00:31 jsing Exp $ */ +/* $OpenBSD: a_enum.c,v 1.22 2021/12/25 08:52:44 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -60,6 +60,7 @@ #include #include +#include #include #include #include @@ -69,6 +70,24 @@ * for comments on encoding see a_int.c */ +const ASN1_ITEM ASN1_ENUMERATED_it = { + .itype = ASN1_ITYPE_PRIMITIVE, + .utype = V_ASN1_ENUMERATED, + .sname = "ASN1_ENUMERATED", +}; + +ASN1_ENUMERATED * +ASN1_ENUMERATED_new(void) +{ + return (ASN1_ENUMERATED *)ASN1_item_new(&ASN1_ENUMERATED_it); +} + +void +ASN1_ENUMERATED_free(ASN1_ENUMERATED *a) +{ + ASN1_item_free((ASN1_VALUE *)a, &ASN1_ENUMERATED_it); +} + int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v) { @@ -320,3 +339,16 @@ err: free(s); return (ret); } + +int +i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)a, out, &ASN1_ENUMERATED_it); +} + +ASN1_ENUMERATED * +d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, const unsigned char **in, long len) +{ + return (ASN1_ENUMERATED *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, + &ASN1_ENUMERATED_it); +} -- cgit v1.2.3-55-g6feb