mirror of
https://github.com/openssl/openssl.git
synced 2025-02-23 14:42:15 +08:00
EVP: Make evp_pkey_ctx_state() available to all of EVP
This will help with transitioning diverse functions to be able to use the ctrl<->OSSL_PARAM translators. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13913)
This commit is contained in:
parent
6179dfc7c4
commit
e19246dc72
@ -135,31 +135,6 @@ EVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags)
|
||||
return pmeth;
|
||||
}
|
||||
|
||||
/* Three possible states: */
|
||||
# define EVP_PKEY_STATE_UNKNOWN 0
|
||||
# define EVP_PKEY_STATE_LEGACY 1
|
||||
# define EVP_PKEY_STATE_PROVIDER 2
|
||||
|
||||
static int evp_pkey_ctx_state(EVP_PKEY_CTX *ctx)
|
||||
{
|
||||
if (ctx->operation == EVP_PKEY_OP_UNDEFINED)
|
||||
return EVP_PKEY_STATE_UNKNOWN;
|
||||
|
||||
if ((EVP_PKEY_CTX_IS_DERIVE_OP(ctx)
|
||||
&& ctx->op.kex.exchprovctx != NULL)
|
||||
|| (EVP_PKEY_CTX_IS_SIGNATURE_OP(ctx)
|
||||
&& ctx->op.sig.sigprovctx != NULL)
|
||||
|| (EVP_PKEY_CTX_IS_ASYM_CIPHER_OP(ctx)
|
||||
&& ctx->op.ciph.ciphprovctx != NULL)
|
||||
|| (EVP_PKEY_CTX_IS_GEN_OP(ctx)
|
||||
&& ctx->op.keymgmt.genctx != NULL)
|
||||
|| (EVP_PKEY_CTX_IS_KEM_OP(ctx)
|
||||
&& ctx->op.encap.kemprovctx != NULL))
|
||||
return EVP_PKEY_STATE_PROVIDER;
|
||||
|
||||
return EVP_PKEY_STATE_LEGACY;
|
||||
}
|
||||
|
||||
static void help_get_legacy_alg_type_from_keymgmt(const char *keytype,
|
||||
void *arg)
|
||||
{
|
||||
@ -179,6 +154,26 @@ static int get_legacy_alg_type_from_keymgmt(const EVP_KEYMGMT *keymgmt)
|
||||
}
|
||||
#endif /* FIPS_MODULE */
|
||||
|
||||
int evp_pkey_ctx_state(const EVP_PKEY_CTX *ctx)
|
||||
{
|
||||
if (ctx->operation == EVP_PKEY_OP_UNDEFINED)
|
||||
return EVP_PKEY_STATE_UNKNOWN;
|
||||
|
||||
if ((EVP_PKEY_CTX_IS_DERIVE_OP(ctx)
|
||||
&& ctx->op.kex.exchprovctx != NULL)
|
||||
|| (EVP_PKEY_CTX_IS_SIGNATURE_OP(ctx)
|
||||
&& ctx->op.sig.sigprovctx != NULL)
|
||||
|| (EVP_PKEY_CTX_IS_ASYM_CIPHER_OP(ctx)
|
||||
&& ctx->op.ciph.ciphprovctx != NULL)
|
||||
|| (EVP_PKEY_CTX_IS_GEN_OP(ctx)
|
||||
&& ctx->op.keymgmt.genctx != NULL)
|
||||
|| (EVP_PKEY_CTX_IS_KEM_OP(ctx)
|
||||
&& ctx->op.encap.kemprovctx != NULL))
|
||||
return EVP_PKEY_STATE_PROVIDER;
|
||||
|
||||
return EVP_PKEY_STATE_LEGACY;
|
||||
}
|
||||
|
||||
static EVP_PKEY_CTX *int_ctx_new(OSSL_LIB_CTX *libctx,
|
||||
EVP_PKEY *pkey, ENGINE *e,
|
||||
const char *keytype, const char *propquery,
|
||||
|
@ -858,4 +858,10 @@ EVP_PKEY *evp_privatekey_from_binary(int keytype, EVP_PKEY **a,
|
||||
const unsigned char **pp, long length,
|
||||
OSSL_LIB_CTX *libctx, const char *propq);
|
||||
|
||||
/* Three possible states: */
|
||||
# define EVP_PKEY_STATE_UNKNOWN 0
|
||||
# define EVP_PKEY_STATE_LEGACY 1
|
||||
# define EVP_PKEY_STATE_PROVIDER 2
|
||||
int evp_pkey_ctx_state(const EVP_PKEY_CTX *ctx);
|
||||
|
||||
#endif /* OSSL_CRYPTO_EVP_H */
|
||||
|
Loading…
Reference in New Issue
Block a user