diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/t_x509.c')
-rw-r--r-- | src/lib/libcrypto/asn1/t_x509.c | 98 |
1 files changed, 7 insertions, 91 deletions
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c index 3181dd2907..7cf4557314 100644 --- a/src/lib/libcrypto/asn1/t_x509.c +++ b/src/lib/libcrypto/asn1/t_x509.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: t_x509.c,v 1.50 2025/01/27 10:29:41 tb Exp $ */ | 1 | /* $OpenBSD: t_x509.c,v 1.51 2025/02/08 03:41:36 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -57,28 +57,21 @@ | |||
57 | */ | 57 | */ |
58 | 58 | ||
59 | #include <limits.h> | 59 | #include <limits.h> |
60 | #include <stdint.h> | ||
60 | #include <stdio.h> | 61 | #include <stdio.h> |
62 | #include <stdlib.h> | ||
61 | 63 | ||
62 | #include <openssl/opensslconf.h> | 64 | #include <openssl/opensslconf.h> |
63 | 65 | ||
64 | #include <openssl/bn.h> | 66 | #include <openssl/asn1.h> |
65 | #include <openssl/buffer.h> | 67 | #include <openssl/bio.h> |
66 | #include <openssl/err.h> | 68 | #include <openssl/err.h> |
69 | #include <openssl/evp.h> | ||
67 | #include <openssl/objects.h> | 70 | #include <openssl/objects.h> |
71 | #include <openssl/sha.h> | ||
68 | #include <openssl/x509.h> | 72 | #include <openssl/x509.h> |
69 | #include <openssl/x509v3.h> | 73 | #include <openssl/x509v3.h> |
70 | 74 | ||
71 | #ifndef OPENSSL_NO_DSA | ||
72 | #include <openssl/dsa.h> | ||
73 | #endif | ||
74 | #ifndef OPENSSL_NO_EC | ||
75 | #include <openssl/ec.h> | ||
76 | #endif | ||
77 | #ifndef OPENSSL_NO_RSA | ||
78 | #include <openssl/rsa.h> | ||
79 | #endif | ||
80 | |||
81 | #include "bytestring.h" | ||
82 | #include "evp_local.h" | 75 | #include "evp_local.h" |
83 | #include "x509_local.h" | 76 | #include "x509_local.h" |
84 | 77 | ||
@@ -490,80 +483,3 @@ ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm) | |||
490 | return (0); | 483 | return (0); |
491 | } | 484 | } |
492 | LCRYPTO_ALIAS(ASN1_UTCTIME_print); | 485 | LCRYPTO_ALIAS(ASN1_UTCTIME_print); |
493 | |||
494 | /* NID with SN of 1-2 letters, which X509_NAME_print() historically included. */ | ||
495 | static int | ||
496 | x509_name_entry_include(const X509_NAME_ENTRY *ne) | ||
497 | { | ||
498 | int nid; | ||
499 | |||
500 | if ((nid = OBJ_obj2nid(ne->object)) == NID_undef) | ||
501 | return 0; | ||
502 | |||
503 | switch (nid) { | ||
504 | case NID_commonName: | ||
505 | case NID_surname: | ||
506 | case NID_countryName: | ||
507 | case NID_localityName: | ||
508 | case NID_stateOrProvinceName: | ||
509 | case NID_organizationName: | ||
510 | case NID_organizationalUnitName: | ||
511 | case NID_givenName: | ||
512 | case NID_domainComponent: /* XXX - doesn't really belong here */ | ||
513 | return 1; | ||
514 | } | ||
515 | |||
516 | return 0; | ||
517 | } | ||
518 | |||
519 | int | ||
520 | X509_NAME_print(BIO *bio, const X509_NAME *name, int obase) | ||
521 | { | ||
522 | CBB cbb; | ||
523 | uint8_t *buf = NULL; | ||
524 | size_t buf_len; | ||
525 | const X509_NAME_ENTRY *ne; | ||
526 | int i; | ||
527 | int started = 0; | ||
528 | int ret = 0; | ||
529 | |||
530 | if (!CBB_init(&cbb, 0)) | ||
531 | goto err; | ||
532 | |||
533 | for (i = 0; i < sk_X509_NAME_ENTRY_num(name->entries); i++) { | ||
534 | ne = sk_X509_NAME_ENTRY_value(name->entries, i); | ||
535 | |||
536 | if (!x509_name_entry_include(ne)) | ||
537 | continue; | ||
538 | |||
539 | if (started) { | ||
540 | if (!CBB_add_u8(&cbb, ',')) | ||
541 | goto err; | ||
542 | if (!CBB_add_u8(&cbb, ' ')) | ||
543 | goto err; | ||
544 | } | ||
545 | |||
546 | if (!X509_NAME_ENTRY_add_cbb(&cbb, ne)) | ||
547 | goto err; | ||
548 | |||
549 | started = 1; | ||
550 | } | ||
551 | |||
552 | if (!CBB_add_u8(&cbb, '\0')) | ||
553 | goto err; | ||
554 | |||
555 | if (!CBB_finish(&cbb, &buf, &buf_len)) | ||
556 | goto err; | ||
557 | |||
558 | if (BIO_printf(bio, "%s", buf) < 0) | ||
559 | goto err; | ||
560 | |||
561 | ret = 1; | ||
562 | |||
563 | err: | ||
564 | CBB_cleanup(&cbb); | ||
565 | free(buf); | ||
566 | |||
567 | return ret; | ||
568 | } | ||
569 | LCRYPTO_ALIAS(X509_NAME_print); | ||