return (sk_OSSL_DECODER_INSTANCE_push(ctx->decoder_insts, di) > 0);
}
-int OSSL_DECODER_CTX_add_decoder(OSSL_DECODER_CTX *ctx,
- OSSL_DECODER *decoder)
+int OSSL_DECODER_CTX_add_decoder(OSSL_DECODER_CTX *ctx, OSSL_DECODER *decoder)
{
OSSL_DECODER_INSTANCE *decoder_inst = NULL;
const OSSL_PROVIDER *prov = NULL;
for (i = w_prev_start; i < w_prev_end; i++) {
OSSL_DECODER_INSTANCE *decoder_inst =
sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts, i);
- const char *name = decoder_inst->input_type;
+ const char *input_type =
+ OSSL_DECODER_INSTANCE_get_input_type(decoder_inst);
OSSL_DECODER *decoder = NULL;
/*
* on top of this one, so we don't.
*/
if (ctx->start_input_type != NULL
- && strcasecmp(ctx->start_input_type,
- decoder_inst->input_type) != 0)
+ && strcasecmp(ctx->start_input_type, input_type) != 0)
continue;
ERR_set_mark();
- decoder = OSSL_DECODER_fetch(libctx, name, propq);
+ decoder = OSSL_DECODER_fetch(libctx, input_type, propq);
ERR_pop_to_mark();
if (decoder != NULL) {
return 1;
}
-int OSSL_DECODER_CTX_num_decoders(OSSL_DECODER_CTX *ctx)
+int OSSL_DECODER_CTX_get_num_decoders(OSSL_DECODER_CTX *ctx)
{
if (ctx == NULL || ctx->decoder_insts == NULL)
return 0;
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)
return 0;
}
- return decoder_inst->decoder->export_object(decoder_inst->decoderctx,
- reference, reference_sz,
- export_cb, export_cbarg);
+ 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);
}
-OSSL_DECODER *OSSL_DECODER_INSTANCE_decoder(OSSL_DECODER_INSTANCE *decoder_inst)
+OSSL_DECODER *
+OSSL_DECODER_INSTANCE_get_decoder(OSSL_DECODER_INSTANCE *decoder_inst)
{
if (decoder_inst == NULL)
return NULL;
return decoder_inst->decoder;
}
-void *OSSL_DECODER_INSTANCE_decoder_ctx(OSSL_DECODER_INSTANCE *decoder_inst)
+void *
+OSSL_DECODER_INSTANCE_get_decoder_ctx(OSSL_DECODER_INSTANCE *decoder_inst)
{
if (decoder_inst == NULL)
return NULL;
return decoder_inst->decoderctx;
}
+const char *
+OSSL_DECODER_INSTANCE_get_input_type(OSSL_DECODER_INSTANCE *decoder_inst)
+{
+ if (decoder_inst == NULL)
+ return NULL;
+ return decoder_inst->input_type;
+}
+
static int decoder_process(const OSSL_PARAM params[], void *arg)
{
struct decoder_process_data_st *data = arg;
/* First iteration, where we prepare for what is to come */
data->current_decoder_inst_index =
- OSSL_DECODER_CTX_num_decoders(ctx);
+ OSSL_DECODER_CTX_get_num_decoders(ctx);
bio = data->bio;
} else {
decoder_inst =
sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts,
data->current_decoder_inst_index);
- decoder = OSSL_DECODER_INSTANCE_decoder(decoder_inst);
+ decoder = OSSL_DECODER_INSTANCE_get_decoder(decoder_inst);
if (ctx->construct != NULL
&& ctx->construct(decoder_inst, params, ctx->construct_data)) {
OSSL_DECODER_INSTANCE *new_decoder_inst =
sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts, i);
OSSL_DECODER *new_decoder =
- OSSL_DECODER_INSTANCE_decoder(new_decoder_inst);
+ OSSL_DECODER_INSTANCE_get_decoder(new_decoder_inst);
+ 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);
/*
* If |decoder| is NULL, it means we've just started, and the caller
* that's the case, we do this extra check.
*/
if (decoder == NULL && ctx->start_input_type != NULL
- && strcasecmp(ctx->start_input_type,
- new_decoder_inst->input_type) != 0)
+ && strcasecmp(ctx->start_input_type, new_input_type) != 0)
continue;
/*
* If we have a previous decoder, we check that the input type
* of the next to be used matches the type of this previous one.
- * decoder_inst->input_type is a cache of the parameter "input-type"
- * value for that decoder.
+ * input_type is a cache of the parameter "input-type" value for
+ * that decoder.
*/
- if (decoder != NULL
- && !OSSL_DECODER_is_a(decoder, new_decoder_inst->input_type))
+ if (decoder != NULL && !OSSL_DECODER_is_a(decoder, new_input_type))
continue;
/*
/* Recurse */
new_data.current_decoder_inst_index = i;
- ok = new_decoder->decode(new_decoder_inst->decoderctx,
- (OSSL_CORE_BIO *)bio,
+ ok = new_decoder->decode(new_decoderctx, (OSSL_CORE_BIO *)bio,
decoder_process, &new_data,
ossl_pw_passphrase_callback_dec,
&new_data.ctx->pwdata);