diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/t_x509.c')
-rw-r--r-- | src/lib/libcrypto/asn1/t_x509.c | 146 |
1 files changed, 73 insertions, 73 deletions
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c index 8dfda07b92..30d49cc4dd 100644 --- a/src/lib/libcrypto/asn1/t_x509.c +++ b/src/lib/libcrypto/asn1/t_x509.c | |||
@@ -76,9 +76,9 @@ | |||
76 | 76 | ||
77 | #ifndef OPENSSL_NO_FP_API | 77 | #ifndef OPENSSL_NO_FP_API |
78 | int X509_print_fp(FILE *fp, X509 *x) | 78 | int X509_print_fp(FILE *fp, X509 *x) |
79 | { | 79 | { |
80 | return X509_print_ex_fp(fp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); | 80 | return X509_print_ex_fp(fp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT); |
81 | } | 81 | } |
82 | 82 | ||
83 | int X509_print_ex_fp(FILE *fp, X509 *x, unsigned long nmflag, unsigned long cflag) | 83 | int X509_print_ex_fp(FILE *fp, X509 *x, unsigned long nmflag, unsigned long cflag) |
84 | { | 84 | { |
@@ -86,10 +86,10 @@ int X509_print_ex_fp(FILE *fp, X509 *x, unsigned long nmflag, unsigned long cfla | |||
86 | int ret; | 86 | int ret; |
87 | 87 | ||
88 | if ((b=BIO_new(BIO_s_file())) == NULL) | 88 | if ((b=BIO_new(BIO_s_file())) == NULL) |
89 | { | 89 | { |
90 | X509err(X509_F_X509_PRINT_EX_FP,ERR_R_BUF_LIB); | 90 | X509err(X509_F_X509_PRINT_EX_FP,ERR_R_BUF_LIB); |
91 | return(0); | 91 | return(0); |
92 | } | 92 | } |
93 | BIO_set_fp(b,fp,BIO_NOCLOSE); | 93 | BIO_set_fp(b,fp,BIO_NOCLOSE); |
94 | ret=X509_print_ex(b, x, nmflag, cflag); | 94 | ret=X509_print_ex(b, x, nmflag, cflag); |
95 | BIO_free(b); | 95 | BIO_free(b); |
@@ -103,7 +103,7 @@ int X509_print(BIO *bp, X509 *x) | |||
103 | } | 103 | } |
104 | 104 | ||
105 | int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) | 105 | int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) |
106 | { | 106 | { |
107 | long l; | 107 | long l; |
108 | int ret=0,i; | 108 | int ret=0,i; |
109 | char *m=NULL,mlch = ' '; | 109 | char *m=NULL,mlch = ' '; |
@@ -123,51 +123,51 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) | |||
123 | 123 | ||
124 | ci=x->cert_info; | 124 | ci=x->cert_info; |
125 | if(!(cflag & X509_FLAG_NO_HEADER)) | 125 | if(!(cflag & X509_FLAG_NO_HEADER)) |
126 | { | 126 | { |
127 | if (BIO_write(bp,"Certificate:\n",13) <= 0) goto err; | 127 | if (BIO_write(bp,"Certificate:\n",13) <= 0) goto err; |
128 | if (BIO_write(bp," Data:\n",10) <= 0) goto err; | 128 | if (BIO_write(bp," Data:\n",10) <= 0) goto err; |
129 | } | 129 | } |
130 | if(!(cflag & X509_FLAG_NO_VERSION)) | 130 | if(!(cflag & X509_FLAG_NO_VERSION)) |
131 | { | 131 | { |
132 | l=X509_get_version(x); | 132 | l=X509_get_version(x); |
133 | if (BIO_printf(bp,"%8sVersion: %lu (0x%lx)\n","",l+1,l) <= 0) goto err; | 133 | if (BIO_printf(bp,"%8sVersion: %lu (0x%lx)\n","",l+1,l) <= 0) goto err; |
134 | } | 134 | } |
135 | if(!(cflag & X509_FLAG_NO_SERIAL)) | 135 | if(!(cflag & X509_FLAG_NO_SERIAL)) |
136 | { | 136 | { |
137 | 137 | ||
138 | if (BIO_write(bp," Serial Number:",22) <= 0) goto err; | 138 | if (BIO_write(bp," Serial Number:",22) <= 0) goto err; |
139 | 139 | ||
140 | bs=X509_get_serialNumber(x); | 140 | bs=X509_get_serialNumber(x); |
141 | if (bs->length <= (int)sizeof(long)) | 141 | if (bs->length <= (int)sizeof(long)) |
142 | { | 142 | { |
143 | l=ASN1_INTEGER_get(bs); | 143 | l=ASN1_INTEGER_get(bs); |
144 | if (bs->type == V_ASN1_NEG_INTEGER) | 144 | if (bs->type == V_ASN1_NEG_INTEGER) |
145 | { | 145 | { |
146 | l= -l; | 146 | l= -l; |
147 | neg="-"; | 147 | neg="-"; |
148 | } | 148 | } |
149 | else | 149 | else |
150 | neg=""; | 150 | neg=""; |
151 | if (BIO_printf(bp," %s%lu (%s0x%lx)\n",neg,l,neg,l) <= 0) | 151 | if (BIO_printf(bp," %s%lu (%s0x%lx)\n",neg,l,neg,l) <= 0) |
152 | goto err; | 152 | goto err; |
153 | } | 153 | } |
154 | else | 154 | else |
155 | { | 155 | { |
156 | neg=(bs->type == V_ASN1_NEG_INTEGER)?" (Negative)":""; | 156 | neg=(bs->type == V_ASN1_NEG_INTEGER)?" (Negative)":""; |
157 | if (BIO_printf(bp,"\n%12s%s","",neg) <= 0) goto err; | 157 | if (BIO_printf(bp,"\n%12s%s","",neg) <= 0) goto err; |
158 | 158 | ||
159 | for (i=0; i<bs->length; i++) | 159 | for (i=0; i<bs->length; i++) |
160 | { | 160 | { |
161 | if (BIO_printf(bp,"%02x%c",bs->data[i], | 161 | if (BIO_printf(bp,"%02x%c",bs->data[i], |
162 | ((i+1 == bs->length)?'\n':':')) <= 0) | 162 | ((i+1 == bs->length)?'\n':':')) <= 0) |
163 | goto err; | 163 | goto err; |
164 | } | ||
165 | } | 164 | } |
166 | |||
167 | } | 165 | } |
168 | 166 | ||
167 | } | ||
168 | |||
169 | if(!(cflag & X509_FLAG_NO_SIGNAME)) | 169 | if(!(cflag & X509_FLAG_NO_SIGNAME)) |
170 | { | 170 | { |
171 | if(X509_signature_print(bp, x->sig_alg, NULL) <= 0) | 171 | if(X509_signature_print(bp, x->sig_alg, NULL) <= 0) |
172 | goto err; | 172 | goto err; |
173 | #if 0 | 173 | #if 0 |
@@ -178,31 +178,31 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) | |||
178 | if (BIO_puts(bp, "\n") <= 0) | 178 | if (BIO_puts(bp, "\n") <= 0) |
179 | goto err; | 179 | goto err; |
180 | #endif | 180 | #endif |
181 | } | 181 | } |
182 | 182 | ||
183 | if(!(cflag & X509_FLAG_NO_ISSUER)) | 183 | if(!(cflag & X509_FLAG_NO_ISSUER)) |
184 | { | 184 | { |
185 | if (BIO_printf(bp," Issuer:%c",mlch) <= 0) goto err; | 185 | if (BIO_printf(bp," Issuer:%c",mlch) <= 0) goto err; |
186 | if (X509_NAME_print_ex(bp,X509_get_issuer_name(x),nmindent, nmflags) < 0) goto err; | 186 | if (X509_NAME_print_ex(bp,X509_get_issuer_name(x),nmindent, nmflags) < 0) goto err; |
187 | if (BIO_write(bp,"\n",1) <= 0) goto err; | 187 | if (BIO_write(bp,"\n",1) <= 0) goto err; |
188 | } | 188 | } |
189 | if(!(cflag & X509_FLAG_NO_VALIDITY)) | 189 | if(!(cflag & X509_FLAG_NO_VALIDITY)) |
190 | { | 190 | { |
191 | if (BIO_write(bp," Validity\n",17) <= 0) goto err; | 191 | if (BIO_write(bp," Validity\n",17) <= 0) goto err; |
192 | if (BIO_write(bp," Not Before: ",24) <= 0) goto err; | 192 | if (BIO_write(bp," Not Before: ",24) <= 0) goto err; |
193 | if (!ASN1_TIME_print(bp,X509_get_notBefore(x))) goto err; | 193 | if (!ASN1_TIME_print(bp,X509_get_notBefore(x))) goto err; |
194 | if (BIO_write(bp,"\n Not After : ",25) <= 0) goto err; | 194 | if (BIO_write(bp,"\n Not After : ",25) <= 0) goto err; |
195 | if (!ASN1_TIME_print(bp,X509_get_notAfter(x))) goto err; | 195 | if (!ASN1_TIME_print(bp,X509_get_notAfter(x))) goto err; |
196 | if (BIO_write(bp,"\n",1) <= 0) goto err; | 196 | if (BIO_write(bp,"\n",1) <= 0) goto err; |
197 | } | 197 | } |
198 | if(!(cflag & X509_FLAG_NO_SUBJECT)) | 198 | if(!(cflag & X509_FLAG_NO_SUBJECT)) |
199 | { | 199 | { |
200 | if (BIO_printf(bp," Subject:%c",mlch) <= 0) goto err; | 200 | if (BIO_printf(bp," Subject:%c",mlch) <= 0) goto err; |
201 | if (X509_NAME_print_ex(bp,X509_get_subject_name(x),nmindent, nmflags) < 0) goto err; | 201 | if (X509_NAME_print_ex(bp,X509_get_subject_name(x),nmindent, nmflags) < 0) goto err; |
202 | if (BIO_write(bp,"\n",1) <= 0) goto err; | 202 | if (BIO_write(bp,"\n",1) <= 0) goto err; |
203 | } | 203 | } |
204 | if(!(cflag & X509_FLAG_NO_PUBKEY)) | 204 | if(!(cflag & X509_FLAG_NO_PUBKEY)) |
205 | { | 205 | { |
206 | if (BIO_write(bp," Subject Public Key Info:\n",33) <= 0) | 206 | if (BIO_write(bp," Subject Public Key Info:\n",33) <= 0) |
207 | goto err; | 207 | goto err; |
208 | if (BIO_printf(bp,"%12sPublic Key Algorithm: ","") <= 0) | 208 | if (BIO_printf(bp,"%12sPublic Key Algorithm: ","") <= 0) |
@@ -214,37 +214,37 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) | |||
214 | 214 | ||
215 | pkey=X509_get_pubkey(x); | 215 | pkey=X509_get_pubkey(x); |
216 | if (pkey == NULL) | 216 | if (pkey == NULL) |
217 | { | 217 | { |
218 | BIO_printf(bp,"%12sUnable to load Public Key\n",""); | 218 | BIO_printf(bp,"%12sUnable to load Public Key\n",""); |
219 | ERR_print_errors(bp); | 219 | ERR_print_errors(bp); |
220 | } | 220 | } |
221 | else | 221 | else |
222 | { | 222 | { |
223 | EVP_PKEY_print_public(bp, pkey, 16, NULL); | 223 | EVP_PKEY_print_public(bp, pkey, 16, NULL); |
224 | EVP_PKEY_free(pkey); | 224 | EVP_PKEY_free(pkey); |
225 | } | ||
226 | } | 225 | } |
226 | } | ||
227 | 227 | ||
228 | if (!(cflag & X509_FLAG_NO_EXTENSIONS)) | 228 | if (!(cflag & X509_FLAG_NO_EXTENSIONS)) |
229 | X509V3_extensions_print(bp, "X509v3 extensions", | 229 | X509V3_extensions_print(bp, "X509v3 extensions", |
230 | ci->extensions, cflag, 8); | 230 | ci->extensions, cflag, 8); |
231 | 231 | ||
232 | if(!(cflag & X509_FLAG_NO_SIGDUMP)) | 232 | if(!(cflag & X509_FLAG_NO_SIGDUMP)) |
233 | { | 233 | { |
234 | if(X509_signature_print(bp, x->sig_alg, x->signature) <= 0) goto err; | 234 | if(X509_signature_print(bp, x->sig_alg, x->signature) <= 0) goto err; |
235 | } | 235 | } |
236 | if(!(cflag & X509_FLAG_NO_AUX)) | 236 | if(!(cflag & X509_FLAG_NO_AUX)) |
237 | { | 237 | { |
238 | if (!X509_CERT_AUX_print(bp, x->aux, 0)) goto err; | 238 | if (!X509_CERT_AUX_print(bp, x->aux, 0)) goto err; |
239 | } | 239 | } |
240 | ret=1; | 240 | ret=1; |
241 | err: | 241 | err: |
242 | if (m != NULL) free(m); | 242 | if (m != NULL) free(m); |
243 | return(ret); | 243 | return(ret); |
244 | } | 244 | } |
245 | 245 | ||
246 | int X509_ocspid_print (BIO *bp, X509 *x) | 246 | int X509_ocspid_print (BIO *bp, X509 *x) |
247 | { | 247 | { |
248 | unsigned char *der=NULL ; | 248 | unsigned char *der=NULL ; |
249 | unsigned char *dertmp; | 249 | unsigned char *dertmp; |
250 | int derlen; | 250 | int derlen; |
@@ -263,9 +263,9 @@ int X509_ocspid_print (BIO *bp, X509 *x) | |||
263 | if (!EVP_Digest(der, derlen, SHA1md, NULL, EVP_sha1(), NULL)) | 263 | if (!EVP_Digest(der, derlen, SHA1md, NULL, EVP_sha1(), NULL)) |
264 | goto err; | 264 | goto err; |
265 | for (i=0; i < SHA_DIGEST_LENGTH; i++) | 265 | for (i=0; i < SHA_DIGEST_LENGTH; i++) |
266 | { | 266 | { |
267 | if (BIO_printf(bp,"%02X",SHA1md[i]) <= 0) goto err; | 267 | if (BIO_printf(bp,"%02X",SHA1md[i]) <= 0) goto err; |
268 | } | 268 | } |
269 | free (der); | 269 | free (der); |
270 | der=NULL; | 270 | der=NULL; |
271 | 271 | ||
@@ -279,17 +279,17 @@ int X509_ocspid_print (BIO *bp, X509 *x) | |||
279 | SHA1md, NULL, EVP_sha1(), NULL)) | 279 | SHA1md, NULL, EVP_sha1(), NULL)) |
280 | goto err; | 280 | goto err; |
281 | for (i=0; i < SHA_DIGEST_LENGTH; i++) | 281 | for (i=0; i < SHA_DIGEST_LENGTH; i++) |
282 | { | 282 | { |
283 | if (BIO_printf(bp,"%02X",SHA1md[i]) <= 0) | 283 | if (BIO_printf(bp,"%02X",SHA1md[i]) <= 0) |
284 | goto err; | 284 | goto err; |
285 | } | 285 | } |
286 | BIO_printf(bp,"\n"); | 286 | BIO_printf(bp,"\n"); |
287 | 287 | ||
288 | return (1); | 288 | return (1); |
289 | err: | 289 | err: |
290 | if (der != NULL) free(der); | 290 | if (der != NULL) free(der); |
291 | return(0); | 291 | return(0); |
292 | } | 292 | } |
293 | 293 | ||
294 | int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent) | 294 | int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent) |
295 | { | 295 | { |
@@ -299,15 +299,15 @@ int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent) | |||
299 | n=sig->length; | 299 | n=sig->length; |
300 | s=sig->data; | 300 | s=sig->data; |
301 | for (i=0; i<n; i++) | 301 | for (i=0; i<n; i++) |
302 | { | 302 | { |
303 | if ((i%18) == 0) | 303 | if ((i%18) == 0) |
304 | { | 304 | { |
305 | if (BIO_write(bp,"\n",1) <= 0) return 0; | 305 | if (BIO_write(bp,"\n",1) <= 0) return 0; |
306 | if (BIO_indent(bp, indent, indent) <= 0) return 0; | 306 | if (BIO_indent(bp, indent, indent) <= 0) return 0; |
307 | } | 307 | } |
308 | if (BIO_printf(bp,"%02x%s",s[i], | 308 | if (BIO_printf(bp,"%02x%s",s[i], |
309 | ((i+1) == n)?"":":") <= 0) return 0; | 309 | ((i+1) == n)?"":":") <= 0) return 0; |
310 | } | 310 | } |
311 | if (BIO_write(bp,"\n",1) != 1) return 0; | 311 | if (BIO_write(bp,"\n",1) != 1) return 0; |
312 | 312 | ||
313 | return 1; | 313 | return 1; |
@@ -321,16 +321,16 @@ int X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig) | |||
321 | 321 | ||
322 | sig_nid = OBJ_obj2nid(sigalg->algorithm); | 322 | sig_nid = OBJ_obj2nid(sigalg->algorithm); |
323 | if (sig_nid != NID_undef) | 323 | if (sig_nid != NID_undef) |
324 | { | 324 | { |
325 | int pkey_nid, dig_nid; | 325 | int pkey_nid, dig_nid; |
326 | const EVP_PKEY_ASN1_METHOD *ameth; | 326 | const EVP_PKEY_ASN1_METHOD *ameth; |
327 | if (OBJ_find_sigid_algs(sig_nid, &dig_nid, &pkey_nid)) | 327 | if (OBJ_find_sigid_algs(sig_nid, &dig_nid, &pkey_nid)) |
328 | { | 328 | { |
329 | ameth = EVP_PKEY_asn1_find(NULL, pkey_nid); | 329 | ameth = EVP_PKEY_asn1_find(NULL, pkey_nid); |
330 | if (ameth && ameth->sig_print) | 330 | if (ameth && ameth->sig_print) |
331 | return ameth->sig_print(bp, sigalg, sig, 9, 0); | 331 | return ameth->sig_print(bp, sigalg, sig, 9, 0); |
332 | } | ||
333 | } | 332 | } |
333 | } | ||
334 | if (sig) | 334 | if (sig) |
335 | return X509_signature_dump(bp, sig, 9); | 335 | return X509_signature_dump(bp, sig, 9); |
336 | else if (BIO_puts(bp, "\n") <= 0) | 336 | else if (BIO_puts(bp, "\n") <= 0) |
@@ -339,7 +339,7 @@ int X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig) | |||
339 | } | 339 | } |
340 | 340 | ||
341 | int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v) | 341 | int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v) |
342 | { | 342 | { |
343 | int i,n; | 343 | int i,n; |
344 | char buf[80]; | 344 | char buf[80]; |
345 | const char *p; | 345 | const char *p; |
@@ -348,7 +348,7 @@ int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v) | |||
348 | n=0; | 348 | n=0; |
349 | p=(const char *)v->data; | 349 | p=(const char *)v->data; |
350 | for (i=0; i<v->length; i++) | 350 | for (i=0; i<v->length; i++) |
351 | { | 351 | { |
352 | if ((p[i] > '~') || ((p[i] < ' ') && | 352 | if ((p[i] > '~') || ((p[i] < ' ') && |
353 | (p[i] != '\n') && (p[i] != '\r'))) | 353 | (p[i] != '\n') && (p[i] != '\r'))) |
354 | buf[n]='.'; | 354 | buf[n]='.'; |
@@ -356,17 +356,17 @@ int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v) | |||
356 | buf[n]=p[i]; | 356 | buf[n]=p[i]; |
357 | n++; | 357 | n++; |
358 | if (n >= 80) | 358 | if (n >= 80) |
359 | { | 359 | { |
360 | if (BIO_write(bp,buf,n) <= 0) | 360 | if (BIO_write(bp,buf,n) <= 0) |
361 | return(0); | 361 | return(0); |
362 | n=0; | 362 | n=0; |
363 | } | ||
364 | } | 363 | } |
364 | } | ||
365 | if (n > 0) | 365 | if (n > 0) |
366 | if (BIO_write(bp,buf,n) <= 0) | 366 | if (BIO_write(bp,buf,n) <= 0) |
367 | return(0); | 367 | return(0); |
368 | return(1); | 368 | return(1); |
369 | } | 369 | } |
370 | 370 | ||
371 | int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm) | 371 | int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm) |
372 | { | 372 | { |
@@ -384,7 +384,7 @@ static const char *mon[12]= | |||
384 | }; | 384 | }; |
385 | 385 | ||
386 | int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm) | 386 | int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm) |
387 | { | 387 | { |
388 | char *v; | 388 | char *v; |
389 | int gmt=0; | 389 | int gmt=0; |
390 | int i; | 390 | int i; |
@@ -408,18 +408,18 @@ int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm) | |||
408 | if (tm->length >= 14 && | 408 | if (tm->length >= 14 && |
409 | (v[12] >= '0') && (v[12] <= '9') && | 409 | (v[12] >= '0') && (v[12] <= '9') && |
410 | (v[13] >= '0') && (v[13] <= '9')) | 410 | (v[13] >= '0') && (v[13] <= '9')) |
411 | { | 411 | { |
412 | s= (v[12]-'0')*10+(v[13]-'0'); | 412 | s= (v[12]-'0')*10+(v[13]-'0'); |
413 | /* Check for fractions of seconds. */ | 413 | /* Check for fractions of seconds. */ |
414 | if (tm->length >= 15 && v[14] == '.') | 414 | if (tm->length >= 15 && v[14] == '.') |
415 | { | 415 | { |
416 | int l = tm->length; | 416 | int l = tm->length; |
417 | f = &v[14]; /* The decimal point. */ | 417 | f = &v[14]; /* The decimal point. */ |
418 | f_len = 1; | 418 | f_len = 1; |
419 | while (14 + f_len < l && f[f_len] >= '0' && f[f_len] <= '9') | 419 | while (14 + f_len < l && f[f_len] >= '0' && f[f_len] <= '9') |
420 | ++f_len; | 420 | ++f_len; |
421 | } | ||
422 | } | 421 | } |
422 | } | ||
423 | 423 | ||
424 | if (BIO_printf(bp,"%s %2d %02d:%02d:%02d%.*s %d%s", | 424 | if (BIO_printf(bp,"%s %2d %02d:%02d:%02d%.*s %d%s", |
425 | mon[M-1],d,h,m,s,f_len,f,y,(gmt)?" GMT":"") <= 0) | 425 | mon[M-1],d,h,m,s,f_len,f,y,(gmt)?" GMT":"") <= 0) |
@@ -429,10 +429,10 @@ int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm) | |||
429 | err: | 429 | err: |
430 | BIO_write(bp,"Bad time value",14); | 430 | BIO_write(bp,"Bad time value",14); |
431 | return(0); | 431 | return(0); |
432 | } | 432 | } |
433 | 433 | ||
434 | int ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm) | 434 | int ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm) |
435 | { | 435 | { |
436 | const char *v; | 436 | const char *v; |
437 | int gmt=0; | 437 | int gmt=0; |
438 | int i; | 438 | int i; |
@@ -465,10 +465,10 @@ int ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm) | |||
465 | err: | 465 | err: |
466 | BIO_write(bp,"Bad time value",14); | 466 | BIO_write(bp,"Bad time value",14); |
467 | return(0); | 467 | return(0); |
468 | } | 468 | } |
469 | 469 | ||
470 | int X509_NAME_print(BIO *bp, X509_NAME *name, int obase) | 470 | int X509_NAME_print(BIO *bp, X509_NAME *name, int obase) |
471 | { | 471 | { |
472 | char *s,*c,*b; | 472 | char *s,*c,*b; |
473 | int ret=0,l,i; | 473 | int ret=0,l,i; |
474 | 474 | ||
@@ -476,15 +476,15 @@ int X509_NAME_print(BIO *bp, X509_NAME *name, int obase) | |||
476 | 476 | ||
477 | b=X509_NAME_oneline(name,NULL,0); | 477 | b=X509_NAME_oneline(name,NULL,0); |
478 | if (!*b) | 478 | if (!*b) |
479 | { | 479 | { |
480 | free(b); | 480 | free(b); |
481 | return 1; | 481 | return 1; |
482 | } | 482 | } |
483 | s=b+1; /* skip the first slash */ | 483 | s=b+1; /* skip the first slash */ |
484 | 484 | ||
485 | c=s; | 485 | c=s; |
486 | for (;;) | 486 | for (;;) |
487 | { | 487 | { |
488 | if ( ((*s == '/') && | 488 | if ( ((*s == '/') && |
489 | ((s[1] >= 'A') && (s[1] <= 'Z') && ( | 489 | ((s[1] >= 'A') && (s[1] <= 'Z') && ( |
490 | (s[2] == '=') || | 490 | (s[2] == '=') || |
@@ -492,27 +492,27 @@ int X509_NAME_print(BIO *bp, X509_NAME *name, int obase) | |||
492 | (s[3] == '=')) | 492 | (s[3] == '=')) |
493 | ))) || | 493 | ))) || |
494 | (*s == '\0')) | 494 | (*s == '\0')) |
495 | { | 495 | { |
496 | i=s-c; | 496 | i=s-c; |
497 | if (BIO_write(bp,c,i) != i) goto err; | 497 | if (BIO_write(bp,c,i) != i) goto err; |
498 | c=s+1; /* skip following slash */ | 498 | c=s+1; /* skip following slash */ |
499 | if (*s != '\0') | 499 | if (*s != '\0') |
500 | { | 500 | { |
501 | if (BIO_write(bp,", ",2) != 2) goto err; | 501 | if (BIO_write(bp,", ",2) != 2) goto err; |
502 | } | ||
503 | l--; | ||
504 | } | 502 | } |
503 | l--; | ||
504 | } | ||
505 | if (*s == '\0') break; | 505 | if (*s == '\0') break; |
506 | s++; | 506 | s++; |
507 | l--; | 507 | l--; |
508 | } | 508 | } |
509 | 509 | ||
510 | ret=1; | 510 | ret=1; |
511 | if (0) | 511 | if (0) |
512 | { | 512 | { |
513 | err: | 513 | err: |
514 | X509err(X509_F_X509_NAME_PRINT,ERR_R_BUF_LIB); | 514 | X509err(X509_F_X509_NAME_PRINT,ERR_R_BUF_LIB); |
515 | } | 515 | } |
516 | free(b); | 516 | free(b); |
517 | return(ret); | 517 | return(ret); |
518 | } | 518 | } |