diff options
author | jsing <> | 2021-12-25 08:52:44 +0000 |
---|---|---|
committer | jsing <> | 2021-12-25 08:52:44 +0000 |
commit | a1aa360082915390f4dce8cb202c7a908f0801d7 (patch) | |
tree | deb13cf3156e23b9aed2e7ab7fcc949a90f0b8a0 /src/lib/libcrypto/asn1/a_enum.c | |
parent | 9bcf656c985ee0377aa1efaa225459e511cda945 (diff) | |
download | openbsd-a1aa360082915390f4dce8cb202c7a908f0801d7.tar.gz openbsd-a1aa360082915390f4dce8cb202c7a908f0801d7.tar.bz2 openbsd-a1aa360082915390f4dce8cb202c7a908f0801d7.zip |
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@
Diffstat (limited to 'src/lib/libcrypto/asn1/a_enum.c')
-rw-r--r-- | src/lib/libcrypto/asn1/a_enum.c | 34 |
1 files changed, 33 insertions, 1 deletions
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 @@ | |||
1 | /* $OpenBSD: a_enum.c,v 1.21 2021/12/15 18:00:31 jsing Exp $ */ | 1 | /* $OpenBSD: a_enum.c,v 1.22 2021/12/25 08:52:44 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 | * |
@@ -60,6 +60,7 @@ | |||
60 | #include <stdio.h> | 60 | #include <stdio.h> |
61 | 61 | ||
62 | #include <openssl/asn1.h> | 62 | #include <openssl/asn1.h> |
63 | #include <openssl/asn1t.h> | ||
63 | #include <openssl/bn.h> | 64 | #include <openssl/bn.h> |
64 | #include <openssl/buffer.h> | 65 | #include <openssl/buffer.h> |
65 | #include <openssl/err.h> | 66 | #include <openssl/err.h> |
@@ -69,6 +70,24 @@ | |||
69 | * for comments on encoding see a_int.c | 70 | * for comments on encoding see a_int.c |
70 | */ | 71 | */ |
71 | 72 | ||
73 | const ASN1_ITEM ASN1_ENUMERATED_it = { | ||
74 | .itype = ASN1_ITYPE_PRIMITIVE, | ||
75 | .utype = V_ASN1_ENUMERATED, | ||
76 | .sname = "ASN1_ENUMERATED", | ||
77 | }; | ||
78 | |||
79 | ASN1_ENUMERATED * | ||
80 | ASN1_ENUMERATED_new(void) | ||
81 | { | ||
82 | return (ASN1_ENUMERATED *)ASN1_item_new(&ASN1_ENUMERATED_it); | ||
83 | } | ||
84 | |||
85 | void | ||
86 | ASN1_ENUMERATED_free(ASN1_ENUMERATED *a) | ||
87 | { | ||
88 | ASN1_item_free((ASN1_VALUE *)a, &ASN1_ENUMERATED_it); | ||
89 | } | ||
90 | |||
72 | int | 91 | int |
73 | ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v) | 92 | ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v) |
74 | { | 93 | { |
@@ -320,3 +339,16 @@ err: | |||
320 | free(s); | 339 | free(s); |
321 | return (ret); | 340 | return (ret); |
322 | } | 341 | } |
342 | |||
343 | int | ||
344 | i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *a, unsigned char **out) | ||
345 | { | ||
346 | return ASN1_item_i2d((ASN1_VALUE *)a, out, &ASN1_ENUMERATED_it); | ||
347 | } | ||
348 | |||
349 | ASN1_ENUMERATED * | ||
350 | d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a, const unsigned char **in, long len) | ||
351 | { | ||
352 | return (ASN1_ENUMERATED *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, | ||
353 | &ASN1_ENUMERATED_it); | ||
354 | } | ||