diff options
author | beck <> | 1999-09-29 04:37:45 +0000 |
---|---|---|
committer | beck <> | 1999-09-29 04:37:45 +0000 |
commit | de8f24ea083384bb66b32ec105dc4743c5663cdf (patch) | |
tree | 1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/asn1/p7_lib.c | |
parent | cb929d29896bcb87c2a97417fbd03e50078fc178 (diff) | |
download | openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2 openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip |
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/asn1/p7_lib.c')
-rw-r--r-- | src/lib/libcrypto/asn1/p7_lib.c | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/src/lib/libcrypto/asn1/p7_lib.c b/src/lib/libcrypto/asn1/p7_lib.c index 2134e0974a..846be17158 100644 --- a/src/lib/libcrypto/asn1/p7_lib.c +++ b/src/lib/libcrypto/asn1/p7_lib.c | |||
@@ -58,17 +58,11 @@ | |||
58 | 58 | ||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
61 | #include "asn1_mac.h" | 61 | #include <openssl/asn1_mac.h> |
62 | #include "objects.h" | 62 | #include <openssl/pkcs7.h> |
63 | #include <openssl/objects.h> | ||
63 | 64 | ||
64 | /* ASN1err(ASN1_F_D2I_PKCS7,ASN1_R_BAD_PKCS7_CONTENT); | 65 | int i2d_PKCS7(PKCS7 *a, unsigned char **pp) |
65 | * ASN1err(ASN1_F_I2D_PKCS7,ASN1_R_BAD_PKCS7_TYPE); | ||
66 | * ASN1err(ASN1_F_PKCS7_NEW,ASN1_R_BAD_PKCS7_TYPE); | ||
67 | */ | ||
68 | |||
69 | int i2d_PKCS7(a,pp) | ||
70 | PKCS7 *a; | ||
71 | unsigned char **pp; | ||
72 | { | 66 | { |
73 | M_ASN1_I2D_vars(a); | 67 | M_ASN1_I2D_vars(a); |
74 | 68 | ||
@@ -150,10 +144,7 @@ unsigned char **pp; | |||
150 | M_ASN1_I2D_finish(); | 144 | M_ASN1_I2D_finish(); |
151 | } | 145 | } |
152 | 146 | ||
153 | PKCS7 *d2i_PKCS7(a,pp,length) | 147 | PKCS7 *d2i_PKCS7(PKCS7 **a, unsigned char **pp, long length) |
154 | PKCS7 **a; | ||
155 | unsigned char **pp; | ||
156 | long length; | ||
157 | { | 148 | { |
158 | M_ASN1_D2I_vars(a,PKCS7 *,PKCS7_new); | 149 | M_ASN1_D2I_vars(a,PKCS7 *,PKCS7_new); |
159 | 150 | ||
@@ -179,6 +170,7 @@ long length; | |||
179 | V_ASN1_CONTEXT_SPECIFIC|0)) | 170 | V_ASN1_CONTEXT_SPECIFIC|0)) |
180 | { | 171 | { |
181 | c.error=ASN1_R_BAD_PKCS7_CONTENT; | 172 | c.error=ASN1_R_BAD_PKCS7_CONTENT; |
173 | c.line=__LINE__; | ||
182 | goto err; | 174 | goto err; |
183 | } | 175 | } |
184 | 176 | ||
@@ -187,7 +179,7 @@ long length; | |||
187 | c.q=c.p; | 179 | c.q=c.p; |
188 | Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass, | 180 | Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass, |
189 | (c.inf & 1)?(length+ *pp-c.q):c.slen); | 181 | (c.inf & 1)?(length+ *pp-c.q):c.slen); |
190 | if (Tinf & 0x80) goto err; | 182 | if (Tinf & 0x80) { c.line=__LINE__; goto err; } |
191 | c.slen-=(c.p-c.q); | 183 | c.slen-=(c.p-c.q); |
192 | 184 | ||
193 | switch (OBJ_obj2nid(ret->type)) | 185 | switch (OBJ_obj2nid(ret->type)) |
@@ -215,14 +207,16 @@ long length; | |||
215 | break; | 207 | break; |
216 | default: | 208 | default: |
217 | c.error=ASN1_R_BAD_PKCS7_TYPE; | 209 | c.error=ASN1_R_BAD_PKCS7_TYPE; |
210 | c.line=__LINE__; | ||
218 | goto err; | 211 | goto err; |
219 | break; | 212 | /* break; */ |
220 | } | 213 | } |
221 | if (Tinf == (1|V_ASN1_CONSTRUCTED)) | 214 | if (Tinf == (1|V_ASN1_CONSTRUCTED)) |
222 | { | 215 | { |
223 | if (!ASN1_check_infinite_end(&c.p,c.slen)) | 216 | if (!ASN1_check_infinite_end(&c.p,c.slen)) |
224 | { | 217 | { |
225 | c.error=ASN1_R_MISSING_EOS; | 218 | c.error=ERR_R_MISSING_ASN1_EOS; |
219 | c.line=__LINE__; | ||
226 | goto err; | 220 | goto err; |
227 | } | 221 | } |
228 | } | 222 | } |
@@ -233,12 +227,13 @@ long length; | |||
233 | M_ASN1_D2I_Finish(a,PKCS7_free,ASN1_F_D2I_PKCS7); | 227 | M_ASN1_D2I_Finish(a,PKCS7_free,ASN1_F_D2I_PKCS7); |
234 | } | 228 | } |
235 | 229 | ||
236 | PKCS7 *PKCS7_new() | 230 | PKCS7 *PKCS7_new(void) |
237 | { | 231 | { |
238 | PKCS7 *ret=NULL; | 232 | PKCS7 *ret=NULL; |
233 | ASN1_CTX c; | ||
239 | 234 | ||
240 | M_ASN1_New_Malloc(ret,PKCS7); | 235 | M_ASN1_New_Malloc(ret,PKCS7); |
241 | ret->type=ASN1_OBJECT_new(); | 236 | ret->type=OBJ_nid2obj(NID_undef); |
242 | ret->asn1=NULL; | 237 | ret->asn1=NULL; |
243 | ret->length=0; | 238 | ret->length=0; |
244 | ret->detached=0; | 239 | ret->detached=0; |
@@ -247,8 +242,7 @@ PKCS7 *PKCS7_new() | |||
247 | M_ASN1_New_Error(ASN1_F_PKCS7_NEW); | 242 | M_ASN1_New_Error(ASN1_F_PKCS7_NEW); |
248 | } | 243 | } |
249 | 244 | ||
250 | void PKCS7_free(a) | 245 | void PKCS7_free(PKCS7 *a) |
251 | PKCS7 *a; | ||
252 | { | 246 | { |
253 | if (a == NULL) return; | 247 | if (a == NULL) return; |
254 | 248 | ||
@@ -260,9 +254,11 @@ PKCS7 *a; | |||
260 | Free((char *)(char *)a); | 254 | Free((char *)(char *)a); |
261 | } | 255 | } |
262 | 256 | ||
263 | void PKCS7_content_free(a) | 257 | void PKCS7_content_free(PKCS7 *a) |
264 | PKCS7 *a; | ||
265 | { | 258 | { |
259 | if(a == NULL) | ||
260 | return; | ||
261 | |||
266 | if (a->asn1 != NULL) Free((char *)a->asn1); | 262 | if (a->asn1 != NULL) Free((char *)a->asn1); |
267 | 263 | ||
268 | if (a->d.ptr != NULL) | 264 | if (a->d.ptr != NULL) |