struct collected_data_st {
struct decoder_EVP_PKEY_data_st *process_data;
+ const char *keytype;
STACK_OF(OPENSSL_CSTRING) *names;
OSSL_DECODER_CTX *ctx;
{
struct collected_data_st *data = arg;
+ if (data->keytype != NULL && !EVP_KEYMGMT_is_a(keymgmt, data->keytype))
+ return;
if (data->error_occured)
return;
}
int ossl_decoder_ctx_setup_for_EVP_PKEY(OSSL_DECODER_CTX *ctx,
- EVP_PKEY **pkey,
+ EVP_PKEY **pkey, const char *keytype,
OPENSSL_CTX *libctx,
const char *propquery)
{
if ((data = OPENSSL_zalloc(sizeof(*data))) == NULL
|| (data->process_data =
OPENSSL_zalloc(sizeof(*data->process_data))) == NULL
- || (data->process_data->keymgmts
- = sk_EVP_KEYMGMT_new_null()) == NULL
+ || (data->process_data->keymgmts = sk_EVP_KEYMGMT_new_null()) == NULL
|| (data->names = sk_OPENSSL_CSTRING_new_null()) == NULL) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_MALLOC_FAILURE);
goto err;
}
data->process_data->object = (void **)pkey;
data->ctx = ctx;
+ data->keytype = keytype;
/* First, find all keymgmts to form goals */
EVP_KEYMGMT_do_all_provided(libctx, collect_keymgmt, data);
return ok;
}
-OSSL_DECODER_CTX *OSSL_DECODER_CTX_new_by_EVP_PKEY(EVP_PKEY **pkey,
- const char *input_type,
- OPENSSL_CTX *libctx,
- const char *propquery)
+OSSL_DECODER_CTX *
+OSSL_DECODER_CTX_new_by_EVP_PKEY(EVP_PKEY **pkey,
+ const char *input_type, const char *keytype,
+ OPENSSL_CTX *libctx, const char *propquery)
{
OSSL_DECODER_CTX *ctx = NULL;
return NULL;
}
if (OSSL_DECODER_CTX_set_input_type(ctx, input_type)
- && ossl_decoder_ctx_setup_for_EVP_PKEY(ctx, pkey, libctx, propquery)
+ && ossl_decoder_ctx_setup_for_EVP_PKEY(ctx, pkey, keytype,
+ libctx, propquery)
&& OSSL_DECODER_CTX_add_extra(ctx, libctx, propquery))
return ctx;
if (membio == NULL)
return 0;
- decoderctx = OSSL_DECODER_CTX_new_by_EVP_PKEY(&pk, "DER", libctx, propq);
+ decoderctx =
+ OSSL_DECODER_CTX_new_by_EVP_PKEY(&pk, "DER", NULL, libctx, propq);
(void)OSSL_DECODER_CTX_set_passphrase_cb(decoderctx, cb, cbarg);
/* No error if this couldn't be decoded */
#include <openssl/decoder.h>
OSSL_DECODER_CTX *
- OSSL_DECODER_CTX_new_by_EVP_PKEY(const EVP_PKEY *pkey, const char *input_type,
+ OSSL_DECODER_CTX_new_by_EVP_PKEY(const EVP_PKEY *pkey,
+ const char *input_type, const char *keytype,
OPENSSL_CTX *libctx, const char *propquery);
int OSSL_DECODER_CTX_set_passphrase(OSSL_DECODER_CTX *ctx,
fetched using I<libctx> and I<propquery>.
The search of decoder implementations can be limited with I<input_type>,
-which specifies a starting input type. This is further explained in
-L<OSSL_DECODER_CTX_set_input_type(3)>.
+which specifies a starting input type. NULL is valid input and signifies
+that the decoder implementations will find out the input type on their own.
+This is further explained in L<OSSL_DECODER_CTX_set_input_type(3)>.
+
+The search of decoder implementations can also be limited with I<keytype>,
+which specifies the expected resulting keytype. NULL is valid input and
+signifies that the decoder implementations will find out the keytype on
+their own from the input they get.
If no suitable decoder implementation is found,
OSSL_DECODER_CTX_new_by_EVP_PKEY() still creates a B<OSSL_DECODER_CTX>, but
OSSL_DECODER_INSTANCE *di);
int ossl_decoder_ctx_setup_for_EVP_PKEY(OSSL_DECODER_CTX *ctx,
- EVP_PKEY **pkey,
+ EVP_PKEY **pkey, const char *keytype,
OPENSSL_CTX *libctx,
const char *propquery);
* an implicit OSSL_DECODER_fetch(), suitable for the object of that type.
*/
OSSL_DECODER_CTX *
-OSSL_DECODER_CTX_new_by_EVP_PKEY(EVP_PKEY **pkey, const char *input_type,
+OSSL_DECODER_CTX_new_by_EVP_PKEY(EVP_PKEY **pkey,
+ const char *input_type, const char *keytype,
OPENSSL_CTX *libctx, const char *propquery);
# ifdef __cplusplus
* Since we're setting up our own constructor, we don't need to care
* more than that...
*/
- if (!ossl_decoder_ctx_setup_for_EVP_PKEY(ctx->_.file.decoderctx, &dummy,
+ if (!ossl_decoder_ctx_setup_for_EVP_PKEY(ctx->_.file.decoderctx,
+ &dummy, NULL,
libctx, ctx->_.file.propq)
|| !OSSL_DECODER_CTX_add_extra(ctx->_.file.decoderctx,
libctx, ctx->_.file.propq)) {
const unsigned char *upass = (const unsigned char *)pass;
int ok = 0;
- if (!TEST_ptr(dctx = OSSL_DECODER_CTX_new_by_EVP_PKEY(&pkey, NULL,
+ if (!TEST_ptr(dctx = OSSL_DECODER_CTX_new_by_EVP_PKEY(&pkey, NULL, NULL,
NULL, NULL))
|| (pass != NULL
&& !OSSL_DECODER_CTX_set_passphrase(dctx, upass, strlen(pass)))