diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/asn_pack.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/asn_pack.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/lib/libcrypto/asn1/asn_pack.c b/src/lib/libcrypto/asn1/asn_pack.c index 13dc5d4665..9752a68206 100644 --- a/src/lib/libcrypto/asn1/asn_pack.c +++ b/src/lib/libcrypto/asn1/asn_pack.c | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | * are met: | 10 | * are met: |
| 11 | * | 11 | * |
| 12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * | 14 | * |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
| @@ -62,29 +62,32 @@ | |||
| 62 | 62 | ||
| 63 | /* ASN1_ITEM versions of the above */ | 63 | /* ASN1_ITEM versions of the above */ |
| 64 | 64 | ||
| 65 | ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct) | 65 | ASN1_STRING * |
| 66 | ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct) | ||
| 66 | { | 67 | { |
| 67 | ASN1_STRING *octmp; | 68 | ASN1_STRING *octmp; |
| 68 | 69 | ||
| 69 | if (!oct || !*oct) { | 70 | if (!oct || !*oct) { |
| 70 | if (!(octmp = ASN1_STRING_new ())) { | 71 | if (!(octmp = ASN1_STRING_new ())) { |
| 71 | ASN1err(ASN1_F_ASN1_ITEM_PACK,ERR_R_MALLOC_FAILURE); | 72 | ASN1err(ASN1_F_ASN1_ITEM_PACK, ERR_R_MALLOC_FAILURE); |
| 72 | return NULL; | 73 | return NULL; |
| 73 | } | 74 | } |
| 74 | if (oct) *oct = octmp; | 75 | if (oct) |
| 75 | } else octmp = *oct; | 76 | *oct = octmp; |
| 77 | } else | ||
| 78 | octmp = *oct; | ||
| 76 | 79 | ||
| 77 | if(octmp->data) { | 80 | if (octmp->data) { |
| 78 | free(octmp->data); | 81 | free(octmp->data); |
| 79 | octmp->data = NULL; | 82 | octmp->data = NULL; |
| 80 | } | 83 | } |
| 81 | 84 | ||
| 82 | if (!(octmp->length = ASN1_item_i2d(obj, &octmp->data, it))) { | 85 | if (!(octmp->length = ASN1_item_i2d(obj, &octmp->data, it))) { |
| 83 | ASN1err(ASN1_F_ASN1_ITEM_PACK,ASN1_R_ENCODE_ERROR); | 86 | ASN1err(ASN1_F_ASN1_ITEM_PACK, ASN1_R_ENCODE_ERROR); |
| 84 | return NULL; | 87 | return NULL; |
| 85 | } | 88 | } |
| 86 | if (!octmp->data) { | 89 | if (!octmp->data) { |
| 87 | ASN1err(ASN1_F_ASN1_ITEM_PACK,ERR_R_MALLOC_FAILURE); | 90 | ASN1err(ASN1_F_ASN1_ITEM_PACK, ERR_R_MALLOC_FAILURE); |
| 88 | return NULL; | 91 | return NULL; |
| 89 | } | 92 | } |
| 90 | return octmp; | 93 | return octmp; |
| @@ -92,13 +95,14 @@ ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct) | |||
| 92 | 95 | ||
| 93 | /* Extract an ASN1 object from an ASN1_STRING */ | 96 | /* Extract an ASN1 object from an ASN1_STRING */ |
| 94 | 97 | ||
| 95 | void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it) | 98 | void * |
| 99 | ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it) | ||
| 96 | { | 100 | { |
| 97 | const unsigned char *p; | 101 | const unsigned char *p; |
| 98 | void *ret; | 102 | void *ret; |
| 99 | 103 | ||
| 100 | p = oct->data; | 104 | p = oct->data; |
| 101 | if(!(ret = ASN1_item_d2i(NULL, &p, oct->length, it))) | 105 | if (!(ret = ASN1_item_d2i(NULL, &p, oct->length, it))) |
| 102 | ASN1err(ASN1_F_ASN1_ITEM_UNPACK,ASN1_R_DECODE_ERROR); | 106 | ASN1err(ASN1_F_ASN1_ITEM_UNPACK, ASN1_R_DECODE_ERROR); |
| 103 | return ret; | 107 | return ret; |
| 104 | } | 108 | } |
