diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2000-12-28 19:18:48 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2000-12-28 19:18:48 +0000 |
commit | 09ab755c555a96df23b78fb188578b2fba5faae2 (patch) | |
tree | d70caa8c199c4dc22e7c2301a554a80c8158c160 /crypto/asn1/asn_pack.c | |
parent | ec558b65480cb186979e0c3bf0cf8e36eb49a125 (diff) | |
download | openssl-09ab755c555a96df23b78fb188578b2fba5faae2.tar.gz |
ASN1_ITEM versions of sign, verify, pack and unpack.
The old function pointer versions will eventually go
away.
Diffstat (limited to 'crypto/asn1/asn_pack.c')
-rw-r--r-- | crypto/asn1/asn_pack.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/crypto/asn1/asn_pack.c b/crypto/asn1/asn_pack.c index bdf5f130b3..0b9ed691a9 100644 --- a/crypto/asn1/asn_pack.c +++ b/crypto/asn1/asn_pack.c @@ -117,7 +117,7 @@ void *ASN1_unpack_string (ASN1_STRING *oct, char *(*d2i)()) /* Pack an ASN1 object into an ASN1_STRING */ -ASN1_STRING *ASN1_pack_string (void *obj, int (*i2d)(), ASN1_STRING **oct) +ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_STRING **oct) { unsigned char *p; ASN1_STRING *octmp; @@ -143,3 +143,45 @@ ASN1_STRING *ASN1_pack_string (void *obj, int (*i2d)(), ASN1_STRING **oct) return octmp; } +/* ASN1_ITEM versions of the above */ + +ASN1_STRING *ASN1_pack_item(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct) +{ + ASN1_STRING *octmp; + + if (!oct || !*oct) { + if (!(octmp = ASN1_STRING_new ())) { + ASN1err(ASN1_F_ASN1_PACK_STRING,ERR_R_MALLOC_FAILURE); + return NULL; + } + if (oct) *oct = octmp; + } else octmp = *oct; + + if(octmp->data) { + OPENSSL_free(octmp->data); + octmp->data = NULL; + } + + if (!(octmp->length = ASN1_item_i2d(obj, &octmp->data, it))) { + ASN1err(ASN1_F_ASN1_PACK_STRING,ASN1_R_ENCODE_ERROR); + return NULL; + } + if (!octmp->data) { + ASN1err(ASN1_F_ASN1_PACK_STRING,ERR_R_MALLOC_FAILURE); + return NULL; + } + return octmp; +} + +/* Extract an ASN1 object from an ASN1_STRING */ + +void *ASN1_unpack_item(ASN1_STRING *oct, const ASN1_ITEM *it) +{ + unsigned char *p; + void *ret; + + p = oct->data; + if(!(ret = ASN1_item_d2i(NULL, &p, oct->length, it))) + ASN1err(ASN1_F_ASN1_UNPACK_STRING,ASN1_R_DECODE_ERROR); + return ret; +} |