diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/t_pkey.c')
-rw-r--r-- | src/lib/libcrypto/asn1/t_pkey.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/lib/libcrypto/asn1/t_pkey.c b/src/lib/libcrypto/asn1/t_pkey.c index a307381231..d1f77219ea 100644 --- a/src/lib/libcrypto/asn1/t_pkey.c +++ b/src/lib/libcrypto/asn1/t_pkey.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: t_pkey.c,v 1.17 2021/12/04 16:08:32 tb Exp $ */ | 1 | /* $OpenBSD: t_pkey.c,v 1.18 2022/11/10 13:09:34 jsing 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 | * |
@@ -114,3 +114,32 @@ ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, | |||
114 | } | 114 | } |
115 | return (1); | 115 | return (1); |
116 | } | 116 | } |
117 | |||
118 | #define ASN1_BUF_PRINT_WIDTH 15 | ||
119 | #define ASN1_BUF_PRINT_MAX_INDENT 64 | ||
120 | |||
121 | int | ||
122 | ASN1_buf_print(BIO *bp, const unsigned char *buf, size_t buflen, int indent) | ||
123 | { | ||
124 | size_t i; | ||
125 | |||
126 | for (i = 0; i < buflen; i++) { | ||
127 | if ((i % ASN1_BUF_PRINT_WIDTH) == 0) { | ||
128 | if (i > 0 && BIO_puts(bp, "\n") <= 0) | ||
129 | return 0; | ||
130 | if (!BIO_indent(bp, indent, ASN1_BUF_PRINT_MAX_INDENT)) | ||
131 | return 0; | ||
132 | } | ||
133 | /* | ||
134 | * Use colon separators for each octet for compatibility as | ||
135 | * this function is used to print out key components. | ||
136 | */ | ||
137 | if (BIO_printf(bp, "%02x%s", buf[i], | ||
138 | (i == buflen - 1) ? "" : ":") <= 0) | ||
139 | return 0; | ||
140 | } | ||
141 | if (BIO_write(bp, "\n", 1) <= 0) | ||
142 | return 0; | ||
143 | |||
144 | return 1; | ||
145 | } | ||