summaryrefslogtreecommitdiff
path: root/crypto/encode_decode
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2026-01-29 01:27:53 +0000
committerEnji Cooper <ngie@FreeBSD.org>2026-01-29 01:27:53 +0000
commit808413da28df9fb93e1f304e6016b15e660f54c8 (patch)
treef3ecb4f928716223c9563ee34e044ab84549debb /crypto/encode_decode
parent8e12a5c4eb3507846b507d0afe87d115af41df40 (diff)
Diffstat (limited to 'crypto/encode_decode')
-rw-r--r--crypto/encode_decode/decoder_err.c14
-rw-r--r--crypto/encode_decode/decoder_lib.c386
-rw-r--r--crypto/encode_decode/decoder_meth.c85
-rw-r--r--crypto/encode_decode/decoder_pkey.c226
-rw-r--r--crypto/encode_decode/encoder_err.c14
-rw-r--r--crypto/encode_decode/encoder_lib.c252
-rw-r--r--crypto/encode_decode/encoder_local.h18
-rw-r--r--crypto/encode_decode/encoder_meth.c95
-rw-r--r--crypto/encode_decode/encoder_pkey.c95
9 files changed, 607 insertions, 578 deletions
diff --git a/crypto/encode_decode/decoder_err.c b/crypto/encode_decode/decoder_err.c
index 88324a1d5078..9e6556a1467d 100644
--- a/crypto/encode_decode/decoder_err.c
+++ b/crypto/encode_decode/decoder_err.c
@@ -15,13 +15,13 @@
#ifndef OPENSSL_NO_ERR
static const ERR_STRING_DATA OSSL_DECODER_str_reasons[] = {
- {ERR_PACK(ERR_LIB_OSSL_DECODER, 0, OSSL_DECODER_R_COULD_NOT_DECODE_OBJECT),
- "could not decode object"},
- {ERR_PACK(ERR_LIB_OSSL_DECODER, 0, OSSL_DECODER_R_DECODER_NOT_FOUND),
- "decoder not found"},
- {ERR_PACK(ERR_LIB_OSSL_DECODER, 0, OSSL_DECODER_R_MISSING_GET_PARAMS),
- "missing get params"},
- {0, NULL}
+ { ERR_PACK(ERR_LIB_OSSL_DECODER, 0, OSSL_DECODER_R_COULD_NOT_DECODE_OBJECT),
+ "could not decode object" },
+ { ERR_PACK(ERR_LIB_OSSL_DECODER, 0, OSSL_DECODER_R_DECODER_NOT_FOUND),
+ "decoder not found" },
+ { ERR_PACK(ERR_LIB_OSSL_DECODER, 0, OSSL_DECODER_R_MISSING_GET_PARAMS),
+ "missing get params" },
+ { 0, NULL }
};
#endif
diff --git a/crypto/encode_decode/decoder_lib.c b/crypto/encode_decode/decoder_lib.c
index dedfb24e569e..c0b32d7d9c42 100644
--- a/crypto/encode_decode/decoder_lib.c
+++ b/crypto/encode_decode/decoder_lib.c
@@ -58,9 +58,9 @@ int OSSL_DECODER_from_bio(OSSL_DECODER_CTX *ctx, BIO *in)
if (OSSL_DECODER_CTX_get_num_decoders(ctx) == 0) {
ERR_raise_data(ERR_LIB_OSSL_DECODER, OSSL_DECODER_R_DECODER_NOT_FOUND,
- "No decoders were found. For standard decoders you need "
- "at least one of the default or base providers "
- "available. Did you forget to load them?");
+ "No decoders were found. For standard decoders you need "
+ "at least one of the default or base providers "
+ "available. Did you forget to load them?");
return 0;
}
@@ -84,14 +84,16 @@ int OSSL_DECODER_from_bio(OSSL_DECODER_CTX *ctx, BIO *in)
if (!data.flag_construct_called) {
const char *spaces
= ctx->start_input_type != NULL && ctx->input_structure != NULL
- ? " " : "";
+ ? " "
+ : "";
const char *input_type_label
= ctx->start_input_type != NULL ? "Input type: " : "";
const char *input_structure_label
= ctx->input_structure != NULL ? "Input structure: " : "";
const char *comma
= ctx->start_input_type != NULL && ctx->input_structure != NULL
- ? ", " : "";
+ ? ", "
+ : "";
const char *input_type
= ctx->start_input_type != NULL ? ctx->start_input_type : "";
const char *input_structure
@@ -100,9 +102,9 @@ int OSSL_DECODER_from_bio(OSSL_DECODER_CTX *ctx, BIO *in)
if (ERR_peek_last_error() == lasterr || ERR_peek_error() == 0)
/* Prevent spurious decoding error but add at least something */
ERR_raise_data(ERR_LIB_OSSL_DECODER, ERR_R_UNSUPPORTED,
- "No supported data to decode. %s%s%s%s%s%s",
- spaces, input_type_label, input_type, comma,
- input_structure_label, input_structure);
+ "No supported data to decode. %s%s%s%s%s%s",
+ spaces, input_type_label, input_type, comma,
+ input_structure_label, input_structure);
ok = 0;
}
@@ -143,7 +145,7 @@ int OSSL_DECODER_from_fp(OSSL_DECODER_CTX *ctx, FILE *fp)
#endif
int OSSL_DECODER_from_data(OSSL_DECODER_CTX *ctx, const unsigned char **pdata,
- size_t *pdata_len)
+ size_t *pdata_len)
{
BIO *membio;
int ret = 0;
@@ -179,7 +181,7 @@ int OSSL_DECODER_CTX_set_selection(OSSL_DECODER_CTX *ctx, int selection)
}
int OSSL_DECODER_CTX_set_input_type(OSSL_DECODER_CTX *ctx,
- const char *input_type)
+ const char *input_type)
{
if (!ossl_assert(ctx != NULL)) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER);
@@ -195,7 +197,7 @@ int OSSL_DECODER_CTX_set_input_type(OSSL_DECODER_CTX *ctx,
}
int OSSL_DECODER_CTX_set_input_structure(OSSL_DECODER_CTX *ctx,
- const char *input_structure)
+ const char *input_structure)
{
if (!ossl_assert(ctx != NULL)) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER);
@@ -212,7 +214,7 @@ int OSSL_DECODER_CTX_set_input_structure(OSSL_DECODER_CTX *ctx,
OSSL_DECODER_INSTANCE *
ossl_decoder_instance_new_forprov(OSSL_DECODER *decoder, void *provctx,
- const char *input_structure)
+ const char *input_structure)
{
void *decoderctx;
@@ -227,9 +229,8 @@ ossl_decoder_instance_new_forprov(OSSL_DECODER *decoder, void *provctx,
if (input_structure != NULL && decoder->set_ctx_params != NULL) {
OSSL_PARAM params[] = { OSSL_PARAM_END, OSSL_PARAM_END };
- params[0] =
- OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_STRUCTURE,
- (char *)input_structure, 0);
+ params[0] = OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_STRUCTURE,
+ (char *)input_structure, 0);
if (!decoder->set_ctx_params(decoderctx, params)) {
decoder->freectx(decoderctx);
return 0;
@@ -239,7 +240,7 @@ ossl_decoder_instance_new_forprov(OSSL_DECODER *decoder, void *provctx,
}
OSSL_DECODER_INSTANCE *ossl_decoder_instance_new(OSSL_DECODER *decoder,
- void *decoderctx)
+ void *decoderctx)
{
OSSL_DECODER_INSTANCE *decoder_inst = NULL;
const OSSL_PROVIDER *prov;
@@ -260,8 +261,8 @@ OSSL_DECODER_INSTANCE *ossl_decoder_instance_new(OSSL_DECODER *decoder,
props = ossl_decoder_parsed_properties(decoder);
if (props == NULL) {
ERR_raise_data(ERR_LIB_OSSL_DECODER, ERR_R_INVALID_PROPERTY_DEFINITION,
- "there are no property definitions with decoder %s",
- OSSL_DECODER_get0_name(decoder));
+ "there are no property definitions with decoder %s",
+ OSSL_DECODER_get0_name(decoder));
goto err;
}
@@ -271,10 +272,10 @@ OSSL_DECODER_INSTANCE *ossl_decoder_instance_new(OSSL_DECODER *decoder,
decoder_inst->input_type_id = 0;
if (decoder_inst->input_type == NULL) {
ERR_raise_data(ERR_LIB_OSSL_DECODER, ERR_R_INVALID_PROPERTY_DEFINITION,
- "the mandatory 'input' property is missing "
- "for decoder %s (properties: %s)",
- OSSL_DECODER_get0_name(decoder),
- OSSL_DECODER_get0_properties(decoder));
+ "the mandatory 'input' property is missing "
+ "for decoder %s (properties: %s)",
+ OSSL_DECODER_get0_name(decoder),
+ OSSL_DECODER_get0_properties(decoder));
goto err;
}
@@ -292,7 +293,7 @@ OSSL_DECODER_INSTANCE *ossl_decoder_instance_new(OSSL_DECODER *decoder,
decoder_inst->decoder = decoder;
decoder_inst->decoderctx = decoderctx;
return decoder_inst;
- err:
+err:
ossl_decoder_instance_free(decoder_inst);
return NULL;
}
@@ -335,7 +336,7 @@ OSSL_DECODER_INSTANCE *ossl_decoder_instance_dup(const OSSL_DECODER_INSTANCE *sr
return dest;
- err:
+err:
OPENSSL_free(dest);
return NULL;
}
@@ -351,27 +352,28 @@ int ossl_decoder_ctx_get_harderr(const OSSL_DECODER_CTX *ctx)
}
int ossl_decoder_ctx_add_decoder_inst(OSSL_DECODER_CTX *ctx,
- OSSL_DECODER_INSTANCE *di)
+ OSSL_DECODER_INSTANCE *di)
{
int ok;
if (ctx->decoder_insts == NULL
- && (ctx->decoder_insts =
- sk_OSSL_DECODER_INSTANCE_new_null()) == NULL) {
+ && (ctx->decoder_insts = sk_OSSL_DECODER_INSTANCE_new_null()) == NULL) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_CRYPTO_LIB);
return 0;
}
ok = (sk_OSSL_DECODER_INSTANCE_push(ctx->decoder_insts, di) > 0);
if (ok) {
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) Added decoder instance %p for decoder %p\n"
- " %s with %s\n",
- (void *)ctx, (void *)di, (void *)di->decoder,
- OSSL_DECODER_get0_name(di->decoder),
- OSSL_DECODER_get0_properties(di->decoder));
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) Added decoder instance %p for decoder %p\n"
+ " %s with %s\n",
+ (void *)ctx, (void *)di, (void *)di->decoder,
+ OSSL_DECODER_get0_name(di->decoder),
+ OSSL_DECODER_get0_properties(di->decoder));
+ }
+ OSSL_TRACE_END(DECODER);
}
return ok;
}
@@ -392,8 +394,7 @@ int OSSL_DECODER_CTX_add_decoder(OSSL_DECODER_CTX *ctx, OSSL_DECODER *decoder)
provctx = OSSL_PROVIDER_get0_provider_ctx(prov);
if ((decoderctx = decoder->newctx(provctx)) == NULL
- || (decoder_inst =
- ossl_decoder_instance_new(decoder, decoderctx)) == NULL)
+ || (decoder_inst = ossl_decoder_instance_new(decoder, decoderctx)) == NULL)
goto err;
/* Avoid double free of decoderctx on further errors */
decoderctx = NULL;
@@ -402,7 +403,7 @@ int OSSL_DECODER_CTX_add_decoder(OSSL_DECODER_CTX *ctx, OSSL_DECODER *decoder)
goto err;
return 1;
- err:
+err:
ossl_decoder_instance_free(decoder_inst);
if (decoderctx != NULL)
decoder->freectx(decoderctx);
@@ -418,9 +419,10 @@ struct collect_extra_decoder_data_st {
* 0 to check that the decoder's input type is the same as the decoder name
* 1 to check that the decoder's input type differs from the decoder name
*/
- enum { IS_SAME = 0, IS_DIFFERENT = 1 } type_check;
+ enum { IS_SAME = 0,
+ IS_DIFFERENT = 1 } type_check;
size_t w_prev_start, w_prev_end; /* "previous" decoders */
- size_t w_new_start, w_new_end; /* "new" decoders */
+ size_t w_new_start, w_new_end; /* "new" decoders */
};
DEFINE_STACK_OF(OSSL_DECODER)
@@ -430,7 +432,7 @@ static void collect_all_decoders(OSSL_DECODER *decoder, void *arg)
STACK_OF(OSSL_DECODER) *skdecoders = arg;
if (OSSL_DECODER_up_ref(decoder)
- && !sk_OSSL_DECODER_push(skdecoders, decoder))
+ && !sk_OSSL_DECODER_push(skdecoders, decoder))
OSSL_DECODER_free(decoder);
}
@@ -445,14 +447,16 @@ static void collect_extra_decoder(OSSL_DECODER *decoder, void *arg)
void *decoderctx = NULL;
OSSL_DECODER_INSTANCE *di = NULL;
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) [%d] Checking out decoder %p:\n"
- " %s with %s\n",
- (void *)data->ctx, data->type_check, (void *)decoder,
- OSSL_DECODER_get0_name(decoder),
- OSSL_DECODER_get0_properties(decoder));
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) [%d] Checking out decoder %p:\n"
+ " %s with %s\n",
+ (void *)data->ctx, data->type_check, (void *)decoder,
+ OSSL_DECODER_get0_name(decoder),
+ OSSL_DECODER_get0_properties(decoder));
+ }
+ OSSL_TRACE_END(DECODER);
/*
* Check that we don't already have this decoder in our stack,
@@ -460,15 +464,16 @@ static void collect_extra_decoder(OSSL_DECODER *decoder, void *arg)
* we have added in the current window.
*/
for (j = data->w_prev_start; j < data->w_new_end; j++) {
- OSSL_DECODER_INSTANCE *check_inst =
- sk_OSSL_DECODER_INSTANCE_value(data->ctx->decoder_insts, j);
+ OSSL_DECODER_INSTANCE *check_inst = sk_OSSL_DECODER_INSTANCE_value(data->ctx->decoder_insts, j);
if (decoder->base.algodef == check_inst->decoder->base.algodef) {
/* We found it, so don't do anything more */
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- " REJECTED: already exists in the chain\n");
- } OSSL_TRACE_END(DECODER);
+ " REJECTED: already exists in the chain\n");
+ }
+ OSSL_TRACE_END(DECODER);
return;
}
}
@@ -481,9 +486,8 @@ static void collect_extra_decoder(OSSL_DECODER *decoder, void *arg)
OSSL_PARAM params[] = { OSSL_PARAM_END, OSSL_PARAM_END };
const char *str = data->ctx->input_structure;
- params[0] =
- OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_STRUCTURE,
- (char *)str, 0);
+ params[0] = OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_STRUCTURE,
+ (char *)str, 0);
if (!decoder->set_ctx_params(decoderctx, params)) {
decoder->freectx(decoderctx);
return;
@@ -499,26 +503,30 @@ static void collect_extra_decoder(OSSL_DECODER *decoder, void *arg)
case IS_SAME:
/* If it differs, this is not a decoder to add for now. */
if (!ossl_decoder_fast_is_a(decoder,
- OSSL_DECODER_INSTANCE_get_input_type(di),
- &di->input_type_id)) {
+ OSSL_DECODER_INSTANCE_get_input_type(di),
+ &di->input_type_id)) {
ossl_decoder_instance_free(di);
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- " REJECTED: input type doesn't match output type\n");
- } OSSL_TRACE_END(DECODER);
+ " REJECTED: input type doesn't match output type\n");
+ }
+ OSSL_TRACE_END(DECODER);
return;
}
break;
case IS_DIFFERENT:
/* If it's the same, this is not a decoder to add for now. */
if (ossl_decoder_fast_is_a(decoder,
- OSSL_DECODER_INSTANCE_get_input_type(di),
- &di->input_type_id)) {
+ OSSL_DECODER_INSTANCE_get_input_type(di),
+ &di->input_type_id)) {
ossl_decoder_instance_free(di);
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- " REJECTED: input type matches output type\n");
- } OSSL_TRACE_END(DECODER);
+ " REJECTED: input type matches output type\n");
+ }
+ OSSL_TRACE_END(DECODER);
return;
}
break;
@@ -538,7 +546,7 @@ static void collect_extra_decoder(OSSL_DECODER *decoder, void *arg)
}
static int decoder_sk_cmp(const OSSL_DECODER_INSTANCE *const *a,
- const OSSL_DECODER_INSTANCE *const *b)
+ const OSSL_DECODER_INSTANCE *const *b)
{
if ((*a)->score == (*b)->score)
return (*a)->order - (*b)->order;
@@ -546,7 +554,7 @@ static int decoder_sk_cmp(const OSSL_DECODER_INSTANCE *const *a,
}
int OSSL_DECODER_CTX_add_extra(OSSL_DECODER_CTX *ctx,
- OSSL_LIB_CTX *libctx, const char *propq)
+ OSSL_LIB_CTX *libctx, const char *propq)
{
/*
* This function goes through existing decoder methods in
@@ -589,11 +597,12 @@ int OSSL_DECODER_CTX_add_extra(OSSL_DECODER_CTX *ctx,
if (ctx->decoder_insts == NULL)
return 1;
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out, "(ctx %p) Looking for extra decoders\n",
- (void *)ctx);
- } OSSL_TRACE_END(DECODER);
-
+ (void *)ctx);
+ }
+ OSSL_TRACE_END(DECODER);
skdecoders = sk_OSSL_DECODER_new_null();
if (skdecoders == NULL) {
@@ -612,8 +621,7 @@ int OSSL_DECODER_CTX_add_extra(OSSL_DECODER_CTX *ctx,
int num_decoder_insts = sk_OSSL_DECODER_INSTANCE_num(ctx->decoder_insts);
int i;
OSSL_DECODER_INSTANCE *di;
- sk_OSSL_DECODER_INSTANCE_compfunc old_cmp =
- sk_OSSL_DECODER_INSTANCE_set_cmp_func(ctx->decoder_insts, decoder_sk_cmp);
+ sk_OSSL_DECODER_INSTANCE_compfunc old_cmp = sk_OSSL_DECODER_INSTANCE_set_cmp_func(ctx->decoder_insts, decoder_sk_cmp);
for (i = 0; i < num_decoder_insts; i++) {
di = sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts, i);
@@ -640,11 +648,10 @@ int OSSL_DECODER_CTX_add_extra(OSSL_DECODER_CTX *ctx,
* 1. All decoders that a different name than their input type.
*/
for (data.type_check = IS_SAME;
- data.type_check <= IS_DIFFERENT;
- data.type_check++) {
+ data.type_check <= IS_DIFFERENT;
+ data.type_check++) {
for (i = data.w_prev_start; i < data.w_prev_end; i++) {
- OSSL_DECODER_INSTANCE *decoder_inst =
- sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts, i);
+ OSSL_DECODER_INSTANCE *decoder_inst = sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts, i);
data.output_type
= OSSL_DECODER_INSTANCE_get_input_type(decoder_inst);
@@ -653,7 +660,7 @@ int OSSL_DECODER_CTX_add_extra(OSSL_DECODER_CTX *ctx,
for (j = 0; j < numdecoders; j++)
collect_extra_decoder(sk_OSSL_DECODER_value(skdecoders, j),
- &data);
+ &data);
}
}
/* How many were added in this iteration */
@@ -678,7 +685,7 @@ int OSSL_DECODER_CTX_get_num_decoders(OSSL_DECODER_CTX *ctx)
}
int OSSL_DECODER_CTX_set_construct(OSSL_DECODER_CTX *ctx,
- OSSL_DECODER_CONSTRUCT *construct)
+ OSSL_DECODER_CONSTRUCT *construct)
{
if (!ossl_assert(ctx != NULL)) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER);
@@ -689,7 +696,7 @@ int OSSL_DECODER_CTX_set_construct(OSSL_DECODER_CTX *ctx,
}
int OSSL_DECODER_CTX_set_construct_data(OSSL_DECODER_CTX *ctx,
- void *construct_data)
+ void *construct_data)
{
if (!ossl_assert(ctx != NULL)) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER);
@@ -700,7 +707,7 @@ int OSSL_DECODER_CTX_set_construct_data(OSSL_DECODER_CTX *ctx,
}
int OSSL_DECODER_CTX_set_cleanup(OSSL_DECODER_CTX *ctx,
- OSSL_DECODER_CLEANUP *cleanup)
+ OSSL_DECODER_CLEANUP *cleanup)
{
if (!ossl_assert(ctx != NULL)) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER);
@@ -734,16 +741,16 @@ OSSL_DECODER_CTX_get_cleanup(OSSL_DECODER_CTX *ctx)
}
int OSSL_DECODER_export(OSSL_DECODER_INSTANCE *decoder_inst,
- void *reference, size_t reference_sz,
- OSSL_CALLBACK *export_cb, void *export_cbarg)
+ void *reference, size_t reference_sz,
+ OSSL_CALLBACK *export_cb, void *export_cbarg)
{
OSSL_DECODER *decoder = NULL;
void *decoderctx = NULL;
if (!(ossl_assert(decoder_inst != NULL)
- && ossl_assert(reference != NULL)
- && ossl_assert(export_cb != NULL)
- && ossl_assert(export_cbarg != NULL))) {
+ && ossl_assert(reference != NULL)
+ && ossl_assert(export_cb != NULL)
+ && ossl_assert(export_cbarg != NULL))) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER);
return 0;
}
@@ -751,7 +758,7 @@ int OSSL_DECODER_export(OSSL_DECODER_INSTANCE *decoder_inst,
decoder = OSSL_DECODER_INSTANCE_get_decoder(decoder_inst);
decoderctx = OSSL_DECODER_INSTANCE_get_decoder_ctx(decoder_inst);
return decoder->export_object(decoderctx, reference, reference_sz,
- export_cb, export_cbarg);
+ export_cb, export_cbarg);
}
OSSL_DECODER *
@@ -780,7 +787,7 @@ OSSL_DECODER_INSTANCE_get_input_type(OSSL_DECODER_INSTANCE *decoder_inst)
const char *
OSSL_DECODER_INSTANCE_get_input_structure(OSSL_DECODER_INSTANCE *decoder_inst,
- int *was_set)
+ int *was_set)
{
if (decoder_inst == NULL)
return NULL;
@@ -817,49 +824,53 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
new_data.recursion = data->recursion + 1;
#define LEVEL_STR ">>>>>>>>>>>>>>>>"
-#define LEVEL (new_data.recursion < sizeof(LEVEL_STR) \
- ? &LEVEL_STR[sizeof(LEVEL_STR) - new_data.recursion - 1] \
- : LEVEL_STR "...")
+#define LEVEL (new_data.recursion < sizeof(LEVEL_STR) \
+ ? &LEVEL_STR[sizeof(LEVEL_STR) - new_data.recursion - 1] \
+ : LEVEL_STR "...")
if (params == NULL) {
/* First iteration, where we prepare for what is to come */
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) starting to walk the decoder chain\n",
- (void *)new_data.ctx);
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) starting to walk the decoder chain\n",
+ (void *)new_data.ctx);
+ }
+ OSSL_TRACE_END(DECODER);
- data->current_decoder_inst_index =
- OSSL_DECODER_CTX_get_num_decoders(ctx);
+ data->current_decoder_inst_index = OSSL_DECODER_CTX_get_num_decoders(ctx);
bio = data->bio;
} else {
const OSSL_PARAM *p;
const char *trace_data_structure;
- decoder_inst =
- sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts,
- data->current_decoder_inst_index);
+ decoder_inst = sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts,
+ data->current_decoder_inst_index);
decoder = OSSL_DECODER_INSTANCE_get_decoder(decoder_inst);
data->flag_construct_called = 0;
if (ctx->construct != NULL) {
int rv;
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) %s Running constructor\n",
- (void *)new_data.ctx, LEVEL);
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) %s Running constructor\n",
+ (void *)new_data.ctx, LEVEL);
+ }
+ OSSL_TRACE_END(DECODER);
rv = ctx->construct(decoder_inst, params, ctx->construct_data);
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) %s Running constructor => %d\n",
- (void *)new_data.ctx, LEVEL, rv);
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) %s Running constructor => %d\n",
+ (void *)new_data.ctx, LEVEL, rv);
+ }
+ OSSL_TRACE_END(DECODER);
ok = (rv > 0);
if (ok) {
@@ -929,15 +940,18 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
&& OPENSSL_strcasecmp(data_structure, "type-specific") == 0)
data_structure = NULL;
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) %s incoming from previous decoder (%p):\n"
- " data type: %s, data structure: %s%s\n",
- (void *)new_data.ctx, LEVEL, (void *)decoder,
- data_type, trace_data_structure,
- (trace_data_structure == data_structure
- ? "" : " (dropped)"));
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) %s incoming from previous decoder (%p):\n"
+ " data type: %s, data structure: %s%s\n",
+ (void *)new_data.ctx, LEVEL, (void *)decoder,
+ data_type, trace_data_structure,
+ (trace_data_structure == data_structure
+ ? ""
+ : " (dropped)"));
+ }
+ OSSL_TRACE_END(DECODER);
}
/*
@@ -958,30 +972,27 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
}
for (i = data->current_decoder_inst_index; i-- > 0;) {
- OSSL_DECODER_INSTANCE *new_decoder_inst =
- sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts, i);
- OSSL_DECODER *new_decoder =
- OSSL_DECODER_INSTANCE_get_decoder(new_decoder_inst);
+ OSSL_DECODER_INSTANCE *new_decoder_inst = sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts, i);
+ OSSL_DECODER *new_decoder = OSSL_DECODER_INSTANCE_get_decoder(new_decoder_inst);
const char *new_decoder_name = NULL;
- void *new_decoderctx =
- OSSL_DECODER_INSTANCE_get_decoder_ctx(new_decoder_inst);
- const char *new_input_type =
- OSSL_DECODER_INSTANCE_get_input_type(new_decoder_inst);
- int n_i_s_was_set = 0; /* We don't care here */
- const char *new_input_structure =
- OSSL_DECODER_INSTANCE_get_input_structure(new_decoder_inst,
- &n_i_s_was_set);
+ void *new_decoderctx = OSSL_DECODER_INSTANCE_get_decoder_ctx(new_decoder_inst);
+ const char *new_input_type = OSSL_DECODER_INSTANCE_get_input_type(new_decoder_inst);
+ int n_i_s_was_set = 0; /* We don't care here */
+ const char *new_input_structure = OSSL_DECODER_INSTANCE_get_input_structure(new_decoder_inst,
+ &n_i_s_was_set);
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
new_decoder_name = OSSL_DECODER_get0_name(new_decoder);
BIO_printf(trc_out,
- "(ctx %p) %s [%u] Considering decoder instance %p (decoder %p):\n"
- " %s with %s\n",
- (void *)new_data.ctx, LEVEL, (unsigned int)i,
- (void *)new_decoder_inst, (void *)new_decoder,
- new_decoder_name,
- OSSL_DECODER_get0_properties(new_decoder));
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) %s [%u] Considering decoder instance %p (decoder %p):\n"
+ " %s with %s\n",
+ (void *)new_data.ctx, LEVEL, (unsigned int)i,
+ (void *)new_decoder_inst, (void *)new_decoder,
+ new_decoder_name,
+ OSSL_DECODER_get0_properties(new_decoder));
+ }
+ OSSL_TRACE_END(DECODER);
/*
* If |decoder| is NULL, it means we've just started, and the caller
@@ -990,12 +1001,14 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
*/
if (decoder == NULL && ctx->start_input_type != NULL
&& OPENSSL_strcasecmp(ctx->start_input_type, new_input_type) != 0) {
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) %s [%u] the start input type '%s' doesn't match the input type of the considered decoder, skipping...\n",
- (void *)new_data.ctx, LEVEL, (unsigned int)i,
- ctx->start_input_type);
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) %s [%u] the start input type '%s' doesn't match the input type of the considered decoder, skipping...\n",
+ (void *)new_data.ctx, LEVEL, (unsigned int)i,
+ ctx->start_input_type);
+ }
+ OSSL_TRACE_END(DECODER);
continue;
}
@@ -1005,14 +1018,15 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
* |new_input_type| holds the value of the "input-type" parameter
* for the decoder we're currently considering.
*/
- if (decoder != NULL && !ossl_decoder_fast_is_a(decoder, new_input_type,
- &new_decoder_inst->input_type_id)) {
- OSSL_TRACE_BEGIN(DECODER) {
+ if (decoder != NULL && !ossl_decoder_fast_is_a(decoder, new_input_type, &new_decoder_inst->input_type_id)) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) %s [%u] the input type doesn't match the name of the previous decoder (%p), skipping...\n",
- (void *)new_data.ctx, LEVEL, (unsigned int)i,
- (void *)decoder);
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) %s [%u] the input type doesn't match the name of the previous decoder (%p), skipping...\n",
+ (void *)new_data.ctx, LEVEL, (unsigned int)i,
+ (void *)decoder);
+ }
+ OSSL_TRACE_END(DECODER);
continue;
}
@@ -1021,11 +1035,13 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
* if that matches the decoder we're currently considering.
*/
if (data_type != NULL && !OSSL_DECODER_is_a(new_decoder, data_type)) {
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) %s [%u] the previous decoder's data type doesn't match the name of the considered decoder, skipping...\n",
- (void *)new_data.ctx, LEVEL, (unsigned int)i);
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) %s [%u] the previous decoder's data type doesn't match the name of the considered decoder, skipping...\n",
+ (void *)new_data.ctx, LEVEL, (unsigned int)i);
+ }
+ OSSL_TRACE_END(DECODER);
continue;
}
@@ -1037,12 +1053,15 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
if (data_structure != NULL
&& (new_input_structure == NULL
|| OPENSSL_strcasecmp(data_structure,
- new_input_structure) != 0)) {
- OSSL_TRACE_BEGIN(DECODER) {
+ new_input_structure)
+ != 0)) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) %s [%u] the previous decoder's data structure doesn't match the input structure of the considered decoder, skipping...\n",
- (void *)new_data.ctx, LEVEL, (unsigned int)i);
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) %s [%u] the previous decoder's data structure doesn't match the input structure of the considered decoder, skipping...\n",
+ (void *)new_data.ctx, LEVEL, (unsigned int)i);
+ }
+ OSSL_TRACE_END(DECODER);
continue;
}
@@ -1057,12 +1076,15 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
&& new_input_structure != NULL) {
data->flag_input_structure_checked = 1;
if (OPENSSL_strcasecmp(new_input_structure,
- ctx->input_structure) != 0) {
- OSSL_TRACE_BEGIN(DECODER) {
+ ctx->input_structure)
+ != 0) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) %s [%u] the previous decoder's data structure doesn't match the input structure given by the user, skipping...\n",
- (void *)new_data.ctx, LEVEL, (unsigned int)i);
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) %s [%u] the previous decoder's data structure doesn't match the input structure given by the user, skipping...\n",
+ (void *)new_data.ctx, LEVEL, (unsigned int)i);
+ }
+ OSSL_TRACE_END(DECODER);
continue;
}
}
@@ -1082,12 +1104,14 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
goto end;
/* Recurse */
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) %s [%u] Running decoder instance %s (%p)\n",
- (void *)new_data.ctx, LEVEL, (unsigned int)i,
- new_decoder_name, (void *)new_decoder_inst);
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) %s [%u] Running decoder instance %s (%p)\n",
+ (void *)new_data.ctx, LEVEL, (unsigned int)i,
+ new_decoder_name, (void *)new_decoder_inst);
+ }
+ OSSL_TRACE_END(DECODER);
/*
* We only care about errors reported from decoder implementations
@@ -1099,20 +1123,22 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
new_data.flag_input_structure_checked
= data->flag_input_structure_checked;
ok = new_decoder->decode(new_decoderctx, cbio,
- new_data.ctx->selection,
- decoder_process, &new_data,
- ossl_pw_passphrase_callback_dec,
- &new_data.ctx->pwdata);
+ new_data.ctx->selection,
+ decoder_process, &new_data,
+ ossl_pw_passphrase_callback_dec,
+ &new_data.ctx->pwdata);
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) %s [%u] Running decoder instance %s (%p) => %d"
- " (recursed further: %s, construct called: %s)\n",
- (void *)new_data.ctx, LEVEL, (unsigned int)i,
- new_decoder_name, (void *)new_decoder_inst, ok,
- new_data.flag_next_level_called ? "yes" : "no",
- new_data.flag_construct_called ? "yes" : "no");
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) %s [%u] Running decoder instance %s (%p) => %d"
+ " (recursed further: %s, construct called: %s)\n",
+ (void *)new_data.ctx, LEVEL, (unsigned int)i,
+ new_decoder_name, (void *)new_decoder_inst, ok,
+ new_data.flag_next_level_called ? "yes" : "no",
+ new_data.flag_construct_called ? "yes" : "no");
+ }
+ OSSL_TRACE_END(DECODER);
data->flag_construct_called = new_data.flag_construct_called;
@@ -1131,7 +1157,7 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
break;
}
- end:
+end:
ossl_core_bio_free(cbio);
BIO_free(new_data.bio);
ctx->start_input_type = start_input_type;
diff --git a/crypto/encode_decode/decoder_meth.c b/crypto/encode_decode/decoder_meth.c
index 85ab3b528673..110581f764f7 100644
--- a/crypto/encode_decode/decoder_meth.c
+++ b/crypto/encode_decode/decoder_meth.c
@@ -77,9 +77,9 @@ void OSSL_DECODER_free(OSSL_DECODER *decoder)
/* Data to be passed through ossl_method_construct() */
struct decoder_data_st {
OSSL_LIB_CTX *libctx;
- int id; /* For get_decoder_from_store() */
- const char *names; /* For get_decoder_from_store() */
- const char *propquery; /* For get_decoder_from_store() */
+ int id; /* For get_decoder_from_store() */
+ const char *names; /* For get_decoder_from_store() */
+ const char *propquery; /* For get_decoder_from_store() */
OSSL_METHOD_STORE *tmp_store; /* For get_tmp_decoder_store() */
@@ -137,7 +137,7 @@ static int unreserve_decoder_store(void *store, void *data)
/* Get decoder methods from a store, or put one in */
static void *get_decoder_from_store(void *store, const OSSL_PROVIDER **prov,
- void *data)
+ void *data)
{
struct decoder_data_st *methdata = data;
void *method = NULL;
@@ -172,9 +172,9 @@ static void *get_decoder_from_store(void *store, const OSSL_PROVIDER **prov,
}
static int put_decoder_in_store(void *store, void *method,
- const OSSL_PROVIDER *prov,
- const char *names, const char *propdef,
- void *data)
+ const OSSL_PROVIDER *prov,
+ const char *names, const char *propdef,
+ void *data)
{
struct decoder_data_st *methdata = data;
OSSL_NAMEMAP *namemap;
@@ -201,13 +201,13 @@ static int put_decoder_in_store(void *store, void *method,
return 0;
return ossl_method_store_add(store, prov, id, propdef, method,
- ossl_decoder_up_ref,
- ossl_decoder_free);
+ ossl_decoder_up_ref,
+ ossl_decoder_free);
}
/* Create and populate a decoder method */
void *ossl_decoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef,
- OSSL_PROVIDER *prov)
+ OSSL_PROVIDER *prov)
{
OSSL_DECODER *decoder = NULL;
const OSSL_DISPATCH *fns = algodef->implementation;
@@ -222,7 +222,8 @@ void *ossl_decoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef,
}
decoder->base.algodef = algodef;
if ((decoder->base.parsed_propdef
- = ossl_parse_property(libctx, algodef->property_definition)) == NULL) {
+ = ossl_parse_property(libctx, algodef->property_definition))
+ == NULL) {
OSSL_DECODER_free(decoder);
return NULL;
}
@@ -239,28 +240,23 @@ void *ossl_decoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef,
break;
case OSSL_FUNC_DECODER_GET_PARAMS:
if (decoder->get_params == NULL)
- decoder->get_params =
- OSSL_FUNC_decoder_get_params(fns);
+ decoder->get_params = OSSL_FUNC_decoder_get_params(fns);
break;
case OSSL_FUNC_DECODER_GETTABLE_PARAMS:
if (decoder->gettable_params == NULL)
- decoder->gettable_params =
- OSSL_FUNC_decoder_gettable_params(fns);
+ decoder->gettable_params = OSSL_FUNC_decoder_gettable_params(fns);
break;
case OSSL_FUNC_DECODER_SET_CTX_PARAMS:
if (decoder->set_ctx_params == NULL)
- decoder->set_ctx_params =
- OSSL_FUNC_decoder_set_ctx_params(fns);
+ decoder->set_ctx_params = OSSL_FUNC_decoder_set_ctx_params(fns);
break;
case OSSL_FUNC_DECODER_SETTABLE_CTX_PARAMS:
if (decoder->settable_ctx_params == NULL)
- decoder->settable_ctx_params =
- OSSL_FUNC_decoder_settable_ctx_params(fns);
+ decoder->settable_ctx_params = OSSL_FUNC_decoder_settable_ctx_params(fns);
break;
case OSSL_FUNC_DECODER_DOES_SELECTION:
if (decoder->does_selection == NULL)
- decoder->does_selection =
- OSSL_FUNC_decoder_does_selection(fns);
+ decoder->does_selection = OSSL_FUNC_decoder_does_selection(fns);
break;
case OSSL_FUNC_DECODER_DECODE:
if (decoder->decode == NULL)
@@ -278,7 +274,7 @@ void *ossl_decoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef,
* You must have at least one of the encoding driver functions.
*/
if (!((decoder->newctx == NULL && decoder->freectx == NULL)
- || (decoder->newctx != NULL && decoder->freectx != NULL))
+ || (decoder->newctx != NULL && decoder->freectx != NULL))
|| decoder->decode == NULL) {
OSSL_DECODER_free(decoder);
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_INVALID_PROVIDER_FUNCTIONS);
@@ -294,14 +290,13 @@ void *ossl_decoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef,
return decoder;
}
-
/*
* The core fetching functionality passes the names of the implementation.
* This function is responsible to getting an identity number for them,
* then call ossl_decoder_from_algorithm() with that identity number.
*/
static void *construct_decoder(const OSSL_ALGORITHM *algodef,
- OSSL_PROVIDER *prov, void *data)
+ OSSL_PROVIDER *prov, void *data)
{
/*
* This function is only called if get_decoder_from_store() returned
@@ -349,7 +344,7 @@ static void free_decoder(void *method)
/* Fetching support. Can fetch by numeric identity or by name */
static OSSL_DECODER *
inner_ossl_decoder_fetch(struct decoder_data_st *methdata,
- const char *name, const char *properties)
+ const char *name, const char *properties)
{
OSSL_METHOD_STORE *store = get_decoder_store(methdata->libctx);
OSSL_NAMEMAP *namemap = ossl_namemap_stored(methdata->libctx);
@@ -388,8 +383,9 @@ inner_ossl_decoder_fetch(struct decoder_data_st *methdata,
methdata->propquery = propq;
methdata->flag_construct_error_occurred = 0;
if ((method = ossl_method_construct(methdata->libctx, OSSL_OP_DECODER,
- &prov, 0 /* !force_cache */,
- &mcm, methdata)) != NULL) {
+ &prov, 0 /* !force_cache */,
+ &mcm, methdata))
+ != NULL) {
/*
* If construction did create a method for us, we know that
* there is a correct name_id and meth_id, since those have
@@ -400,7 +396,7 @@ inner_ossl_decoder_fetch(struct decoder_data_st *methdata,
id = ossl_namemap_name2num(namemap, name);
if (id != 0)
ossl_method_store_cache_set(store, prov, id, propq, method,
- up_ref_decoder, free_decoder);
+ up_ref_decoder, free_decoder);
}
/*
@@ -416,17 +412,17 @@ inner_ossl_decoder_fetch(struct decoder_data_st *methdata,
if (name == NULL)
name = ossl_namemap_num2name(namemap, id, 0);
ERR_raise_data(ERR_LIB_OSSL_DECODER, code,
- "%s, Name (%s : %d), Properties (%s)",
- ossl_lib_ctx_get_descriptor(methdata->libctx),
- name == NULL ? "<null>" : name, id,
- properties == NULL ? "<null>" : properties);
+ "%s, Name (%s : %d), Properties (%s)",
+ ossl_lib_ctx_get_descriptor(methdata->libctx),
+ name == NULL ? "<null>" : name, id,
+ properties == NULL ? "<null>" : properties);
}
return method;
}
OSSL_DECODER *OSSL_DECODER_fetch(OSSL_LIB_CTX *libctx, const char *name,
- const char *properties)
+ const char *properties)
{
struct decoder_data_st methdata;
void *method;
@@ -554,9 +550,9 @@ static void do_one(ossl_unused int id, void *method, void *arg)
}
void OSSL_DECODER_do_all_provided(OSSL_LIB_CTX *libctx,
- void (*user_fn)(OSSL_DECODER *decoder,
- void *arg),
- void *user_arg)
+ void (*user_fn)(OSSL_DECODER *decoder,
+ void *arg),
+ void *user_arg)
{
struct decoder_data_st methdata;
struct do_one_data_st data;
@@ -574,8 +570,8 @@ void OSSL_DECODER_do_all_provided(OSSL_LIB_CTX *libctx,
}
int OSSL_DECODER_names_do_all(const OSSL_DECODER *decoder,
- void (*fn)(const char *name, void *data),
- void *data)
+ void (*fn)(const char *name, void *data),
+ void *data)
{
if (decoder == NULL)
return 0;
@@ -638,7 +634,7 @@ OSSL_DECODER_CTX *OSSL_DECODER_CTX_new(void)
}
int OSSL_DECODER_CTX_set_params(OSSL_DECODER_CTX *ctx,
- const OSSL_PARAM params[])
+ const OSSL_PARAM params[])
{
int ok = 1;
size_t i;
@@ -654,12 +650,9 @@ int OSSL_DECODER_CTX_set_params(OSSL_DECODER_CTX *ctx,
l = OSSL_DECODER_CTX_get_num_decoders(ctx);
for (i = 0; i < l; i++) {
- OSSL_DECODER_INSTANCE *decoder_inst =
- sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts, i);
- OSSL_DECODER *decoder =
- OSSL_DECODER_INSTANCE_get_decoder(decoder_inst);
- OSSL_DECODER *decoderctx =
- OSSL_DECODER_INSTANCE_get_decoder_ctx(decoder_inst);
+ OSSL_DECODER_INSTANCE *decoder_inst = sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts, i);
+ OSSL_DECODER *decoder = OSSL_DECODER_INSTANCE_get_decoder(decoder_inst);
+ OSSL_DECODER *decoderctx = OSSL_DECODER_INSTANCE_get_decoder_ctx(decoder_inst);
if (decoderctx == NULL || decoder->set_ctx_params == NULL)
continue;
@@ -675,7 +668,7 @@ void OSSL_DECODER_CTX_free(OSSL_DECODER_CTX *ctx)
if (ctx->cleanup != NULL)
ctx->cleanup(ctx->construct_data);
sk_OSSL_DECODER_INSTANCE_pop_free(ctx->decoder_insts,
- ossl_decoder_instance_free);
+ ossl_decoder_instance_free);
ossl_pw_clear_passphrase_data(&ctx->pwdata);
OPENSSL_free(ctx);
}
diff --git a/crypto/encode_decode/decoder_pkey.c b/crypto/encode_decode/decoder_pkey.c
index 9fc4e2312331..a578e6a13532 100644
--- a/crypto/encode_decode/decoder_pkey.c
+++ b/crypto/encode_decode/decoder_pkey.c
@@ -24,28 +24,28 @@
#include "internal/sizes.h"
int OSSL_DECODER_CTX_set_passphrase(OSSL_DECODER_CTX *ctx,
- const unsigned char *kstr,
- size_t klen)
+ const unsigned char *kstr,
+ size_t klen)
{
return ossl_pw_set_passphrase(&ctx->pwdata, kstr, klen);
}
int OSSL_DECODER_CTX_set_passphrase_ui(OSSL_DECODER_CTX *ctx,
- const UI_METHOD *ui_method,
- void *ui_data)
+ const UI_METHOD *ui_method,
+ void *ui_data)
{
return ossl_pw_set_ui_method(&ctx->pwdata, ui_method, ui_data);
}
int OSSL_DECODER_CTX_set_pem_password_cb(OSSL_DECODER_CTX *ctx,
- pem_password_cb *cb, void *cbarg)
+ pem_password_cb *cb, void *cbarg)
{
return ossl_pw_set_pem_password_cb(&ctx->pwdata, cb, cbarg);
}
int OSSL_DECODER_CTX_set_passphrase_cb(OSSL_DECODER_CTX *ctx,
- OSSL_PASSPHRASE_CALLBACK *cb,
- void *cbarg)
+ OSSL_PASSPHRASE_CALLBACK *cb,
+ void *cbarg)
{
return ossl_pw_set_ossl_passphrase_cb(&ctx->pwdata, cb, cbarg);
}
@@ -63,14 +63,14 @@ struct decoder_pkey_data_st {
int selection;
STACK_OF(EVP_KEYMGMT) *keymgmts;
- char *object_type; /* recorded object data type, may be NULL */
- void **object; /* Where the result should end up */
- OSSL_DECODER_CTX *ctx; /* The parent decoder context */
+ char *object_type; /* recorded object data type, may be NULL */
+ void **object; /* Where the result should end up */
+ OSSL_DECODER_CTX *ctx; /* The parent decoder context */
};
static int decoder_construct_pkey(OSSL_DECODER_INSTANCE *decoder_inst,
- const OSSL_PARAM *params,
- void *construct_data)
+ const OSSL_PARAM *params,
+ void *construct_data)
{
struct decoder_pkey_data_st *data = construct_data;
OSSL_DECODER *decoder = OSSL_DECODER_INSTANCE_get_decoder(decoder_inst);
@@ -131,8 +131,9 @@ static int decoder_construct_pkey(OSSL_DECODER_INSTANCE *decoder_inst,
if (!EVP_KEYMGMT_up_ref(keymgmt))
return 0;
} else if ((keymgmt = EVP_KEYMGMT_fetch(data->libctx,
- data->object_type,
- data->propq)) != NULL) {
+ data->object_type,
+ data->propq))
+ != NULL) {
keymgmt_prov = EVP_KEYMGMT_get0_provider(keymgmt);
}
@@ -166,9 +167,9 @@ static int decoder_construct_pkey(OSSL_DECODER_INSTANCE *decoder_inst,
* |import_data.keydata| is as much an indicator.
*/
(void)decoder->export_object(decoderctx,
- object_ref, object_ref_sz,
- &evp_keymgmt_util_try_import,
- &import_data);
+ object_ref, object_ref_sz,
+ &evp_keymgmt_util_try_import,
+ &import_data);
keydata = import_data.keydata;
import_data.keydata = NULL;
}
@@ -218,8 +219,8 @@ struct collect_data_st {
const char *keytype; /* the keytype requested, if any */
int keytype_id; /* if keytype_resolved is set, keymgmt name_id; else 0 */
- int sm2_id; /* if keytype_resolved is set and EC, SM2 name_id; else 0 */
- int total; /* number of matching results */
+ int sm2_id; /* if keytype_resolved is set and EC, SM2 name_id; else 0 */
+ int total; /* number of matching results */
char error_occurred;
char keytype_resolved;
OSSL_PROPERTY_LIST *pq;
@@ -232,7 +233,7 @@ struct collect_data_st {
* if a decoder was added, 0 otherwise.
*/
static int collect_decoder_keymgmt(EVP_KEYMGMT *keymgmt, OSSL_DECODER *decoder,
- void *provctx, struct collect_data_st *data)
+ void *provctx, struct collect_data_st *data)
{
void *decoderctx = NULL;
OSSL_DECODER_INSTANCE *di = NULL;
@@ -272,14 +273,16 @@ static int collect_decoder_keymgmt(EVP_KEYMGMT *keymgmt, OSSL_DECODER *decoder,
return 0;
}
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) Checking out decoder %p:\n"
- " %s with %s\n",
- (void *)data->ctx, (void *)decoder,
- OSSL_DECODER_get0_name(decoder),
- OSSL_DECODER_get0_properties(decoder));
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) Checking out decoder %p:\n"
+ " %s with %s\n",
+ (void *)data->ctx, (void *)decoder,
+ OSSL_DECODER_get0_name(decoder),
+ OSSL_DECODER_get0_properties(decoder));
+ }
+ OSSL_TRACE_END(DECODER);
/*
* Get the property match score so the decoders can be prioritized later.
@@ -328,17 +331,19 @@ static void collect_decoder(OSSL_DECODER *decoder, void *arg)
* doesn't have |does_selection|, it's seen as taking anything.
*/
if (decoder->does_selection != NULL
- && !decoder->does_selection(provctx, data->ctx->selection))
+ && !decoder->does_selection(provctx, data->ctx->selection))
return;
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) Checking out decoder %p:\n"
- " %s with %s\n",
- (void *)data->ctx, (void *)decoder,
- OSSL_DECODER_get0_name(decoder),
- OSSL_DECODER_get0_properties(decoder));
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) Checking out decoder %p:\n"
+ " %s with %s\n",
+ (void *)data->ctx, (void *)decoder,
+ OSSL_DECODER_get0_name(decoder),
+ OSSL_DECODER_get0_properties(decoder));
+ }
+ OSSL_TRACE_END(DECODER);
end_i = sk_EVP_KEYMGMT_num(keymgmts);
for (i = 0; i < end_i; ++i) {
@@ -424,9 +429,9 @@ static void collect_keymgmt(EVP_KEYMGMT *keymgmt, void *arg)
* etc. If 'keytype' is NULL, decoders for all keytypes are bound.
*/
static int ossl_decoder_ctx_setup_for_pkey(OSSL_DECODER_CTX *ctx,
- const char *keytype,
- OSSL_LIB_CTX *libctx,
- const char *propquery)
+ const char *keytype,
+ OSSL_LIB_CTX *libctx,
+ const char *propquery)
{
int ok = 0;
struct decoder_pkey_data_st *process_data = NULL;
@@ -435,20 +440,22 @@ static int ossl_decoder_ctx_setup_for_pkey(OSSL_DECODER_CTX *ctx,
OSSL_PROPERTY_LIST **plp;
OSSL_PROPERTY_LIST *pq = NULL, *p2 = NULL;
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
const char *input_type = ctx->start_input_type;
const char *input_structure = ctx->input_structure;
BIO_printf(trc_out,
- "(ctx %p) Looking for decoders producing %s%s%s%s%s%s\n",
- (void *)ctx,
- keytype != NULL ? keytype : "",
- keytype != NULL ? " keys" : "keys of any type",
- input_type != NULL ? " from " : "",
- input_type != NULL ? input_type : "",
- input_structure != NULL ? " with " : "",
- input_structure != NULL ? input_structure : "");
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) Looking for decoders producing %s%s%s%s%s%s\n",
+ (void *)ctx,
+ keytype != NULL ? keytype : "",
+ keytype != NULL ? " keys" : "keys of any type",
+ input_type != NULL ? " from " : "",
+ input_type != NULL ? input_type : "",
+ input_structure != NULL ? " with " : "",
+ input_structure != NULL ? input_structure : "");
+ }
+ OSSL_TRACE_END(DECODER);
/* Allocate data. */
if ((process_data = OPENSSL_zalloc(sizeof(*process_data))) == NULL)
@@ -464,10 +471,10 @@ static int ossl_decoder_ctx_setup_for_pkey(OSSL_DECODER_CTX *ctx,
goto err;
}
- process_data->object = NULL;
- process_data->libctx = libctx;
+ process_data->object = NULL;
+ process_data->libctx = libctx;
process_data->selection = ctx->selection;
- process_data->keymgmts = keymgmts;
+ process_data->keymgmts = keymgmts;
/*
* Collect passed and default properties to prioritize the decoders.
@@ -503,11 +510,11 @@ static int ossl_decoder_ctx_setup_for_pkey(OSSL_DECODER_CTX *ctx,
* upfront, as this ensures that the names for all loaded providers have
* been registered by the time we try to resolve the keytype string.
*/
- collect_data.ctx = ctx;
- collect_data.libctx = libctx;
- collect_data.keymgmts = keymgmts;
- collect_data.keytype = keytype;
- collect_data.pq = pq;
+ collect_data.ctx = ctx;
+ collect_data.libctx = libctx;
+ collect_data.keymgmts = keymgmts;
+ collect_data.keytype = keytype;
+ collect_data.pq = pq;
EVP_KEYMGMT_do_all_provided(libctx, collect_keymgmt, &collect_data);
if (collect_data.error_occurred)
@@ -519,11 +526,13 @@ static int ossl_decoder_ctx_setup_for_pkey(OSSL_DECODER_CTX *ctx,
if (collect_data.error_occurred)
goto err;
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) Got %d decoders producing keys\n",
- (void *)ctx, collect_data.total);
- } OSSL_TRACE_END(DECODER);
+ "(ctx %p) Got %d decoders producing keys\n",
+ (void *)ctx, collect_data.total);
+ }
+ OSSL_TRACE_END(DECODER);
/*
* Finish initializing the decoder context. If one or more decoders matched
@@ -534,14 +543,14 @@ static int ossl_decoder_ctx_setup_for_pkey(OSSL_DECODER_CTX *ctx,
if (!OSSL_DECODER_CTX_set_construct(ctx, decoder_construct_pkey)
|| !OSSL_DECODER_CTX_set_construct_data(ctx, process_data)
|| !OSSL_DECODER_CTX_set_cleanup(ctx,
- decoder_clean_pkey_construct_arg))
+ decoder_clean_pkey_construct_arg))
goto err;
process_data = NULL; /* Avoid it being freed */
}
ok = 1;
- err:
+err:
decoder_clean_pkey_construct_arg(process_data);
ossl_property_free(p2);
return ok;
@@ -564,9 +573,9 @@ static EVP_KEYMGMT *keymgmt_dup(const EVP_KEYMGMT *keymgmt)
*/
static OSSL_DECODER_CTX *
ossl_decoder_ctx_for_pkey_dup(OSSL_DECODER_CTX *src,
- EVP_PKEY **pkey,
- const char *input_type,
- const char *input_structure)
+ EVP_PKEY **pkey,
+ const char *input_type,
+ const char *input_structure)
{
OSSL_DECODER_CTX *dest;
struct decoder_pkey_data_st *process_data_src, *process_data_dest = NULL;
@@ -580,7 +589,7 @@ ossl_decoder_ctx_for_pkey_dup(OSSL_DECODER_CTX *src,
}
if (!OSSL_DECODER_CTX_set_input_type(dest, input_type)
- || !OSSL_DECODER_CTX_set_input_structure(dest, input_structure)) {
+ || !OSSL_DECODER_CTX_set_input_structure(dest, input_structure)) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_OSSL_DECODER_LIB);
goto err;
}
@@ -589,8 +598,8 @@ ossl_decoder_ctx_for_pkey_dup(OSSL_DECODER_CTX *src,
if (src->decoder_insts != NULL) {
dest->decoder_insts
= sk_OSSL_DECODER_INSTANCE_deep_copy(src->decoder_insts,
- ossl_decoder_instance_dup,
- ossl_decoder_instance_free);
+ ossl_decoder_instance_dup,
+ ossl_decoder_instance_free);
if (dest->decoder_insts == NULL) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_OSSL_DECODER_LIB);
goto err;
@@ -598,7 +607,7 @@ ossl_decoder_ctx_for_pkey_dup(OSSL_DECODER_CTX *src,
}
if (!OSSL_DECODER_CTX_set_construct(dest,
- OSSL_DECODER_CTX_get_construct(src))) {
+ OSSL_DECODER_CTX_get_construct(src))) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_OSSL_DECODER_LIB);
goto err;
}
@@ -621,18 +630,18 @@ ossl_decoder_ctx_for_pkey_dup(OSSL_DECODER_CTX *src,
if (process_data_src->keymgmts != NULL) {
process_data_dest->keymgmts
= sk_EVP_KEYMGMT_deep_copy(process_data_src->keymgmts,
- keymgmt_dup,
- EVP_KEYMGMT_free);
+ keymgmt_dup,
+ EVP_KEYMGMT_free);
if (process_data_dest->keymgmts == NULL) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_EVP_LIB);
goto err;
}
}
- process_data_dest->object = (void **)pkey;
- process_data_dest->libctx = process_data_src->libctx;
+ process_data_dest->object = (void **)pkey;
+ process_data_dest->libctx = process_data_src->libctx;
process_data_dest->selection = process_data_src->selection;
- process_data_dest->ctx = dest;
+ process_data_dest->ctx = dest;
if (!OSSL_DECODER_CTX_set_construct_data(dest, process_data_dest)) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_OSSL_DECODER_LIB);
goto err;
@@ -641,13 +650,13 @@ ossl_decoder_ctx_for_pkey_dup(OSSL_DECODER_CTX *src,
}
if (!OSSL_DECODER_CTX_set_cleanup(dest,
- OSSL_DECODER_CTX_get_cleanup(src))) {
+ OSSL_DECODER_CTX_get_cleanup(src))) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_OSSL_DECODER_LIB);
goto err;
}
return dest;
- err:
+err:
decoder_clean_pkey_construct_arg(process_data_dest);
OSSL_DECODER_CTX_free(dest);
return NULL;
@@ -686,17 +695,21 @@ static unsigned long decoder_cache_entry_hash(const DECODER_CACHE_ENTRY *cache)
unsigned long hash = 17;
hash = (hash * 23)
- + (cache->propquery == NULL
- ? 0 : ossl_lh_strcasehash(cache->propquery));
+ + (cache->propquery == NULL
+ ? 0
+ : ossl_lh_strcasehash(cache->propquery));
hash = (hash * 23)
- + (cache->input_structure == NULL
- ? 0 : ossl_lh_strcasehash(cache->input_structure));
+ + (cache->input_structure == NULL
+ ? 0
+ : ossl_lh_strcasehash(cache->input_structure));
hash = (hash * 23)
- + (cache->input_type == NULL
- ? 0 : ossl_lh_strcasehash(cache->input_type));
+ + (cache->input_type == NULL
+ ? 0
+ : ossl_lh_strcasehash(cache->input_type));
hash = (hash * 23)
- + (cache->keytype == NULL
- ? 0 : ossl_lh_strcasehash(cache->keytype));
+ + (cache->keytype == NULL
+ ? 0
+ : ossl_lh_strcasehash(cache->keytype));
hash ^= cache->selection;
@@ -723,7 +736,7 @@ static ossl_inline int nullstrcmp(const char *a, const char *b, int casecmp)
}
static int decoder_cache_entry_cmp(const DECODER_CACHE_ENTRY *a,
- const DECODER_CACHE_ENTRY *b)
+ const DECODER_CACHE_ENTRY *b)
{
int cmp;
@@ -760,7 +773,7 @@ void *ossl_decoder_cache_new(OSSL_LIB_CTX *ctx)
return NULL;
}
cache->hashtable = lh_DECODER_CACHE_ENTRY_new(decoder_cache_entry_hash,
- decoder_cache_entry_cmp);
+ decoder_cache_entry_cmp);
if (cache->hashtable == NULL) {
CRYPTO_THREAD_lock_free(cache->lock);
OPENSSL_free(cache);
@@ -792,7 +805,6 @@ int ossl_decoder_cache_flush(OSSL_LIB_CTX *libctx)
if (cache == NULL)
return 0;
-
if (!CRYPTO_THREAD_write_lock(cache->lock)) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_OSSL_DECODER_LIB);
return 0;
@@ -807,10 +819,10 @@ int ossl_decoder_cache_flush(OSSL_LIB_CTX *libctx)
OSSL_DECODER_CTX *
OSSL_DECODER_CTX_new_for_pkey(EVP_PKEY **pkey,
- const char *input_type,
- const char *input_structure,
- const char *keytype, int selection,
- OSSL_LIB_CTX *libctx, const char *propquery)
+ const char *input_type,
+ const char *input_structure,
+ const char *keytype, int selection,
+ OSSL_LIB_CTX *libctx, const char *propquery)
{
OSSL_DECODER_CTX *ctx = NULL;
OSSL_PARAM decoder_params[] = {
@@ -828,13 +840,11 @@ OSSL_DECODER_CTX_new_for_pkey(EVP_PKEY **pkey,
return NULL;
}
if (input_structure != NULL)
- decoder_params[i++] =
- OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_STRUCTURE,
- (char *)input_structure, 0);
+ decoder_params[i++] = OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_STRUCTURE,
+ (char *)input_structure, 0);
if (propquery != NULL)
- decoder_params[i++] =
- OSSL_PARAM_construct_utf8_string(OSSL_DECODER_PARAM_PROPERTIES,
- (char *)propquery, 0);
+ decoder_params[i++] = OSSL_PARAM_construct_utf8_string(OSSL_DECODER_PARAM_PROPERTIES,
+ (char *)propquery, 0);
/* It is safe to cast away the const here */
cacheent.input_type = (char *)input_type;
@@ -864,13 +874,15 @@ OSSL_DECODER_CTX_new_for_pkey(EVP_PKEY **pkey,
return NULL;
}
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) Looking for %s decoders with selection %d\n",
- (void *)ctx, keytype, selection);
+ "(ctx %p) Looking for %s decoders with selection %d\n",
+ (void *)ctx, keytype, selection);
BIO_printf(trc_out, " input type: %s, input structure: %s\n",
- input_type, input_structure);
- } OSSL_TRACE_END(DECODER);
+ input_type, input_structure);
+ }
+ OSSL_TRACE_END(DECODER);
if (OSSL_DECODER_CTX_set_input_type(ctx, input_type)
&& OSSL_DECODER_CTX_set_input_structure(ctx, input_structure)
@@ -879,10 +891,12 @@ OSSL_DECODER_CTX_new_for_pkey(EVP_PKEY **pkey,
&& OSSL_DECODER_CTX_add_extra(ctx, libctx, propquery)
&& (propquery == NULL
|| OSSL_DECODER_CTX_set_params(ctx, decoder_params))) {
- OSSL_TRACE_BEGIN(DECODER) {
+ OSSL_TRACE_BEGIN(DECODER)
+ {
BIO_printf(trc_out, "(ctx %p) Got %d decoders\n",
- (void *)ctx, OSSL_DECODER_CTX_get_num_decoders(ctx));
- } OSSL_TRACE_END(DECODER);
+ (void *)ctx, OSSL_DECODER_CTX_get_num_decoders(ctx));
+ }
+ OSSL_TRACE_END(DECODER);
} else {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_OSSL_DECODER_LIB);
OSSL_DECODER_CTX_free(ctx);
@@ -947,7 +961,7 @@ OSSL_DECODER_CTX_new_for_pkey(EVP_PKEY **pkey,
CRYPTO_THREAD_unlock(cache->lock);
return ctx;
- err:
+err:
decoder_cache_entry_free(newcache);
OSSL_DECODER_CTX_free(ctx);
return NULL;
diff --git a/crypto/encode_decode/encoder_err.c b/crypto/encode_decode/encoder_err.c
index a904e87ef2e7..79b12f9c31df 100644
--- a/crypto/encode_decode/encoder_err.c
+++ b/crypto/encode_decode/encoder_err.c
@@ -15,13 +15,13 @@
#ifndef OPENSSL_NO_ERR
static const ERR_STRING_DATA OSSL_ENCODER_str_reasons[] = {
- {ERR_PACK(ERR_LIB_OSSL_ENCODER, 0, OSSL_ENCODER_R_ENCODER_NOT_FOUND),
- "encoder not found"},
- {ERR_PACK(ERR_LIB_OSSL_ENCODER, 0, OSSL_ENCODER_R_INCORRECT_PROPERTY_QUERY),
- "incorrect property query"},
- {ERR_PACK(ERR_LIB_OSSL_ENCODER, 0, OSSL_ENCODER_R_MISSING_GET_PARAMS),
- "missing get params"},
- {0, NULL}
+ { ERR_PACK(ERR_LIB_OSSL_ENCODER, 0, OSSL_ENCODER_R_ENCODER_NOT_FOUND),
+ "encoder not found" },
+ { ERR_PACK(ERR_LIB_OSSL_ENCODER, 0, OSSL_ENCODER_R_INCORRECT_PROPERTY_QUERY),
+ "incorrect property query" },
+ { ERR_PACK(ERR_LIB_OSSL_ENCODER, 0, OSSL_ENCODER_R_MISSING_GET_PARAMS),
+ "missing get params" },
+ { 0, NULL }
};
#endif
diff --git a/crypto/encode_decode/encoder_lib.c b/crypto/encode_decode/encoder_lib.c
index 59d0c885a3e4..753db526209c 100644
--- a/crypto/encode_decode/encoder_lib.c
+++ b/crypto/encode_decode/encoder_lib.c
@@ -24,22 +24,22 @@
#include "encoder_local.h"
/* Number of octets per line */
-#define LABELED_BUF_PRINT_WIDTH 15
+#define LABELED_BUF_PRINT_WIDTH 15
-# ifdef SIXTY_FOUR_BIT_LONG
-# define BN_FMTu "%lu"
-# define BN_FMTx "%lx"
-# endif
+#ifdef SIXTY_FOUR_BIT_LONG
+#define BN_FMTu "%lu"
+#define BN_FMTx "%lx"
+#endif
-# ifdef SIXTY_FOUR_BIT
-# define BN_FMTu "%llu"
-# define BN_FMTx "%llx"
-# endif
+#ifdef SIXTY_FOUR_BIT
+#define BN_FMTu "%llu"
+#define BN_FMTx "%llx"
+#endif
-# ifdef THIRTY_TWO_BIT
-# define BN_FMTu "%u"
-# define BN_FMTx "%x"
-# endif
+#ifdef THIRTY_TWO_BIT
+#define BN_FMTu "%u"
+#define BN_FMTx "%x"
+#endif
struct encoder_process_data_st {
OSSL_ENCODER_CTX *ctx;
@@ -51,7 +51,7 @@ struct encoder_process_data_st {
int current_encoder_inst_index;
/* Processing data passed down through recursion */
- int level; /* Recursion level */
+ int level; /* Recursion level */
OSSL_ENCODER_INSTANCE *next_encoder_inst;
int count_output_structure;
@@ -76,9 +76,9 @@ int OSSL_ENCODER_to_bio(OSSL_ENCODER_CTX *ctx, BIO *out)
if (data.current_encoder_inst_index == 0) {
ERR_raise_data(ERR_LIB_OSSL_ENCODER, OSSL_ENCODER_R_ENCODER_NOT_FOUND,
- "No encoders were found. For standard encoders you need "
- "at least one of the default or base providers "
- "available. Did you forget to load them?");
+ "No encoders were found. For standard encoders you need "
+ "at least one of the default or base providers "
+ "available. Did you forget to load them?");
return 0;
}
@@ -117,7 +117,7 @@ int OSSL_ENCODER_to_fp(OSSL_ENCODER_CTX *ctx, FILE *fp)
#endif
int OSSL_ENCODER_to_data(OSSL_ENCODER_CTX *ctx, unsigned char **pdata,
- size_t *pdata_len)
+ size_t *pdata_len)
{
BIO *out;
BUF_MEM *buf = NULL;
@@ -184,7 +184,7 @@ int OSSL_ENCODER_CTX_set_selection(OSSL_ENCODER_CTX *ctx, int selection)
}
int OSSL_ENCODER_CTX_set_output_type(OSSL_ENCODER_CTX *ctx,
- const char *output_type)
+ const char *output_type)
{
if (!ossl_assert(ctx != NULL) || !ossl_assert(output_type != NULL)) {
ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_PASSED_NULL_PARAMETER);
@@ -196,7 +196,7 @@ int OSSL_ENCODER_CTX_set_output_type(OSSL_ENCODER_CTX *ctx,
}
int OSSL_ENCODER_CTX_set_output_structure(OSSL_ENCODER_CTX *ctx,
- const char *output_structure)
+ const char *output_structure)
{
if (!ossl_assert(ctx != NULL) || !ossl_assert(output_structure != NULL)) {
ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_PASSED_NULL_PARAMETER);
@@ -208,7 +208,7 @@ int OSSL_ENCODER_CTX_set_output_structure(OSSL_ENCODER_CTX *ctx,
}
static OSSL_ENCODER_INSTANCE *ossl_encoder_instance_new(OSSL_ENCODER *encoder,
- void *encoderctx)
+ void *encoderctx)
{
OSSL_ENCODER_INSTANCE *encoder_inst = NULL;
const OSSL_PROVIDER *prov;
@@ -234,8 +234,8 @@ static OSSL_ENCODER_INSTANCE *ossl_encoder_instance_new(OSSL_ENCODER *encoder,
props = ossl_encoder_parsed_properties(encoder);
if (props == NULL) {
ERR_raise_data(ERR_LIB_OSSL_DECODER, ERR_R_INVALID_PROPERTY_DEFINITION,
- "there are no property definitions with encoder %s",
- OSSL_ENCODER_get0_name(encoder));
+ "there are no property definitions with encoder %s",
+ OSSL_ENCODER_get0_name(encoder));
goto err;
}
@@ -244,10 +244,10 @@ static OSSL_ENCODER_INSTANCE *ossl_encoder_instance_new(OSSL_ENCODER *encoder,
encoder_inst->output_type = ossl_property_get_string_value(libctx, prop);
if (encoder_inst->output_type == NULL) {
ERR_raise_data(ERR_LIB_OSSL_DECODER, ERR_R_INVALID_PROPERTY_DEFINITION,
- "the mandatory 'output' property is missing "
- "for encoder %s (properties: %s)",
- OSSL_ENCODER_get0_name(encoder),
- OSSL_ENCODER_get0_properties(encoder));
+ "the mandatory 'output' property is missing "
+ "for encoder %s (properties: %s)",
+ OSSL_ENCODER_get0_name(encoder),
+ OSSL_ENCODER_get0_properties(encoder));
goto err;
}
@@ -260,7 +260,7 @@ static OSSL_ENCODER_INSTANCE *ossl_encoder_instance_new(OSSL_ENCODER *encoder,
encoder_inst->encoder = encoder;
encoder_inst->encoderctx = encoderctx;
return encoder_inst;
- err:
+err:
ossl_encoder_instance_free(encoder_inst);
return NULL;
}
@@ -278,27 +278,28 @@ void ossl_encoder_instance_free(OSSL_ENCODER_INSTANCE *encoder_inst)
}
static int ossl_encoder_ctx_add_encoder_inst(OSSL_ENCODER_CTX *ctx,
- OSSL_ENCODER_INSTANCE *ei)
+ OSSL_ENCODER_INSTANCE *ei)
{
int ok;
if (ctx->encoder_insts == NULL
- && (ctx->encoder_insts =
- sk_OSSL_ENCODER_INSTANCE_new_null()) == NULL) {
+ && (ctx->encoder_insts = sk_OSSL_ENCODER_INSTANCE_new_null()) == NULL) {
ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_CRYPTO_LIB);
return 0;
}
ok = (sk_OSSL_ENCODER_INSTANCE_push(ctx->encoder_insts, ei) > 0);
if (ok) {
- OSSL_TRACE_BEGIN(ENCODER) {
+ OSSL_TRACE_BEGIN(ENCODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) Added encoder instance %p (encoder %p):\n"
- " %s with %s\n",
- (void *)ctx, (void *)ei, (void *)ei->encoder,
- OSSL_ENCODER_get0_name(ei->encoder),
- OSSL_ENCODER_get0_properties(ei->encoder));
- } OSSL_TRACE_END(ENCODER);
+ "(ctx %p) Added encoder instance %p (encoder %p):\n"
+ " %s with %s\n",
+ (void *)ctx, (void *)ei, (void *)ei->encoder,
+ OSSL_ENCODER_get0_name(ei->encoder),
+ OSSL_ENCODER_get0_properties(ei->encoder));
+ }
+ OSSL_TRACE_END(ENCODER);
}
return ok;
}
@@ -319,8 +320,7 @@ int OSSL_ENCODER_CTX_add_encoder(OSSL_ENCODER_CTX *ctx, OSSL_ENCODER *encoder)
provctx = OSSL_PROVIDER_get0_provider_ctx(prov);
if ((encoderctx = encoder->newctx(provctx)) == NULL
- || (encoder_inst =
- ossl_encoder_instance_new(encoder, encoderctx)) == NULL)
+ || (encoder_inst = ossl_encoder_instance_new(encoder, encoderctx)) == NULL)
goto err;
/* Avoid double free of encoderctx on further errors */
encoderctx = NULL;
@@ -329,7 +329,7 @@ int OSSL_ENCODER_CTX_add_encoder(OSSL_ENCODER_CTX *ctx, OSSL_ENCODER *encoder)
goto err;
return 1;
- err:
+err:
ossl_encoder_instance_free(encoder_inst);
if (encoderctx != NULL)
encoder->freectx(encoderctx);
@@ -337,7 +337,7 @@ int OSSL_ENCODER_CTX_add_encoder(OSSL_ENCODER_CTX *ctx, OSSL_ENCODER *encoder)
}
int OSSL_ENCODER_CTX_add_extra(OSSL_ENCODER_CTX *ctx,
- OSSL_LIB_CTX *libctx, const char *propq)
+ OSSL_LIB_CTX *libctx, const char *propq)
{
return 1;
}
@@ -350,7 +350,7 @@ int OSSL_ENCODER_CTX_get_num_encoders(OSSL_ENCODER_CTX *ctx)
}
int OSSL_ENCODER_CTX_set_construct(OSSL_ENCODER_CTX *ctx,
- OSSL_ENCODER_CONSTRUCT *construct)
+ OSSL_ENCODER_CONSTRUCT *construct)
{
if (!ossl_assert(ctx != NULL)) {
ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_PASSED_NULL_PARAMETER);
@@ -361,7 +361,7 @@ int OSSL_ENCODER_CTX_set_construct(OSSL_ENCODER_CTX *ctx,
}
int OSSL_ENCODER_CTX_set_construct_data(OSSL_ENCODER_CTX *ctx,
- void *construct_data)
+ void *construct_data)
{
if (!ossl_assert(ctx != NULL)) {
ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_PASSED_NULL_PARAMETER);
@@ -372,7 +372,7 @@ int OSSL_ENCODER_CTX_set_construct_data(OSSL_ENCODER_CTX *ctx,
}
int OSSL_ENCODER_CTX_set_cleanup(OSSL_ENCODER_CTX *ctx,
- OSSL_ENCODER_CLEANUP *cleanup)
+ OSSL_ENCODER_CLEANUP *cleanup)
{
if (!ossl_assert(ctx != NULL)) {
ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_PASSED_NULL_PARAMETER);
@@ -424,14 +424,13 @@ static int encoder_process(struct encoder_process_data_st *data)
OSSL_PARAM abstract[10];
const OSSL_PARAM *current_abstract = NULL;
int i;
- int ok = -1; /* -1 signifies that the lookup loop gave nothing */
+ int ok = -1; /* -1 signifies that the lookup loop gave nothing */
int top = 0;
if (data->next_encoder_inst == NULL) {
/* First iteration, where we prepare for what is to come */
- data->count_output_structure =
- data->ctx->output_structure == NULL ? -1 : 0;
+ data->count_output_structure = data->ctx->output_structure == NULL ? -1 : 0;
top = 1;
}
@@ -442,19 +441,13 @@ static int encoder_process(struct encoder_process_data_st *data)
struct encoder_process_data_st new_data;
if (!top)
- next_encoder =
- OSSL_ENCODER_INSTANCE_get_encoder(data->next_encoder_inst);
+ next_encoder = OSSL_ENCODER_INSTANCE_get_encoder(data->next_encoder_inst);
- current_encoder_inst =
- sk_OSSL_ENCODER_INSTANCE_value(data->ctx->encoder_insts, i);
- current_encoder =
- OSSL_ENCODER_INSTANCE_get_encoder(current_encoder_inst);
- current_encoder_ctx =
- OSSL_ENCODER_INSTANCE_get_encoder_ctx(current_encoder_inst);
- current_output_type =
- OSSL_ENCODER_INSTANCE_get_output_type(current_encoder_inst);
- current_output_structure =
- OSSL_ENCODER_INSTANCE_get_output_structure(current_encoder_inst);
+ current_encoder_inst = sk_OSSL_ENCODER_INSTANCE_value(data->ctx->encoder_insts, i);
+ current_encoder = OSSL_ENCODER_INSTANCE_get_encoder(current_encoder_inst);
+ current_encoder_ctx = OSSL_ENCODER_INSTANCE_get_encoder_ctx(current_encoder_inst);
+ current_output_type = OSSL_ENCODER_INSTANCE_get_output_type(current_encoder_inst);
+ current_output_structure = OSSL_ENCODER_INSTANCE_get_output_structure(current_encoder_inst);
memset(&new_data, 0, sizeof(new_data));
new_data.ctx = data->ctx;
new_data.current_encoder_inst_index = i;
@@ -462,12 +455,14 @@ static int encoder_process(struct encoder_process_data_st *data)
new_data.count_output_structure = data->count_output_structure;
new_data.level = data->level + 1;
- OSSL_TRACE_BEGIN(ENCODER) {
+ OSSL_TRACE_BEGIN(ENCODER)
+ {
BIO_printf(trc_out,
- "[%d] (ctx %p) Considering encoder instance %p (encoder %p)\n",
- data->level, (void *)data->ctx,
- (void *)current_encoder_inst, (void *)current_encoder);
- } OSSL_TRACE_END(ENCODER);
+ "[%d] (ctx %p) Considering encoder instance %p (encoder %p)\n",
+ data->level, (void *)data->ctx,
+ (void *)current_encoder_inst, (void *)current_encoder);
+ }
+ OSSL_TRACE_END(ENCODER);
/*
* If this is the top call, we check if the output type of the current
@@ -479,23 +474,28 @@ static int encoder_process(struct encoder_process_data_st *data)
if (top) {
if (data->ctx->output_type != NULL
&& OPENSSL_strcasecmp(current_output_type,
- data->ctx->output_type) != 0) {
- OSSL_TRACE_BEGIN(ENCODER) {
+ data->ctx->output_type)
+ != 0) {
+ OSSL_TRACE_BEGIN(ENCODER)
+ {
BIO_printf(trc_out,
- "[%d] Skipping because current encoder output type (%s) != desired output type (%s)\n",
- data->level,
- current_output_type, data->ctx->output_type);
- } OSSL_TRACE_END(ENCODER);
+ "[%d] Skipping because current encoder output type (%s) != desired output type (%s)\n",
+ data->level,
+ current_output_type, data->ctx->output_type);
+ }
+ OSSL_TRACE_END(ENCODER);
continue;
}
} else {
if (!OSSL_ENCODER_is_a(next_encoder, current_output_type)) {
- OSSL_TRACE_BEGIN(ENCODER) {
+ OSSL_TRACE_BEGIN(ENCODER)
+ {
BIO_printf(trc_out,
- "[%d] Skipping because current encoder output type (%s) != name of encoder %p\n",
- data->level,
- current_output_type, (void *)next_encoder);
- } OSSL_TRACE_END(ENCODER);
+ "[%d] Skipping because current encoder output type (%s) != name of encoder %p\n",
+ data->level,
+ current_output_type, (void *)next_encoder);
+ }
+ OSSL_TRACE_END(ENCODER);
continue;
}
}
@@ -508,14 +508,17 @@ static int encoder_process(struct encoder_process_data_st *data)
if (data->ctx->output_structure != NULL
&& current_output_structure != NULL) {
if (OPENSSL_strcasecmp(data->ctx->output_structure,
- current_output_structure) != 0) {
- OSSL_TRACE_BEGIN(ENCODER) {
+ current_output_structure)
+ != 0) {
+ OSSL_TRACE_BEGIN(ENCODER)
+ {
BIO_printf(trc_out,
- "[%d] Skipping because current encoder output structure (%s) != ctx output structure (%s)\n",
- data->level,
- current_output_structure,
- data->ctx->output_structure);
- } OSSL_TRACE_END(ENCODER);
+ "[%d] Skipping because current encoder output structure (%s) != ctx output structure (%s)\n",
+ data->level,
+ current_output_structure,
+ data->ctx->output_structure);
+ }
+ OSSL_TRACE_END(ENCODER);
continue;
}
@@ -546,11 +549,13 @@ static int encoder_process(struct encoder_process_data_st *data)
if (ok != 0)
break;
- OSSL_TRACE_BEGIN(ENCODER) {
+ OSSL_TRACE_BEGIN(ENCODER)
+ {
BIO_printf(trc_out,
- "[%d] Skipping because recursion level %d failed\n",
- data->level, new_data.level);
- } OSSL_TRACE_END(ENCODER);
+ "[%d] Skipping because recursion level %d failed\n",
+ data->level, new_data.level);
+ }
+ OSSL_TRACE_END(ENCODER);
}
/*
@@ -560,11 +565,13 @@ static int encoder_process(struct encoder_process_data_st *data)
if (i < 0) {
ok = -1;
- OSSL_TRACE_BEGIN(ENCODER) {
+ OSSL_TRACE_BEGIN(ENCODER)
+ {
BIO_printf(trc_out,
- "[%d] (ctx %p) No suitable encoder found\n",
- data->level, (void *)data->ctx);
- } OSSL_TRACE_END(ENCODER);
+ "[%d] (ctx %p) No suitable encoder found\n",
+ data->level, (void *)data->ctx);
+ }
+ OSSL_TRACE_END(ENCODER);
} else {
/* Preparations */
@@ -590,9 +597,8 @@ static int encoder_process(struct encoder_process_data_st *data)
if (data->count_output_structure == 0)
return 0;
- original_data =
- data->ctx->construct(current_encoder_inst,
- data->ctx->construct_data);
+ original_data = data->ctx->construct(current_encoder_inst,
+ data->ctx->construct_data);
/* Also set the data type, using the encoder implementation name */
data->data_type = OSSL_ENCODER_get0_name(current_encoder);
@@ -617,21 +623,17 @@ static int encoder_process(struct encoder_process_data_st *data)
*/
OSSL_PARAM *abstract_p = abstract;
- const char *prev_output_structure =
- OSSL_ENCODER_INSTANCE_get_output_structure(data->prev_encoder_inst);
+ const char *prev_output_structure = OSSL_ENCODER_INSTANCE_get_output_structure(data->prev_encoder_inst);
- *abstract_p++ =
- OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_TYPE,
- (char *)data->data_type, 0);
+ *abstract_p++ = OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_TYPE,
+ (char *)data->data_type, 0);
if (prev_output_structure != NULL)
- *abstract_p++ =
- OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_STRUCTURE,
- (char *)prev_output_structure,
- 0);
- *abstract_p++ =
- OSSL_PARAM_construct_octet_string(OSSL_OBJECT_PARAM_DATA,
- data->running_output,
- data->running_output_length);
+ *abstract_p++ = OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_STRUCTURE,
+ (char *)prev_output_structure,
+ 0);
+ *abstract_p++ = OSSL_PARAM_construct_octet_string(OSSL_OBJECT_PARAM_DATA,
+ data->running_output,
+ data->running_output_length);
*abstract_p = OSSL_PARAM_construct_end();
current_abstract = abstract;
}
@@ -651,23 +653,25 @@ static int encoder_process(struct encoder_process_data_st *data)
if (top)
current_out = data->bio;
else if ((current_out = allocated_out = BIO_new(BIO_s_mem()))
- == NULL)
- ok = 0; /* Assume BIO_new() recorded an error */
+ == NULL)
+ ok = 0; /* Assume BIO_new() recorded an error */
if (ok)
ok = (cbio = ossl_core_bio_new_from_bio(current_out)) != NULL;
if (ok) {
ok = current_encoder->encode(current_encoder_ctx, cbio,
- original_data, current_abstract,
- data->ctx->selection,
- ossl_pw_passphrase_callback_enc,
- &data->ctx->pwdata);
- OSSL_TRACE_BEGIN(ENCODER) {
+ original_data, current_abstract,
+ data->ctx->selection,
+ ossl_pw_passphrase_callback_enc,
+ &data->ctx->pwdata);
+ OSSL_TRACE_BEGIN(ENCODER)
+ {
BIO_printf(trc_out,
- "[%d] (ctx %p) Running encoder instance %p => %d\n",
- data->level, (void *)data->ctx,
- (void *)current_encoder_inst, ok);
- } OSSL_TRACE_END(ENCODER);
+ "[%d] (ctx %p) Running encoder instance %p => %d\n",
+ data->level, (void *)data->ctx,
+ (void *)current_encoder_inst, ok);
+ }
+ OSSL_TRACE_END(ENCODER);
}
ossl_core_bio_free(cbio);
@@ -726,7 +730,7 @@ int ossl_bio_print_labeled_bignum(BIO *out, const char *label, const BIGNUM *bn)
neg = "-";
return BIO_printf(out, "%s%s%s" BN_FMTu " (%s0x" BN_FMTx ")\n",
- label, post_label_spc, neg, words[0], neg, words[0]);
+ label, post_label_spc, neg, words[0], neg, words[0]);
}
hex_str = BN_bn2hex(bn);
@@ -762,8 +766,9 @@ int ossl_bio_print_labeled_bignum(BIO *out, const char *label, const BIGNUM *bn)
use_sep = 0; /* The first byte on the next line doesn't have a : */
}
if (BIO_printf(out, "%s%c%c", use_sep ? ":" : "",
- tolower((unsigned char)p[0]),
- tolower((unsigned char)p[1])) <= 0)
+ tolower((unsigned char)p[0]),
+ tolower((unsigned char)p[1]))
+ <= 0)
goto err;
++bytes;
p += 2;
@@ -778,7 +783,7 @@ err:
}
int ossl_bio_print_labeled_buf(BIO *out, const char *label,
- const unsigned char *buf, size_t buflen)
+ const unsigned char *buf, size_t buflen)
{
size_t i;
@@ -794,7 +799,8 @@ int ossl_bio_print_labeled_buf(BIO *out, const char *label,
}
if (BIO_printf(out, "%02x%s", buf[i],
- (i == buflen - 1) ? "" : ":") <= 0)
+ (i == buflen - 1) ? "" : ":")
+ <= 0)
return 0;
}
if (BIO_printf(out, "\n") <= 0)
diff --git a/crypto/encode_decode/encoder_local.h b/crypto/encode_decode/encoder_local.h
index 11e52cfeec75..439bd085f936 100644
--- a/crypto/encode_decode/encoder_local.h
+++ b/crypto/encode_decode/encoder_local.h
@@ -56,9 +56,9 @@ struct ossl_decoder_st {
};
struct ossl_encoder_instance_st {
- OSSL_ENCODER *encoder; /* Never NULL */
- void *encoderctx; /* Never NULL */
- const char *output_type; /* Never NULL */
+ OSSL_ENCODER *encoder; /* Never NULL */
+ void *encoderctx; /* Never NULL */
+ const char *output_type; /* Never NULL */
const char *output_structure; /* May be NULL */
};
@@ -104,13 +104,13 @@ struct ossl_encoder_ctx_st {
};
struct ossl_decoder_instance_st {
- OSSL_DECODER *decoder; /* Never NULL */
- void *decoderctx; /* Never NULL */
- const char *input_type; /* Never NULL */
+ OSSL_DECODER *decoder; /* Never NULL */
+ void *decoderctx; /* Never NULL */
+ const char *input_type; /* Never NULL */
const char *input_structure; /* May be NULL */
int input_type_id;
- int order; /* For stable ordering of decoders wrt proqs */
- int score; /* For ordering decoders wrt proqs */
+ int order; /* For stable ordering of decoders wrt proqs */
+ int score; /* For ordering decoders wrt proqs */
unsigned int flag_input_structure_was_set : 1;
};
@@ -170,4 +170,4 @@ const OSSL_PROPERTY_LIST *
ossl_encoder_parsed_properties(const OSSL_ENCODER *encoder);
int ossl_decoder_fast_is_a(OSSL_DECODER *decoder,
- const char *name, int *id_cache);
+ const char *name, int *id_cache);
diff --git a/crypto/encode_decode/encoder_meth.c b/crypto/encode_decode/encoder_meth.c
index e99eaecbfb39..89c3d7b887cc 100644
--- a/crypto/encode_decode/encoder_meth.c
+++ b/crypto/encode_decode/encoder_meth.c
@@ -77,9 +77,9 @@ void OSSL_ENCODER_free(OSSL_ENCODER *encoder)
/* Data to be passed through ossl_method_construct() */
struct encoder_data_st {
OSSL_LIB_CTX *libctx;
- int id; /* For get_encoder_from_store() */
- const char *names; /* For get_encoder_from_store() */
- const char *propquery; /* For get_encoder_from_store() */
+ int id; /* For get_encoder_from_store() */
+ const char *names; /* For get_encoder_from_store() */
+ const char *propquery; /* For get_encoder_from_store() */
OSSL_METHOD_STORE *tmp_store; /* For get_tmp_encoder_store() */
@@ -137,7 +137,7 @@ static int unreserve_encoder_store(void *store, void *data)
/* Get encoder methods from a store, or put one in */
static void *get_encoder_from_store(void *store, const OSSL_PROVIDER **prov,
- void *data)
+ void *data)
{
struct encoder_data_st *methdata = data;
void *method = NULL;
@@ -172,9 +172,9 @@ static void *get_encoder_from_store(void *store, const OSSL_PROVIDER **prov,
}
static int put_encoder_in_store(void *store, void *method,
- const OSSL_PROVIDER *prov,
- const char *names, const char *propdef,
- void *data)
+ const OSSL_PROVIDER *prov,
+ const char *names, const char *propdef,
+ void *data)
{
struct encoder_data_st *methdata = data;
OSSL_NAMEMAP *namemap;
@@ -201,13 +201,13 @@ static int put_encoder_in_store(void *store, void *method,
return 0;
return ossl_method_store_add(store, prov, id, propdef, method,
- ossl_encoder_up_ref,
- ossl_encoder_free);
+ ossl_encoder_up_ref,
+ ossl_encoder_free);
}
/* Create and populate a encoder method */
static void *encoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef,
- OSSL_PROVIDER *prov)
+ OSSL_PROVIDER *prov)
{
OSSL_ENCODER *encoder = NULL;
const OSSL_DISPATCH *fns = algodef->implementation;
@@ -222,7 +222,8 @@ static void *encoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef,
}
encoder->base.algodef = algodef;
if ((encoder->base.parsed_propdef
- = ossl_parse_property(libctx, algodef->property_definition)) == NULL) {
+ = ossl_parse_property(libctx, algodef->property_definition))
+ == NULL) {
OSSL_ENCODER_free(encoder);
return NULL;
}
@@ -231,38 +232,31 @@ static void *encoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef,
switch (fns->function_id) {
case OSSL_FUNC_ENCODER_NEWCTX:
if (encoder->newctx == NULL)
- encoder->newctx =
- OSSL_FUNC_encoder_newctx(fns);
+ encoder->newctx = OSSL_FUNC_encoder_newctx(fns);
break;
case OSSL_FUNC_ENCODER_FREECTX:
if (encoder->freectx == NULL)
- encoder->freectx =
- OSSL_FUNC_encoder_freectx(fns);
+ encoder->freectx = OSSL_FUNC_encoder_freectx(fns);
break;
case OSSL_FUNC_ENCODER_GET_PARAMS:
if (encoder->get_params == NULL)
- encoder->get_params =
- OSSL_FUNC_encoder_get_params(fns);
+ encoder->get_params = OSSL_FUNC_encoder_get_params(fns);
break;
case OSSL_FUNC_ENCODER_GETTABLE_PARAMS:
if (encoder->gettable_params == NULL)
- encoder->gettable_params =
- OSSL_FUNC_encoder_gettable_params(fns);
+ encoder->gettable_params = OSSL_FUNC_encoder_gettable_params(fns);
break;
case OSSL_FUNC_ENCODER_SET_CTX_PARAMS:
if (encoder->set_ctx_params == NULL)
- encoder->set_ctx_params =
- OSSL_FUNC_encoder_set_ctx_params(fns);
+ encoder->set_ctx_params = OSSL_FUNC_encoder_set_ctx_params(fns);
break;
case OSSL_FUNC_ENCODER_SETTABLE_CTX_PARAMS:
if (encoder->settable_ctx_params == NULL)
- encoder->settable_ctx_params =
- OSSL_FUNC_encoder_settable_ctx_params(fns);
+ encoder->settable_ctx_params = OSSL_FUNC_encoder_settable_ctx_params(fns);
break;
case OSSL_FUNC_ENCODER_DOES_SELECTION:
if (encoder->does_selection == NULL)
- encoder->does_selection =
- OSSL_FUNC_encoder_does_selection(fns);
+ encoder->does_selection = OSSL_FUNC_encoder_does_selection(fns);
break;
case OSSL_FUNC_ENCODER_ENCODE:
if (encoder->encode == NULL)
@@ -270,13 +264,11 @@ static void *encoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef,
break;
case OSSL_FUNC_ENCODER_IMPORT_OBJECT:
if (encoder->import_object == NULL)
- encoder->import_object =
- OSSL_FUNC_encoder_import_object(fns);
+ encoder->import_object = OSSL_FUNC_encoder_import_object(fns);
break;
case OSSL_FUNC_ENCODER_FREE_OBJECT:
if (encoder->free_object == NULL)
- encoder->free_object =
- OSSL_FUNC_encoder_free_object(fns);
+ encoder->free_object = OSSL_FUNC_encoder_free_object(fns);
break;
}
}
@@ -286,9 +278,9 @@ static void *encoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef,
* You must have the encoding driver functions.
*/
if (!((encoder->newctx == NULL && encoder->freectx == NULL)
- || (encoder->newctx != NULL && encoder->freectx != NULL)
- || (encoder->import_object != NULL && encoder->free_object != NULL)
- || (encoder->import_object == NULL && encoder->free_object == NULL))
+ || (encoder->newctx != NULL && encoder->freectx != NULL)
+ || (encoder->import_object != NULL && encoder->free_object != NULL)
+ || (encoder->import_object == NULL && encoder->free_object == NULL))
|| encoder->encode == NULL) {
OSSL_ENCODER_free(encoder);
ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_INVALID_PROVIDER_FUNCTIONS);
@@ -304,14 +296,13 @@ static void *encoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef,
return encoder;
}
-
/*
* The core fetching functionality passes the names of the implementation.
* This function is responsible to getting an identity number for them,
* then call encoder_from_algorithm() with that identity number.
*/
static void *construct_encoder(const OSSL_ALGORITHM *algodef,
- OSSL_PROVIDER *prov, void *data)
+ OSSL_PROVIDER *prov, void *data)
{
/*
* This function is only called if get_encoder_from_store() returned
@@ -359,7 +350,7 @@ static void free_encoder(void *method)
/* Fetching support. Can fetch by numeric identity or by name */
static OSSL_ENCODER *
inner_ossl_encoder_fetch(struct encoder_data_st *methdata,
- const char *name, const char *properties)
+ const char *name, const char *properties)
{
OSSL_METHOD_STORE *store = get_encoder_store(methdata->libctx);
OSSL_NAMEMAP *namemap = ossl_namemap_stored(methdata->libctx);
@@ -398,8 +389,9 @@ inner_ossl_encoder_fetch(struct encoder_data_st *methdata,
methdata->propquery = propq;
methdata->flag_construct_error_occurred = 0;
if ((method = ossl_method_construct(methdata->libctx, OSSL_OP_ENCODER,
- &prov, 0 /* !force_cache */,
- &mcm, methdata)) != NULL) {
+ &prov, 0 /* !force_cache */,
+ &mcm, methdata))
+ != NULL) {
/*
* If construction did create a method for us, we know that
* there is a correct name_id and meth_id, since those have
@@ -409,7 +401,7 @@ inner_ossl_encoder_fetch(struct encoder_data_st *methdata,
if (id == 0)
id = ossl_namemap_name2num(namemap, name);
ossl_method_store_cache_set(store, prov, id, propq, method,
- up_ref_encoder, free_encoder);
+ up_ref_encoder, free_encoder);
}
/*
@@ -425,17 +417,17 @@ inner_ossl_encoder_fetch(struct encoder_data_st *methdata,
if (name == NULL)
name = ossl_namemap_num2name(namemap, id, 0);
ERR_raise_data(ERR_LIB_OSSL_ENCODER, code,
- "%s, Name (%s : %d), Properties (%s)",
- ossl_lib_ctx_get_descriptor(methdata->libctx),
- name == NULL ? "<null>" : name, id,
- properties == NULL ? "<null>" : properties);
+ "%s, Name (%s : %d), Properties (%s)",
+ ossl_lib_ctx_get_descriptor(methdata->libctx),
+ name == NULL ? "<null>" : name, id,
+ properties == NULL ? "<null>" : properties);
}
return method;
}
OSSL_ENCODER *OSSL_ENCODER_fetch(OSSL_LIB_CTX *libctx, const char *name,
- const char *properties)
+ const char *properties)
{
struct encoder_data_st methdata;
void *method;
@@ -545,9 +537,9 @@ static void do_one(ossl_unused int id, void *method, void *arg)
}
void OSSL_ENCODER_do_all_provided(OSSL_LIB_CTX *libctx,
- void (*user_fn)(OSSL_ENCODER *encoder,
- void *arg),
- void *user_arg)
+ void (*user_fn)(OSSL_ENCODER *encoder,
+ void *arg),
+ void *user_arg)
{
struct encoder_data_st methdata;
struct do_one_data_st data;
@@ -565,8 +557,8 @@ void OSSL_ENCODER_do_all_provided(OSSL_LIB_CTX *libctx,
}
int OSSL_ENCODER_names_do_all(const OSSL_ENCODER *encoder,
- void (*fn)(const char *name, void *data),
- void *data)
+ void (*fn)(const char *name, void *data),
+ void *data)
{
if (encoder == NULL)
return 0;
@@ -622,7 +614,7 @@ OSSL_ENCODER_CTX *OSSL_ENCODER_CTX_new(void)
}
int OSSL_ENCODER_CTX_set_params(OSSL_ENCODER_CTX *ctx,
- const OSSL_PARAM params[])
+ const OSSL_PARAM params[])
{
int ok = 1;
size_t i;
@@ -638,8 +630,7 @@ int OSSL_ENCODER_CTX_set_params(OSSL_ENCODER_CTX *ctx,
l = OSSL_ENCODER_CTX_get_num_encoders(ctx);
for (i = 0; i < l; i++) {
- OSSL_ENCODER_INSTANCE *encoder_inst =
- sk_OSSL_ENCODER_INSTANCE_value(ctx->encoder_insts, i);
+ OSSL_ENCODER_INSTANCE *encoder_inst = sk_OSSL_ENCODER_INSTANCE_value(ctx->encoder_insts, i);
OSSL_ENCODER *encoder = OSSL_ENCODER_INSTANCE_get_encoder(encoder_inst);
void *encoderctx = OSSL_ENCODER_INSTANCE_get_encoder_ctx(encoder_inst);
@@ -655,7 +646,7 @@ void OSSL_ENCODER_CTX_free(OSSL_ENCODER_CTX *ctx)
{
if (ctx != NULL) {
sk_OSSL_ENCODER_INSTANCE_pop_free(ctx->encoder_insts,
- ossl_encoder_instance_free);
+ ossl_encoder_instance_free);
OPENSSL_free(ctx->construct_data);
ossl_pw_clear_passphrase_data(&ctx->pwdata);
OPENSSL_free(ctx);
diff --git a/crypto/encode_decode/encoder_pkey.c b/crypto/encode_decode/encoder_pkey.c
index 97aad8820229..10635337b79e 100644
--- a/crypto/encode_decode/encoder_pkey.c
+++ b/crypto/encode_decode/encoder_pkey.c
@@ -24,44 +24,42 @@
DEFINE_STACK_OF(OSSL_ENCODER)
int OSSL_ENCODER_CTX_set_cipher(OSSL_ENCODER_CTX *ctx,
- const char *cipher_name,
- const char *propquery)
+ const char *cipher_name,
+ const char *propquery)
{
OSSL_PARAM params[] = { OSSL_PARAM_END, OSSL_PARAM_END, OSSL_PARAM_END };
- params[0] =
- OSSL_PARAM_construct_utf8_string(OSSL_ENCODER_PARAM_CIPHER,
- (void *)cipher_name, 0);
- params[1] =
- OSSL_PARAM_construct_utf8_string(OSSL_ENCODER_PARAM_PROPERTIES,
- (void *)propquery, 0);
+ params[0] = OSSL_PARAM_construct_utf8_string(OSSL_ENCODER_PARAM_CIPHER,
+ (void *)cipher_name, 0);
+ params[1] = OSSL_PARAM_construct_utf8_string(OSSL_ENCODER_PARAM_PROPERTIES,
+ (void *)propquery, 0);
return OSSL_ENCODER_CTX_set_params(ctx, params);
}
int OSSL_ENCODER_CTX_set_passphrase(OSSL_ENCODER_CTX *ctx,
- const unsigned char *kstr,
- size_t klen)
+ const unsigned char *kstr,
+ size_t klen)
{
return ossl_pw_set_passphrase(&ctx->pwdata, kstr, klen);
}
int OSSL_ENCODER_CTX_set_passphrase_ui(OSSL_ENCODER_CTX *ctx,
- const UI_METHOD *ui_method,
- void *ui_data)
+ const UI_METHOD *ui_method,
+ void *ui_data)
{
return ossl_pw_set_ui_method(&ctx->pwdata, ui_method, ui_data);
}
int OSSL_ENCODER_CTX_set_pem_password_cb(OSSL_ENCODER_CTX *ctx,
- pem_password_cb *cb, void *cbarg)
+ pem_password_cb *cb, void *cbarg)
{
return ossl_pw_set_pem_password_cb(&ctx->pwdata, cb, cbarg);
}
int OSSL_ENCODER_CTX_set_passphrase_cb(OSSL_ENCODER_CTX *ctx,
- OSSL_PASSPHRASE_CALLBACK *cb,
- void *cbarg)
+ OSSL_PASSPHRASE_CALLBACK *cb,
+ void *cbarg)
{
return ossl_pw_set_ossl_passphrase_cb(&ctx->pwdata, cb, cbarg);
}
@@ -79,7 +77,7 @@ struct collected_encoder_st {
const OSSL_PROVIDER *keymgmt_prov;
OSSL_ENCODER_CTX *ctx;
- unsigned int flag_find_same_provider:1;
+ unsigned int flag_find_same_provider : 1;
int error_occurred;
};
@@ -92,7 +90,7 @@ static void collect_encoder(OSSL_ENCODER *encoder, void *arg)
if (data->error_occurred)
return;
- data->error_occurred = 1; /* Assume the worst */
+ data->error_occurred = 1; /* Assume the worst */
prov = OSSL_ENCODER_get0_provider(encoder);
/*
@@ -111,7 +109,7 @@ static void collect_encoder(OSSL_ENCODER *encoder, void *arg)
match = (data->id_names[i] == encoder->base.id);
else
match = OSSL_ENCODER_is_a(encoder,
- sk_OPENSSL_CSTRING_value(data->names, i));
+ sk_OPENSSL_CSTRING_value(data->names, i));
if (!match
|| (encoder->does_selection != NULL
&& !encoder->does_selection(provctx, data->ctx->selection))
@@ -125,12 +123,12 @@ static void collect_encoder(OSSL_ENCODER *encoder, void *arg)
}
}
- data->error_occurred = 0; /* All is good now */
+ data->error_occurred = 0; /* All is good now */
}
struct collected_names_st {
STACK_OF(OPENSSL_CSTRING) *names;
- unsigned int error_occurred:1;
+ unsigned int error_occurred : 1;
};
static void collect_name(const char *name, void *arg)
@@ -140,12 +138,12 @@ static void collect_name(const char *name, void *arg)
if (data->error_occurred)
return;
- data->error_occurred = 1; /* Assume the worst */
+ data->error_occurred = 1; /* Assume the worst */
if (sk_OPENSSL_CSTRING_push(data->names, name) <= 0)
return;
- data->error_occurred = 0; /* All is good now */
+ data->error_occurred = 0; /* All is good now */
}
/*
@@ -170,8 +168,7 @@ static int encoder_import_cb(const OSSL_PARAM params[], void *arg)
OSSL_ENCODER *encoder = OSSL_ENCODER_INSTANCE_get_encoder(encoder_inst);
void *encoderctx = OSSL_ENCODER_INSTANCE_get_encoder_ctx(encoder_inst);
- construct_data->constructed_obj =
- encoder->import_object(encoderctx, construct_data->selection, params);
+ construct_data->constructed_obj = encoder->import_object(encoderctx, construct_data->selection, params);
return (construct_data->constructed_obj != NULL);
}
@@ -182,8 +179,7 @@ encoder_construct_pkey(OSSL_ENCODER_INSTANCE *encoder_inst, void *arg)
struct construct_data_st *data = arg;
if (data->obj == NULL) {
- OSSL_ENCODER *encoder =
- OSSL_ENCODER_INSTANCE_get_encoder(encoder_inst);
+ OSSL_ENCODER *encoder = OSSL_ENCODER_INSTANCE_get_encoder(encoder_inst);
const EVP_PKEY *pk = data->pk;
const OSSL_PROVIDER *k_prov = EVP_KEYMGMT_get0_provider(pk->keymgmt);
const OSSL_PROVIDER *e_prov = OSSL_ENCODER_get0_provider(encoder);
@@ -196,7 +192,7 @@ encoder_construct_pkey(OSSL_ENCODER_INSTANCE *encoder_inst, void *arg)
data->encoder_inst = encoder_inst;
if (!evp_keymgmt_export(pk->keymgmt, pk->keydata, selection,
- &encoder_import_cb, data))
+ &encoder_import_cb, data))
return NULL;
data->obj = data->constructed_obj;
} else {
@@ -213,8 +209,7 @@ static void encoder_destruct_pkey(void *arg)
int match = (data->obj == data->constructed_obj);
if (data->encoder_inst != NULL) {
- OSSL_ENCODER *encoder =
- OSSL_ENCODER_INSTANCE_get_encoder(data->encoder_inst);
+ OSSL_ENCODER *encoder = OSSL_ENCODER_INSTANCE_get_encoder(data->encoder_inst);
encoder->free_object(data->constructed_obj);
}
@@ -230,9 +225,9 @@ static void encoder_destruct_pkey(void *arg)
* and to use fallback methods if the result is NULL.
*/
static int ossl_encoder_ctx_setup_for_pkey(OSSL_ENCODER_CTX *ctx,
- const EVP_PKEY *pkey,
- int selection,
- const char *propquery)
+ const EVP_PKEY *pkey,
+ int selection,
+ const char *propquery)
{
struct construct_data_st *data = NULL;
const OSSL_PROVIDER *prov = NULL;
@@ -332,11 +327,11 @@ static int ossl_encoder_ctx_setup_for_pkey(OSSL_ENCODER_CTX *ctx,
data->pk = pkey;
data->selection = selection;
- data = NULL; /* Avoid it being freed */
+ data = NULL; /* Avoid it being freed */
}
ok = 1;
- err:
+err:
if (data != NULL) {
OSSL_ENCODER_CTX_set_construct_data(ctx, NULL);
OPENSSL_free(data);
@@ -345,10 +340,10 @@ static int ossl_encoder_ctx_setup_for_pkey(OSSL_ENCODER_CTX *ctx,
}
OSSL_ENCODER_CTX *OSSL_ENCODER_CTX_new_for_pkey(const EVP_PKEY *pkey,
- int selection,
- const char *output_type,
- const char *output_struct,
- const char *propquery)
+ int selection,
+ const char *output_type,
+ const char *output_struct,
+ const char *propquery)
{
OSSL_ENCODER_CTX *ctx = NULL;
OSSL_LIB_CTX *libctx = NULL;
@@ -360,7 +355,7 @@ OSSL_ENCODER_CTX *OSSL_ENCODER_CTX_new_for_pkey(const EVP_PKEY *pkey,
if (!evp_pkey_is_assigned(pkey)) {
ERR_raise_data(ERR_LIB_OSSL_ENCODER, ERR_R_PASSED_INVALID_ARGUMENT,
- "The passed EVP_PKEY must be assigned a key");
+ "The passed EVP_PKEY must be assigned a key");
return NULL;
}
@@ -375,13 +370,15 @@ OSSL_ENCODER_CTX *OSSL_ENCODER_CTX_new_for_pkey(const EVP_PKEY *pkey,
libctx = ossl_provider_libctx(prov);
}
- OSSL_TRACE_BEGIN(ENCODER) {
+ OSSL_TRACE_BEGIN(ENCODER)
+ {
BIO_printf(trc_out,
- "(ctx %p) Looking for %s encoders with selection %d\n",
- (void *)ctx, EVP_PKEY_get0_type_name(pkey), selection);
+ "(ctx %p) Looking for %s encoders with selection %d\n",
+ (void *)ctx, EVP_PKEY_get0_type_name(pkey), selection);
BIO_printf(trc_out, " output type: %s, output structure: %s\n",
- output_type, output_struct);
- } OSSL_TRACE_END(ENCODER);
+ output_type, output_struct);
+ }
+ OSSL_TRACE_END(ENCODER);
if (OSSL_ENCODER_CTX_set_output_type(ctx, output_type)
&& (output_struct == NULL
@@ -393,14 +390,16 @@ OSSL_ENCODER_CTX *OSSL_ENCODER_CTX_new_for_pkey(const EVP_PKEY *pkey,
int save_parameters = pkey->save_parameters;
params[0] = OSSL_PARAM_construct_int(OSSL_ENCODER_PARAM_SAVE_PARAMETERS,
- &save_parameters);
+ &save_parameters);
/* ignoring error as this is only auxiliary parameter */
(void)OSSL_ENCODER_CTX_set_params(ctx, params);
- OSSL_TRACE_BEGIN(ENCODER) {
+ OSSL_TRACE_BEGIN(ENCODER)
+ {
BIO_printf(trc_out, "(ctx %p) Got %d encoders\n",
- (void *)ctx, OSSL_ENCODER_CTX_get_num_encoders(ctx));
- } OSSL_TRACE_END(ENCODER);
+ (void *)ctx, OSSL_ENCODER_CTX_get_num_encoders(ctx));
+ }
+ OSSL_TRACE_END(ENCODER);
return ctx;
}