summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/usr.bin/openssl/pkcs12.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/usr.bin/openssl/pkcs12.c b/src/usr.bin/openssl/pkcs12.c
index efd6d59163..d29a12ce60 100644
--- a/src/usr.bin/openssl/pkcs12.c
+++ b/src/usr.bin/openssl/pkcs12.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pkcs12.c,v 1.30 2025/06/07 08:33:58 tb Exp $ */ 1/* $OpenBSD: pkcs12.c,v 1.31 2025/11/27 08:26:32 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -88,7 +88,6 @@ static int dump_certs_pkeys_bag(BIO *out, PKCS12_SAFEBAG *bags, char *pass,
88 int passlen, int options, char *pempass); 88 int passlen, int options, char *pempass);
89static int print_attribs(BIO *out, const STACK_OF(X509_ATTRIBUTE) *attrlst, 89static int print_attribs(BIO *out, const STACK_OF(X509_ATTRIBUTE) *attrlst,
90 const char *name); 90 const char *name);
91static void hex_prin(BIO *out, unsigned char *buf, int len);
92static int alg_print(BIO *x, const X509_ALGOR *alg); 91static int alg_print(BIO *x, const X509_ALGOR *alg);
93static int set_pbe(BIO *err, int *ppbe, const char *str); 92static int set_pbe(BIO *err, int *ppbe, const char *str);
94 93
@@ -1021,6 +1020,17 @@ alg_print(BIO *x, const X509_ALGOR *alg)
1021 return 1; 1020 return 1;
1022} 1021}
1023 1022
1023static void
1024hex_print(BIO *out, const ASN1_STRING *str)
1025{
1026 const unsigned char *buf = ASN1_STRING_get0_data(str);
1027 int len = ASN1_STRING_length(str);
1028 int i;
1029
1030 for (i = 0; i < len; i++)
1031 BIO_printf(out, "%02X ", buf[i]);
1032}
1033
1024/* Generalised attribute print: handle PKCS#8 and bag attributes */ 1034/* Generalised attribute print: handle PKCS#8 and bag attributes */
1025static void 1035static void
1026print_attribute(BIO *out, const ASN1_TYPE *av) 1036print_attribute(BIO *out, const ASN1_TYPE *av)
@@ -1030,21 +1040,19 @@ print_attribute(BIO *out, const ASN1_TYPE *av)
1030 switch (av->type) { 1040 switch (av->type) {
1031 case V_ASN1_BMPSTRING: 1041 case V_ASN1_BMPSTRING:
1032 value = OPENSSL_uni2asc( 1042 value = OPENSSL_uni2asc(
1033 av->value.bmpstring->data, 1043 ASN1_STRING_get0_data(av->value.bmpstring),
1034 av->value.bmpstring->length); 1044 ASN1_STRING_length(av->value.bmpstring));
1035 BIO_printf(out, "%s\n", value); 1045 BIO_printf(out, "%s\n", value != NULL ? value : "(null)");
1036 free(value); 1046 free(value);
1037 break; 1047 break;
1038 1048
1039 case V_ASN1_OCTET_STRING: 1049 case V_ASN1_OCTET_STRING:
1040 hex_prin(out, av->value.octet_string->data, 1050 hex_print(out, av->value.octet_string);
1041 av->value.octet_string->length);
1042 BIO_printf(out, "\n"); 1051 BIO_printf(out, "\n");
1043 break; 1052 break;
1044 1053
1045 case V_ASN1_BIT_STRING: 1054 case V_ASN1_BIT_STRING:
1046 hex_prin(out, av->value.bit_string->data, 1055 hex_print(out, av->value.bit_string);
1047 av->value.bit_string->length);
1048 BIO_printf(out, "\n"); 1056 BIO_printf(out, "\n");
1049 break; 1057 break;
1050 1058
@@ -1096,15 +1104,6 @@ print_attribs(BIO *out, const STACK_OF(X509_ATTRIBUTE) *attrlst,
1096 return 1; 1104 return 1;
1097} 1105}
1098 1106
1099static void
1100hex_prin(BIO *out, unsigned char *buf, int len)
1101{
1102 int i;
1103
1104 for (i = 0; i < len; i++)
1105 BIO_printf(out, "%02X ", buf[i]);
1106}
1107
1108static int 1107static int
1109set_pbe(BIO *err, int *ppbe, const char *str) 1108set_pbe(BIO *err, int *ppbe, const char *str)
1110{ 1109{