diff options
author | jsing <> | 2019-10-24 16:36:10 +0000 |
---|---|---|
committer | jsing <> | 2019-10-24 16:36:10 +0000 |
commit | f860ff473beb386fc88047a00a6e27437ba4ab75 (patch) | |
tree | 00cb228ed14c5d7d0d214c2323c65a899391f933 | |
parent | e76162e1394c75ce7b2d71cffbe5483c0725825d (diff) | |
download | openbsd-f860ff473beb386fc88047a00a6e27437ba4ab75.tar.gz openbsd-f860ff473beb386fc88047a00a6e27437ba4ab75.tar.bz2 openbsd-f860ff473beb386fc88047a00a6e27437ba4ab75.zip |
Provide ASN1_TYPE_{,un}pack_sequence().
These are internal only for now.
Based on OpenSSL 1.1.1d.
ok inoguchi@
-rw-r--r-- | src/lib/libcrypto/asn1/a_type.c | 33 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/asn1_locl.h | 5 |
2 files changed, 36 insertions, 2 deletions
diff --git a/src/lib/libcrypto/asn1/a_type.c b/src/lib/libcrypto/asn1/a_type.c index 11d38300d6..a18ffe66ba 100644 --- a/src/lib/libcrypto/asn1/a_type.c +++ b/src/lib/libcrypto/asn1/a_type.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: a_type.c,v 1.20 2018/04/25 11:48:21 tb Exp $ */ | 1 | /* $OpenBSD: a_type.c,v 1.21 2019/10/24 16:36:10 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 | * |
@@ -154,3 +154,34 @@ ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b) | |||
154 | 154 | ||
155 | return result; | 155 | return result; |
156 | } | 156 | } |
157 | |||
158 | ASN1_TYPE * | ||
159 | ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t) | ||
160 | { | ||
161 | ASN1_OCTET_STRING *oct; | ||
162 | ASN1_TYPE *rt; | ||
163 | |||
164 | if ((oct = ASN1_item_pack(s, it, NULL)) == NULL) | ||
165 | return NULL; | ||
166 | |||
167 | if (t != NULL && *t != NULL) { | ||
168 | rt = *t; | ||
169 | } else { | ||
170 | if ((rt = ASN1_TYPE_new()) == NULL) { | ||
171 | ASN1_OCTET_STRING_free(oct); | ||
172 | return NULL; | ||
173 | } | ||
174 | if (t != NULL) | ||
175 | *t = rt; | ||
176 | } | ||
177 | ASN1_TYPE_set(rt, V_ASN1_SEQUENCE, oct); | ||
178 | return rt; | ||
179 | } | ||
180 | |||
181 | void * | ||
182 | ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t) | ||
183 | { | ||
184 | if (t == NULL || t->type != V_ASN1_SEQUENCE || t->value.sequence == NULL) | ||
185 | return NULL; | ||
186 | return ASN1_item_unpack(t->value.sequence, it); | ||
187 | } | ||
diff --git a/src/lib/libcrypto/asn1/asn1_locl.h b/src/lib/libcrypto/asn1/asn1_locl.h index 5ade6c7e3f..39779d9377 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.11 2018/08/24 20:22:15 tb Exp $ */ | 1 | /* $OpenBSD: asn1_locl.h,v 1.12 2019/10/24 16:36:10 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 | */ |
@@ -60,6 +60,9 @@ __BEGIN_HIDDEN_DECLS | |||
60 | 60 | ||
61 | /* Internal ASN1 structures and functions: not for application use */ | 61 | /* Internal ASN1 structures and functions: not for application use */ |
62 | 62 | ||
63 | ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t); | ||
64 | void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t); | ||
65 | |||
63 | /* ASN1 print context structure */ | 66 | /* ASN1 print context structure */ |
64 | 67 | ||
65 | struct asn1_pctx_st { | 68 | struct asn1_pctx_st { |