diff options
author | 2019-10-24 16:36:10 +0000 | |
---|---|---|
committer | 2019-10-24 16:36:10 +0000 | |
commit | 434c8a018109e78da75dfdc17c134227f2eb6b6f (patch) | |
tree | 07e26fea866221508b58404005e3622b801a4efe /lib/libcrypto | |
parent | Provide RSA_OAEP_PARAMS along with ASN.1 encoding/decoding. (diff) | |
download | wireguard-openbsd-434c8a018109e78da75dfdc17c134227f2eb6b6f.tar.xz wireguard-openbsd-434c8a018109e78da75dfdc17c134227f2eb6b6f.zip |
Provide ASN1_TYPE_{,un}pack_sequence().
These are internal only for now.
Based on OpenSSL 1.1.1d.
ok inoguchi@
Diffstat (limited to 'lib/libcrypto')
-rw-r--r-- | lib/libcrypto/asn1/a_type.c | 33 | ||||
-rw-r--r-- | lib/libcrypto/asn1/asn1_locl.h | 5 |
2 files changed, 36 insertions, 2 deletions
diff --git a/lib/libcrypto/asn1/a_type.c b/lib/libcrypto/asn1/a_type.c index 11d38300d65..a18ffe66bae 100644 --- a/lib/libcrypto/asn1/a_type.c +++ b/lib/libcrypto/asn1/a_type.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_type.c,v 1.20 2018/04/25 11:48:21 tb Exp $ */ +/* $OpenBSD: a_type.c,v 1.21 2019/10/24 16:36:10 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -154,3 +154,34 @@ ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b) return result; } + +ASN1_TYPE * +ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t) +{ + ASN1_OCTET_STRING *oct; + ASN1_TYPE *rt; + + if ((oct = ASN1_item_pack(s, it, NULL)) == NULL) + return NULL; + + if (t != NULL && *t != NULL) { + rt = *t; + } else { + if ((rt = ASN1_TYPE_new()) == NULL) { + ASN1_OCTET_STRING_free(oct); + return NULL; + } + if (t != NULL) + *t = rt; + } + ASN1_TYPE_set(rt, V_ASN1_SEQUENCE, oct); + return rt; +} + +void * +ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t) +{ + if (t == NULL || t->type != V_ASN1_SEQUENCE || t->value.sequence == NULL) + return NULL; + return ASN1_item_unpack(t->value.sequence, it); +} diff --git a/lib/libcrypto/asn1/asn1_locl.h b/lib/libcrypto/asn1/asn1_locl.h index 5ade6c7e3fd..39779d9377b 100644 --- a/lib/libcrypto/asn1/asn1_locl.h +++ b/lib/libcrypto/asn1/asn1_locl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_locl.h,v 1.11 2018/08/24 20:22:15 tb Exp $ */ +/* $OpenBSD: asn1_locl.h,v 1.12 2019/10/24 16:36:10 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -60,6 +60,9 @@ __BEGIN_HIDDEN_DECLS /* Internal ASN1 structures and functions: not for application use */ +ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t); +void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t); + /* ASN1 print context structure */ struct asn1_pctx_st { |