diff options
author | Matt Caswell <matt@openssl.org> | 2019-09-04 23:13:25 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2019-09-09 14:00:00 +0100 |
commit | 864b89ce497c57207d04a83e23f96f50dae9d164 (patch) | |
tree | 4db50f1c6e8bad0a30aa05aba423c0055ffb2b89 /crypto/include | |
parent | 9c45222ddc36124b8826d98dc0794f3eef1e5f0b (diff) |
Move EVP_PKEY algorithm implementations into a union
An EVP_PKEY can be used for multiple different algorithm operations.
Only one can be used at a time, so we move those into a union.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9753)
Diffstat (limited to 'crypto/include')
-rw-r--r-- | crypto/include/internal/evp_int.h | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/crypto/include/internal/evp_int.h b/crypto/include/internal/evp_int.h index 2b49e68c70..caf0ca1dd9 100644 --- a/crypto/include/internal/evp_int.h +++ b/crypto/include/internal/evp_int.h @@ -18,11 +18,20 @@ #define EVP_MD_CTX_FLAG_KEEP_PKEY_CTX 0x0400 struct evp_pkey_ctx_st { - EVP_KEYEXCH *exchange; - void *exchprovctx; + /* Actual operation */ + int operation; + + union { + struct { + EVP_KEYEXCH *exchange; + void *exchprovctx; + } kex; - EVP_SIGNATURE *signature; - void *sigprovctx; + struct { + EVP_SIGNATURE *signature; + void *sigprovctx; + } sig; + } op; /* Legacy fields below */ @@ -34,8 +43,6 @@ struct evp_pkey_ctx_st { EVP_PKEY *pkey; /* Peer key for key agreement, may be NULL */ EVP_PKEY *peerkey; - /* Actual operation */ - int operation; /* Algorithm specific data */ void *data; /* Application specific data */ @@ -550,6 +557,15 @@ struct evp_pkey_st { size_t dirty_cnt_copy; } /* EVP_PKEY */ ; +#define EVP_PKEY_CTX_IS_SIGNATURE_OP(ctx) \ + ((ctx)->operation == EVP_PKEY_OP_SIGN \ + || (ctx)->operation == EVP_PKEY_OP_SIGNCTX \ + || (ctx)->operation == EVP_PKEY_OP_VERIFY \ + || (ctx)->operation == EVP_PKEY_OP_VERIFYCTX \ + || (ctx)->operation == EVP_PKEY_OP_VERIFYRECOVER) + +#define EVP_PKEY_CTX_IS_DERIVE_OP(ctx) \ + ((ctx)->operation == EVP_PKEY_OP_DERIVE) void openssl_add_all_ciphers_int(void); void openssl_add_all_digests_int(void); |