2 * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 #include "app_params.h"
13 static int describe_param_type(char *buf, size_t bufsz, const OSSL_PARAM *param)
15 const char *type_mod = "";
16 const char *type = NULL;
17 int show_type_number = 0;
20 switch (param->data_type) {
21 case OSSL_PARAM_UNSIGNED_INTEGER:
22 type_mod = "unsigned ";
24 case OSSL_PARAM_INTEGER:
27 case OSSL_PARAM_UTF8_PTR:
28 type_mod = "pointer to a ";
30 case OSSL_PARAM_UTF8_STRING:
31 type = "UTF8 encoded string";
33 case OSSL_PARAM_OCTET_PTR:
34 type_mod = "pointer to an ";
36 case OSSL_PARAM_OCTET_STRING:
37 type = "octet string";
40 type = "unknown type";
45 printed_len = BIO_snprintf(buf, bufsz, "%s: ", param->key);
46 if (printed_len > 0) {
50 printed_len = BIO_snprintf(buf, bufsz, "%s%s", type_mod, type);
51 if (printed_len > 0) {
55 if (show_type_number) {
56 printed_len = BIO_snprintf(buf, bufsz, " [%d]", param->data_type);
57 if (printed_len > 0) {
62 if (param->data_size == 0)
63 printed_len = BIO_snprintf(buf, bufsz, " (arbitrary size)");
65 printed_len = BIO_snprintf(buf, bufsz, " (max %zu bytes large)",
67 if (printed_len > 0) {
75 int print_param_types(const char *thing, const OSSL_PARAM *pdefs, int indent)
78 BIO_printf(bio_out, "%*sNo declared %s\n", indent, "", thing);
79 } else if (pdefs->key == NULL) {
81 * An empty list? This shouldn't happen, but let's just make sure to
82 * say something if there's a badly written provider...
84 BIO_printf(bio_out, "%*sEmpty list of %s (!!!)\n", indent, "", thing);
86 BIO_printf(bio_out, "%*s%s:\n", indent, "", thing);
87 for (; pdefs->key != NULL; pdefs++) {
88 char buf[200]; /* This should be ample space */
90 describe_param_type(buf, sizeof(buf), pdefs);
91 BIO_printf(bio_out, "%*s %s\n", indent, "", buf);