IMPLEMENT_ASN1_FUNCTIONS(OSSL_PRIVILEGE_POLICY_ID)
IMPLEMENT_ASN1_FUNCTIONS(OSSL_ATTRIBUTE_DESCRIPTOR)
-/* Copied from x_attrib.c */
-static int print_hex(BIO *out, unsigned char *buf, int len)
-{
- int result = 1;
- char *hexbuf;
-
- if (len == 0)
- return 1;
-
- hexbuf = OPENSSL_buf2hexstr(buf, len);
- if (hexbuf == NULL)
- return 0;
- result = BIO_puts(out, hexbuf) > 0;
-
- OPENSSL_free(hexbuf);
- return result;
-}
-
static int i2r_HASH(X509V3_EXT_METHOD *method,
OSSL_HASH *hash,
BIO *out, int indent)
}
if (BIO_printf(out, "%*sHash Value: ", indent, "") <= 0)
return 0;
- return print_hex(out, hash->hashValue->data, hash->hashValue->length);
+ return ossl_bio_print_hex(out, hash->hashValue->data, hash->hashValue->length);
}
static int i2r_INFO_SYNTAX_POINTER(X509V3_EXT_METHOD *method,
BIO *out, int indent)
{
switch (info->type) {
- case (OSSL_INFO_SYNTAX_TYPE_CONTENT):
+ case OSSL_INFO_SYNTAX_TYPE_CONTENT:
if (BIO_printf(out, "%*sContent: ", indent, "") <= 0)
return 0;
if (BIO_printf(out, "%.*s", info->choice.content->length, info->choice.content->data) <= 0)
if (BIO_puts(out, "\n") <= 0)
return 0;
return 1;
- case (OSSL_INFO_SYNTAX_TYPE_POINTER):
+ case OSSL_INFO_SYNTAX_TYPE_POINTER:
if (BIO_printf(out, "%*sPointer:\n", indent, "") <= 0)
return 0;
return i2r_INFO_SYNTAX_POINTER(method, info->choice.pointer, out, indent + 4);
}
return 1;
}
+
+int ossl_bio_print_hex(BIO *out, unsigned char *buf, int len)
+{
+ int result;
+ char *hexbuf;
+
+ if (len == 0)
+ return 1;
+
+ hexbuf = OPENSSL_buf2hexstr(buf, len);
+ if (hexbuf == NULL)
+ return 0;
+ result = BIO_puts(out, hexbuf) > 0;
+
+ OPENSSL_free(hexbuf);
+ return result;
+}
return NULL;
}
-static int print_hex(BIO *out, unsigned char *buf, int len)
-{
- int result = 1;
- char *hexbuf;
-
- if (len == 0)
- return 1;
-
- hexbuf = OPENSSL_buf2hexstr(buf, len);
- if (hexbuf == NULL)
- return 0;
- result = BIO_puts(out, hexbuf) > 0;
-
- OPENSSL_free(hexbuf);
- return result;
-}
-
static int print_oid(BIO *out, const ASN1_OBJECT *oid) {
const char *ln;
char objbuf[80];
return BIO_printf(out, "%lld", (long long int)int_val) > 0;
}
str = av->value.integer;
- return print_hex(out, str->data, str->length);
+ return ossl_bio_print_hex(out, str->data, str->length);
case V_ASN1_BIT_STRING:
if (BIO_printf(out, "%*s", indent, "") < 0)
return 0;
- return print_hex(out, av->value.bit_string->data,
- av->value.bit_string->length);
+ return ossl_bio_print_hex(out, av->value.bit_string->data,
+ av->value.bit_string->length);
case V_ASN1_OCTET_STRING:
case V_ASN1_VIDEOTEXSTRING:
if (BIO_printf(out, "%*s", indent, "") < 0)
return 0;
- return print_hex(out, av->value.octet_string->data,
- av->value.octet_string->length);
+ return ossl_bio_print_hex(out, av->value.octet_string->data,
+ av->value.octet_string->length);
case V_ASN1_NULL:
return BIO_printf(out, "%*sNULL", indent, "") >= 4;
--- /dev/null
+=pod
+
+=head1 NAME
+
+ossl_bio_print_hex
+- Print a hexdump of a binary input
+
+=head1 SYNOPSIS
+
+ #include <crypto/x509.h>
+
+ int ossl_bio_print_hex(BIO *out, unsigned char *buf, int len);
+
+=head1 DESCRIPTION
+
+This function prints a hexdump-like hexadecimal output to I<out> from a binary
+input I<buf> that is I<len> bytes in length.
+
+=head1 RETURN VALUES
+
+Returns 1 if it succeeds in printing, and 0 if it failed.
+
+=head1 COPYRIGHT
+
+Copyright 2024 The OpenSSL Project Authors. All Rights Reserved.
+
+Licensed under the Apache License 2.0 (the "License"). You may not use
+this file except in compliance with the License. You can obtain a copy
+in the file LICENSE in the source distribution or at
+L<https://www.openssl.org/source/license.html>.
+
+=cut
int indent);
int ossl_serial_number_print(BIO *out, const ASN1_INTEGER *bs, int indent);
+int ossl_bio_print_hex(BIO *out, unsigned char *buf, int len);
#endif /* OSSL_CRYPTO_X509_H */