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/asn1_par.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/asn1_par.c')
-rw-r--r-- | src/lib/libcrypto/asn1/asn1_par.c | 84 |
1 files changed, 51 insertions, 33 deletions
diff --git a/src/lib/libcrypto/asn1/asn1_par.c b/src/lib/libcrypto/asn1/asn1_par.c index 3906227d21..86886606ef 100644 --- a/src/lib/libcrypto/asn1/asn1_par.c +++ b/src/lib/libcrypto/asn1/asn1_par.c | |||
@@ -58,30 +58,21 @@ | |||
58 | 58 | ||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
61 | #include "buffer.h" | 61 | #include <openssl/buffer.h> |
62 | #include "objects.h" | 62 | #include <openssl/objects.h> |
63 | #include "x509.h" | 63 | #include <openssl/asn1.h> |
64 | 64 | ||
65 | #ifndef NOPROTO | ||
66 | static int asn1_print_info(BIO *bp, int tag, int xclass,int constructed, | 65 | static int asn1_print_info(BIO *bp, int tag, int xclass,int constructed, |
67 | int indent); | 66 | int indent); |
68 | static int asn1_parse2(BIO *bp, unsigned char **pp, long length, | 67 | static int asn1_parse2(BIO *bp, unsigned char **pp, long length, |
69 | int offset, int depth, int indent); | 68 | int offset, int depth, int indent); |
70 | #else | 69 | static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed, |
71 | static int asn1_print_info(); | 70 | int indent) |
72 | static int asn1_parse2(); | ||
73 | #endif | ||
74 | |||
75 | static int asn1_print_info(bp, tag, xclass, constructed,indent) | ||
76 | BIO *bp; | ||
77 | int tag; | ||
78 | int xclass; | ||
79 | int constructed; | ||
80 | int indent; | ||
81 | { | 71 | { |
82 | static char *fmt="%-18s"; | 72 | static const char fmt[]="%-18s"; |
83 | static char *fmt2="%2d %-15s"; | 73 | static const char fmt2[]="%2d %-15s"; |
84 | char *p,str[128],*p2=NULL; | 74 | char str[128]; |
75 | const char *p,*p2=NULL; | ||
85 | 76 | ||
86 | if (constructed & V_ASN1_CONSTRUCTED) | 77 | if (constructed & V_ASN1_CONSTRUCTED) |
87 | p="cons: "; | 78 | p="cons: "; |
@@ -108,6 +99,8 @@ int indent; | |||
108 | p="BOOLEAN"; | 99 | p="BOOLEAN"; |
109 | else if (tag == V_ASN1_INTEGER) | 100 | else if (tag == V_ASN1_INTEGER) |
110 | p="INTEGER"; | 101 | p="INTEGER"; |
102 | else if (tag == V_ASN1_ENUMERATED) | ||
103 | p="ENUMERATED"; | ||
111 | else if (tag == V_ASN1_BIT_STRING) | 104 | else if (tag == V_ASN1_BIT_STRING) |
112 | p="BIT STRING"; | 105 | p="BIT STRING"; |
113 | else if (tag == V_ASN1_OCTET_STRING) | 106 | else if (tag == V_ASN1_OCTET_STRING) |
@@ -138,8 +131,8 @@ int indent; | |||
138 | p="GENERALIZEDTIME"; | 131 | p="GENERALIZEDTIME"; |
139 | else if (tag == V_ASN1_GRAPHICSTRING) | 132 | else if (tag == V_ASN1_GRAPHICSTRING) |
140 | p="GRAPHICSTRING"; | 133 | p="GRAPHICSTRING"; |
141 | else if (tag == V_ASN1_ISO64STRING) | 134 | else if (tag == V_ASN1_VISIBLESTRING) |
142 | p="ISO64STRING"; | 135 | p="VISIBLESTRING"; |
143 | else if (tag == V_ASN1_GENERALSTRING) | 136 | else if (tag == V_ASN1_GENERALSTRING) |
144 | p="GENERALSTRING"; | 137 | p="GENERALSTRING"; |
145 | else if (tag == V_ASN1_UNIVERSALSTRING) | 138 | else if (tag == V_ASN1_UNIVERSALSTRING) |
@@ -162,22 +155,13 @@ err: | |||
162 | return(0); | 155 | return(0); |
163 | } | 156 | } |
164 | 157 | ||
165 | int ASN1_parse(bp, pp, len, indent) | 158 | int ASN1_parse(BIO *bp, unsigned char *pp, long len, int indent) |
166 | BIO *bp; | ||
167 | unsigned char *pp; | ||
168 | long len; | ||
169 | int indent; | ||
170 | { | 159 | { |
171 | return(asn1_parse2(bp,&pp,len,0,0,indent)); | 160 | return(asn1_parse2(bp,&pp,len,0,0,indent)); |
172 | } | 161 | } |
173 | 162 | ||
174 | static int asn1_parse2(bp, pp, length, offset, depth, indent) | 163 | static int asn1_parse2(BIO *bp, unsigned char **pp, long length, int offset, |
175 | BIO *bp; | 164 | int depth, int indent) |
176 | unsigned char **pp; | ||
177 | long length; | ||
178 | int offset; | ||
179 | int depth; | ||
180 | int indent; | ||
181 | { | 165 | { |
182 | unsigned char *p,*ep,*tot,*op,*opp; | 166 | unsigned char *p,*ep,*tot,*op,*opp; |
183 | long len; | 167 | long len; |
@@ -266,7 +250,9 @@ int indent; | |||
266 | if ( (tag == V_ASN1_PRINTABLESTRING) || | 250 | if ( (tag == V_ASN1_PRINTABLESTRING) || |
267 | (tag == V_ASN1_T61STRING) || | 251 | (tag == V_ASN1_T61STRING) || |
268 | (tag == V_ASN1_IA5STRING) || | 252 | (tag == V_ASN1_IA5STRING) || |
269 | (tag == V_ASN1_UTCTIME)) | 253 | (tag == V_ASN1_VISIBLESTRING) || |
254 | (tag == V_ASN1_UTCTIME) || | ||
255 | (tag == V_ASN1_GENERALIZEDTIME)) | ||
270 | { | 256 | { |
271 | if (BIO_write(bp,":",1) <= 0) goto end; | 257 | if (BIO_write(bp,":",1) <= 0) goto end; |
272 | if ((len > 0) && | 258 | if ((len > 0) && |
@@ -370,6 +356,38 @@ int indent; | |||
370 | } | 356 | } |
371 | ASN1_INTEGER_free(bs); | 357 | ASN1_INTEGER_free(bs); |
372 | } | 358 | } |
359 | else if (tag == V_ASN1_ENUMERATED) | ||
360 | { | ||
361 | ASN1_ENUMERATED *bs; | ||
362 | int i; | ||
363 | |||
364 | opp=op; | ||
365 | bs=d2i_ASN1_ENUMERATED(NULL,&opp,len+hl); | ||
366 | if (bs != NULL) | ||
367 | { | ||
368 | if (BIO_write(bp,":",1) <= 0) goto end; | ||
369 | if (bs->type == V_ASN1_NEG_ENUMERATED) | ||
370 | if (BIO_write(bp,"-",1) <= 0) | ||
371 | goto end; | ||
372 | for (i=0; i<bs->length; i++) | ||
373 | { | ||
374 | if (BIO_printf(bp,"%02X", | ||
375 | bs->data[i]) <= 0) | ||
376 | goto end; | ||
377 | } | ||
378 | if (bs->length == 0) | ||
379 | { | ||
380 | if (BIO_write(bp,"00",2) <= 0) | ||
381 | goto end; | ||
382 | } | ||
383 | } | ||
384 | else | ||
385 | { | ||
386 | if (BIO_write(bp,"BAD ENUMERATED",11) <= 0) | ||
387 | goto end; | ||
388 | } | ||
389 | ASN1_ENUMERATED_free(bs); | ||
390 | } | ||
373 | 391 | ||
374 | if (!nl) | 392 | if (!nl) |
375 | { | 393 | { |