OLD | NEW |
1 /* asn_pack.c */ | 1 /* asn_pack.c */ |
2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 * project 1999. | 3 * project 1999. |
4 */ | 4 */ |
5 /* ==================================================================== | 5 /* ==================================================================== |
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 #include <stdio.h> | 59 #include <stdio.h> |
60 #include "cryptlib.h" | 60 #include "cryptlib.h" |
61 #include <openssl/asn1.h> | 61 #include <openssl/asn1.h> |
62 | 62 |
63 #ifndef NO_ASN1_OLD | 63 #ifndef NO_ASN1_OLD |
64 | 64 |
65 /* ASN1 packing and unpacking functions */ | 65 /* ASN1 packing and unpacking functions */ |
66 | 66 |
67 /* Turn an ASN1 encoded SEQUENCE OF into a STACK of structures */ | 67 /* Turn an ASN1 encoded SEQUENCE OF into a STACK of structures */ |
68 | 68 |
69 STACK *ASN1_seq_unpack(const unsigned char *buf, int len, | 69 STACK_OF(OPENSSL_BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len, |
70 » » d2i_of_void *d2i,void (*free_func)(void *)) | 70 » » » d2i_of_void *d2i, void (*free_func)(OPENSSL_BLOCK)) |
71 { | 71 { |
72 STACK *sk; | 72 STACK_OF(OPENSSL_BLOCK) *sk; |
73 const unsigned char *pbuf; | 73 const unsigned char *pbuf; |
74 pbuf = buf; | 74 pbuf = buf; |
75 if (!(sk = d2i_ASN1_SET(NULL, &pbuf, len, d2i, free_func, | 75 if (!(sk = d2i_ASN1_SET(NULL, &pbuf, len, d2i, free_func, |
76 V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL))) | 76 V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL))) |
77 ASN1err(ASN1_F_ASN1_SEQ_UNPACK,ASN1_R_DECODE_ERROR); | 77 ASN1err(ASN1_F_ASN1_SEQ_UNPACK,ASN1_R_DECODE_ERROR); |
78 return sk; | 78 return sk; |
79 } | 79 } |
80 | 80 |
81 /* Turn a STACK structures into an ASN1 encoded SEQUENCE OF structure in a | 81 /* Turn a STACK structures into an ASN1 encoded SEQUENCE OF structure in a |
82 * OPENSSL_malloc'ed buffer | 82 * OPENSSL_malloc'ed buffer |
83 */ | 83 */ |
84 | 84 |
85 unsigned char *ASN1_seq_pack(STACK *safes, i2d_of_void *i2d, | 85 unsigned char *ASN1_seq_pack(STACK_OF(OPENSSL_BLOCK) *safes, i2d_of_void *i2d, |
86 unsigned char **buf, int *len) | 86 unsigned char **buf, int *len) |
87 { | 87 { |
88 int safelen; | 88 int safelen; |
89 unsigned char *safe, *p; | 89 unsigned char *safe, *p; |
90 if (!(safelen = i2d_ASN1_SET(safes, NULL, i2d, V_ASN1_SEQUENCE, | 90 if (!(safelen = i2d_ASN1_SET(safes, NULL, i2d, V_ASN1_SEQUENCE, |
91 V_ASN1_UNIVERSAL, IS_SEQUENCE))) { | 91 V_ASN1_UNIVERSAL, IS_SEQUENCE))) { |
92 ASN1err(ASN1_F_ASN1_SEQ_PACK,ASN1_R_ENCODE_ERROR); | 92 ASN1err(ASN1_F_ASN1_SEQ_PACK,ASN1_R_ENCODE_ERROR); |
93 return NULL; | 93 return NULL; |
94 } | 94 } |
95 if (!(safe = OPENSSL_malloc (safelen))) { | 95 if (!(safe = OPENSSL_malloc (safelen))) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it) | 182 void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it) |
183 { | 183 { |
184 const unsigned char *p; | 184 const unsigned char *p; |
185 void *ret; | 185 void *ret; |
186 | 186 |
187 p = oct->data; | 187 p = oct->data; |
188 if(!(ret = ASN1_item_d2i(NULL, &p, oct->length, it))) | 188 if(!(ret = ASN1_item_d2i(NULL, &p, oct->length, it))) |
189 ASN1err(ASN1_F_ASN1_ITEM_UNPACK,ASN1_R_DECODE_ERROR); | 189 ASN1err(ASN1_F_ASN1_ITEM_UNPACK,ASN1_R_DECODE_ERROR); |
190 return ret; | 190 return ret; |
191 } | 191 } |
OLD | NEW |