X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fasn1%2Fa_type.c;h=864ebec0f9ca71a7388d1cce14278a2b63c5dc8f;hp=d52ed4626bba3b359063daf5070a13d9daafd11f;hb=22f5bd3dd2a660f6f50ef86de78985b995c63a85;hpb=94f4b4b31314c07a4b6c9898e14c1023a112d0d0;ds=sidebyside diff --git a/crypto/asn1/a_type.c b/crypto/asn1/a_type.c index d52ed4626b..864ebec0f9 100644 --- a/crypto/asn1/a_type.c +++ b/crypto/asn1/a_type.c @@ -152,3 +152,34 @@ int 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; + + oct = ASN1_item_pack(s, it, NULL); + if (oct == NULL) + return NULL; + + if (t && *t) { + rt = *t; + } else { + rt = ASN1_TYPE_new(); + if (rt == NULL) { + ASN1_OCTET_STRING_free(oct); + return NULL; + } + if (t) + *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->type != V_ASN1_SEQUENCE || t->value.sequence == NULL) + return NULL; + return ASN1_item_unpack(t->value.sequence, it); +}