X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fasn1%2Fa_type.c;h=474aecadc6bd5bc32719a7b92407620c606d6315;hb=e8dfb5bf8e525c9799820d01b2df5fde098a9c4c;hp=e7ec49d39ae120cfa90c60b1e0bfc4885449a2af;hpb=e677e8d13595f7b3287f8feef7676feb301b0e8a;p=oweals%2Fopenssl.git diff --git a/crypto/asn1/a_type.c b/crypto/asn1/a_type.c index e7ec49d39a..474aecadc6 100644 --- a/crypto/asn1/a_type.c +++ b/crypto/asn1/a_type.c @@ -57,9 +57,10 @@ */ #include -#include "cryptlib.h" +#include "internal/cryptlib.h" #include #include +#include "asn1_locl.h" int ASN1_TYPE_get(ASN1_TYPE *a) { @@ -73,7 +74,7 @@ void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value) { if (a->value.ptr != NULL) { ASN1_TYPE **tmp_a = &a; - ASN1_primitive_free((ASN1_VALUE **)tmp_a, NULL); + asn1_primitive_free((ASN1_VALUE **)tmp_a, NULL); } a->type = type; if (type == V_ASN1_BOOLEAN) @@ -151,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 == NULL || t->type != V_ASN1_SEQUENCE || t->value.sequence == NULL) + return NULL; + return ASN1_item_unpack(t->value.sequence, it); +}