aboutsummaryrefslogtreecommitdiff
path: root/crypto/encode_decode/decoder_meth.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/encode_decode/decoder_meth.c')
-rw-r--r--crypto/encode_decode/decoder_meth.c90
1 files changed, 41 insertions, 49 deletions
diff --git a/crypto/encode_decode/decoder_meth.c b/crypto/encode_decode/decoder_meth.c
index 56899a926981..ee6f30ecd953 100644
--- a/crypto/encode_decode/decoder_meth.c
+++ b/crypto/encode_decode/decoder_meth.c
@@ -76,7 +76,6 @@ static void *decoder_store_new(OSSL_LIB_CTX *ctx)
return ossl_method_store_new(ctx);
}
-
static const OSSL_LIB_CTX_METHOD decoder_store_method = {
/* We want decoder_store to be cleaned up before the provider store */
OSSL_LIB_CTX_METHOD_PRIORITY_2,
@@ -87,9 +86,9 @@ static const OSSL_LIB_CTX_METHOD decoder_store_method = {
/* 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() */
@@ -121,7 +120,7 @@ static void dealloc_tmp_decoder_store(void *store)
static OSSL_METHOD_STORE *get_decoder_store(OSSL_LIB_CTX *libctx)
{
return ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_DECODER_STORE_INDEX,
- &decoder_store_method);
+ &decoder_store_method);
}
static int reserve_decoder_store(void *store, void *data)
@@ -148,7 +147,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;
@@ -183,9 +182,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;
@@ -212,13 +211,13 @@ static int put_decoder_in_store(void *store, void *method,
return 0;
return ossl_method_store_add(store, prov, id, propdef, method,
- (int (*)(void *))OSSL_DECODER_up_ref,
- (void (*)(void *))OSSL_DECODER_free);
+ (int (*)(void *))OSSL_DECODER_up_ref,
+ (void (*)(void *))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;
@@ -233,7 +232,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;
}
@@ -250,28 +250,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)
@@ -289,7 +284,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);
@@ -305,14 +300,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
@@ -360,7 +354,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, int id,
- 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);
@@ -410,8 +404,9 @@ inner_ossl_decoder_fetch(struct decoder_data_st *methdata, int id,
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
@@ -422,7 +417,7 @@ inner_ossl_decoder_fetch(struct decoder_data_st *methdata, int id,
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);
}
/*
@@ -438,17 +433,17 @@ inner_ossl_decoder_fetch(struct decoder_data_st *methdata, int id,
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;
@@ -461,7 +456,7 @@ OSSL_DECODER *OSSL_DECODER_fetch(OSSL_LIB_CTX *libctx, const char *name,
}
OSSL_DECODER *ossl_decoder_fetch_by_number(OSSL_LIB_CTX *libctx, int id,
- const char *properties)
+ const char *properties)
{
struct decoder_data_st methdata;
void *method;
@@ -571,9 +566,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;
@@ -591,8 +586,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;
@@ -657,7 +652,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;
@@ -673,12 +668,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;
@@ -694,7 +686,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);
}