diff options
author | djm <> | 2010-10-01 22:59:01 +0000 |
---|---|---|
committer | djm <> | 2010-10-01 22:59:01 +0000 |
commit | fe047d8b632246cb2db3234a0a4f32e5c318857b (patch) | |
tree | 939b752540947d33507b3acc48d76a8bfb7c3dc3 /src/lib/libcrypto/x509v3/v3_utl.c | |
parent | 2ea67f4aa254b09ded62e6e14fc893bbe6381579 (diff) | |
download | openbsd-fe047d8b632246cb2db3234a0a4f32e5c318857b.tar.gz openbsd-fe047d8b632246cb2db3234a0a4f32e5c318857b.tar.bz2 openbsd-fe047d8b632246cb2db3234a0a4f32e5c318857b.zip |
resolve conflicts, fix local changes
Diffstat (limited to 'src/lib/libcrypto/x509v3/v3_utl.c')
-rw-r--r-- | src/lib/libcrypto/x509v3/v3_utl.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/src/lib/libcrypto/x509v3/v3_utl.c b/src/lib/libcrypto/x509v3/v3_utl.c index 2cb53008e3..e030234540 100644 --- a/src/lib/libcrypto/x509v3/v3_utl.c +++ b/src/lib/libcrypto/x509v3/v3_utl.c | |||
@@ -67,9 +67,9 @@ | |||
67 | 67 | ||
68 | static char *strip_spaces(char *name); | 68 | static char *strip_spaces(char *name); |
69 | static int sk_strcmp(const char * const *a, const char * const *b); | 69 | static int sk_strcmp(const char * const *a, const char * const *b); |
70 | static STACK *get_email(X509_NAME *name, GENERAL_NAMES *gens); | 70 | static STACK_OF(OPENSSL_STRING) *get_email(X509_NAME *name, GENERAL_NAMES *gens); |
71 | static void str_free(void *str); | 71 | static void str_free(OPENSSL_STRING str); |
72 | static int append_ia5(STACK **sk, ASN1_IA5STRING *email); | 72 | static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, ASN1_IA5STRING *email); |
73 | 73 | ||
74 | static int ipv4_from_asc(unsigned char *v4, const char *in); | 74 | static int ipv4_from_asc(unsigned char *v4, const char *in); |
75 | static int ipv6_from_asc(unsigned char *v6, const char *in); | 75 | static int ipv6_from_asc(unsigned char *v6, const char *in); |
@@ -344,7 +344,7 @@ static char *strip_spaces(char *name) | |||
344 | char *p, *q; | 344 | char *p, *q; |
345 | /* Skip over leading spaces */ | 345 | /* Skip over leading spaces */ |
346 | p = name; | 346 | p = name; |
347 | while(isspace((unsigned char)*p)) p++; | 347 | while(*p && isspace((unsigned char)*p)) p++; |
348 | if(!*p) return NULL; | 348 | if(!*p) return NULL; |
349 | q = p + strlen(p) - 1; | 349 | q = p + strlen(p) - 1; |
350 | while((q != p) && isspace((unsigned char)*q)) q--; | 350 | while((q != p) && isspace((unsigned char)*q)) q--; |
@@ -360,10 +360,10 @@ static char *strip_spaces(char *name) | |||
360 | * @@@ (Contents of buffer are always kept in ASCII, also on EBCDIC machines) | 360 | * @@@ (Contents of buffer are always kept in ASCII, also on EBCDIC machines) |
361 | */ | 361 | */ |
362 | 362 | ||
363 | char *hex_to_string(unsigned char *buffer, long len) | 363 | char *hex_to_string(const unsigned char *buffer, long len) |
364 | { | 364 | { |
365 | char *tmp, *q; | 365 | char *tmp, *q; |
366 | unsigned char *p; | 366 | const unsigned char *p; |
367 | int i; | 367 | int i; |
368 | const static char hexdig[] = "0123456789ABCDEF"; | 368 | const static char hexdig[] = "0123456789ABCDEF"; |
369 | if(!buffer || !len) return NULL; | 369 | if(!buffer || !len) return NULL; |
@@ -389,7 +389,7 @@ char *hex_to_string(unsigned char *buffer, long len) | |||
389 | * a buffer | 389 | * a buffer |
390 | */ | 390 | */ |
391 | 391 | ||
392 | unsigned char *string_to_hex(char *str, long *len) | 392 | unsigned char *string_to_hex(const char *str, long *len) |
393 | { | 393 | { |
394 | unsigned char *hexbuf, *q; | 394 | unsigned char *hexbuf, *q; |
395 | unsigned char ch, cl, *p; | 395 | unsigned char ch, cl, *p; |
@@ -463,21 +463,23 @@ static int sk_strcmp(const char * const *a, const char * const *b) | |||
463 | return strcmp(*a, *b); | 463 | return strcmp(*a, *b); |
464 | } | 464 | } |
465 | 465 | ||
466 | STACK *X509_get1_email(X509 *x) | 466 | STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x) |
467 | { | 467 | { |
468 | GENERAL_NAMES *gens; | 468 | GENERAL_NAMES *gens; |
469 | STACK *ret; | 469 | STACK_OF(OPENSSL_STRING) *ret; |
470 | |||
470 | gens = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL); | 471 | gens = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL); |
471 | ret = get_email(X509_get_subject_name(x), gens); | 472 | ret = get_email(X509_get_subject_name(x), gens); |
472 | sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); | 473 | sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); |
473 | return ret; | 474 | return ret; |
474 | } | 475 | } |
475 | 476 | ||
476 | STACK *X509_get1_ocsp(X509 *x) | 477 | STACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x) |
477 | { | 478 | { |
478 | AUTHORITY_INFO_ACCESS *info; | 479 | AUTHORITY_INFO_ACCESS *info; |
479 | STACK *ret = NULL; | 480 | STACK_OF(OPENSSL_STRING) *ret = NULL; |
480 | int i; | 481 | int i; |
482 | |||
481 | info = X509_get_ext_d2i(x, NID_info_access, NULL, NULL); | 483 | info = X509_get_ext_d2i(x, NID_info_access, NULL, NULL); |
482 | if (!info) | 484 | if (!info) |
483 | return NULL; | 485 | return NULL; |
@@ -497,11 +499,12 @@ STACK *X509_get1_ocsp(X509 *x) | |||
497 | return ret; | 499 | return ret; |
498 | } | 500 | } |
499 | 501 | ||
500 | STACK *X509_REQ_get1_email(X509_REQ *x) | 502 | STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x) |
501 | { | 503 | { |
502 | GENERAL_NAMES *gens; | 504 | GENERAL_NAMES *gens; |
503 | STACK_OF(X509_EXTENSION) *exts; | 505 | STACK_OF(X509_EXTENSION) *exts; |
504 | STACK *ret; | 506 | STACK_OF(OPENSSL_STRING) *ret; |
507 | |||
505 | exts = X509_REQ_get_extensions(x); | 508 | exts = X509_REQ_get_extensions(x); |
506 | gens = X509V3_get_d2i(exts, NID_subject_alt_name, NULL, NULL); | 509 | gens = X509V3_get_d2i(exts, NID_subject_alt_name, NULL, NULL); |
507 | ret = get_email(X509_REQ_get_subject_name(x), gens); | 510 | ret = get_email(X509_REQ_get_subject_name(x), gens); |
@@ -511,9 +514,9 @@ STACK *X509_REQ_get1_email(X509_REQ *x) | |||
511 | } | 514 | } |
512 | 515 | ||
513 | 516 | ||
514 | static STACK *get_email(X509_NAME *name, GENERAL_NAMES *gens) | 517 | static STACK_OF(OPENSSL_STRING) *get_email(X509_NAME *name, GENERAL_NAMES *gens) |
515 | { | 518 | { |
516 | STACK *ret = NULL; | 519 | STACK_OF(OPENSSL_STRING) *ret = NULL; |
517 | X509_NAME_ENTRY *ne; | 520 | X509_NAME_ENTRY *ne; |
518 | ASN1_IA5STRING *email; | 521 | ASN1_IA5STRING *email; |
519 | GENERAL_NAME *gen; | 522 | GENERAL_NAME *gen; |
@@ -536,23 +539,23 @@ static STACK *get_email(X509_NAME *name, GENERAL_NAMES *gens) | |||
536 | return ret; | 539 | return ret; |
537 | } | 540 | } |
538 | 541 | ||
539 | static void str_free(void *str) | 542 | static void str_free(OPENSSL_STRING str) |
540 | { | 543 | { |
541 | OPENSSL_free(str); | 544 | OPENSSL_free(str); |
542 | } | 545 | } |
543 | 546 | ||
544 | static int append_ia5(STACK **sk, ASN1_IA5STRING *email) | 547 | static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, ASN1_IA5STRING *email) |
545 | { | 548 | { |
546 | char *emtmp; | 549 | char *emtmp; |
547 | /* First some sanity checks */ | 550 | /* First some sanity checks */ |
548 | if(email->type != V_ASN1_IA5STRING) return 1; | 551 | if(email->type != V_ASN1_IA5STRING) return 1; |
549 | if(!email->data || !email->length) return 1; | 552 | if(!email->data || !email->length) return 1; |
550 | if(!*sk) *sk = sk_new(sk_strcmp); | 553 | if(!*sk) *sk = sk_OPENSSL_STRING_new(sk_strcmp); |
551 | if(!*sk) return 0; | 554 | if(!*sk) return 0; |
552 | /* Don't add duplicates */ | 555 | /* Don't add duplicates */ |
553 | if(sk_find(*sk, (char *)email->data) != -1) return 1; | 556 | if(sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1) return 1; |
554 | emtmp = BUF_strdup((char *)email->data); | 557 | emtmp = BUF_strdup((char *)email->data); |
555 | if(!emtmp || !sk_push(*sk, emtmp)) { | 558 | if(!emtmp || !sk_OPENSSL_STRING_push(*sk, emtmp)) { |
556 | X509_email_free(*sk); | 559 | X509_email_free(*sk); |
557 | *sk = NULL; | 560 | *sk = NULL; |
558 | return 0; | 561 | return 0; |
@@ -560,9 +563,9 @@ static int append_ia5(STACK **sk, ASN1_IA5STRING *email) | |||
560 | return 1; | 563 | return 1; |
561 | } | 564 | } |
562 | 565 | ||
563 | void X509_email_free(STACK *sk) | 566 | void X509_email_free(STACK_OF(OPENSSL_STRING) *sk) |
564 | { | 567 | { |
565 | sk_pop_free(sk, str_free); | 568 | sk_OPENSSL_STRING_pop_free(sk, str_free); |
566 | } | 569 | } |
567 | 570 | ||
568 | /* Convert IP addresses both IPv4 and IPv6 into an | 571 | /* Convert IP addresses both IPv4 and IPv6 into an |