2015-03-24 06:57:47 +08:00
|
|
|
/*
|
2018-02-27 21:37:28 +08:00
|
|
|
* Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
|
2015-03-24 06:57:47 +08:00
|
|
|
*
|
2018-12-06 20:12:35 +08:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-18 03:38:09 +08:00
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
2015-03-24 06:57:47 +08:00
|
|
|
*/
|
|
|
|
|
2018-04-09 22:06:50 +08:00
|
|
|
#include <openssl/evp.h>
|
2019-03-13 22:49:40 +08:00
|
|
|
#include <openssl/core_numbers.h>
|
2016-08-27 22:01:08 +08:00
|
|
|
#include "internal/refcount.h"
|
|
|
|
|
2018-09-04 17:21:10 +08:00
|
|
|
/*
|
|
|
|
* Don't free up md_ctx->pctx in EVP_MD_CTX_reset, use the reserved flag
|
|
|
|
* values in evp.h
|
|
|
|
*/
|
|
|
|
#define EVP_MD_CTX_FLAG_KEEP_PKEY_CTX 0x0400
|
|
|
|
|
2015-03-24 06:57:47 +08:00
|
|
|
struct evp_pkey_ctx_st {
|
2019-09-05 06:13:25 +08:00
|
|
|
/* Actual operation */
|
|
|
|
int operation;
|
|
|
|
|
2019-11-01 23:56:31 +08:00
|
|
|
/*
|
2019-12-18 20:24:27 +08:00
|
|
|
* Library context, Key type name and properties associated
|
2019-11-01 23:56:31 +08:00
|
|
|
* with this context
|
|
|
|
*/
|
|
|
|
OPENSSL_CTX *libctx;
|
2019-12-18 20:24:27 +08:00
|
|
|
const char *keytype;
|
2019-10-15 19:08:17 +08:00
|
|
|
const char *propquery;
|
|
|
|
|
2019-10-31 01:03:07 +08:00
|
|
|
/* cached key manager */
|
|
|
|
EVP_KEYMGMT *keymgmt;
|
|
|
|
|
2019-09-05 06:13:25 +08:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
EVP_KEYEXCH *exchange;
|
|
|
|
void *exchprovctx;
|
|
|
|
} kex;
|
2019-06-27 17:48:17 +08:00
|
|
|
|
2019-09-05 06:13:25 +08:00
|
|
|
struct {
|
|
|
|
EVP_SIGNATURE *signature;
|
|
|
|
void *sigprovctx;
|
|
|
|
} sig;
|
2019-10-01 16:40:57 +08:00
|
|
|
|
|
|
|
struct {
|
|
|
|
EVP_ASYM_CIPHER *cipher;
|
|
|
|
void *ciphprovctx;
|
|
|
|
} ciph;
|
2019-09-05 06:13:25 +08:00
|
|
|
} op;
|
2019-08-30 20:33:10 +08:00
|
|
|
|
2019-06-27 17:48:17 +08:00
|
|
|
/* Legacy fields below */
|
|
|
|
|
2015-03-24 06:57:47 +08:00
|
|
|
/* Method associated with this operation */
|
|
|
|
const EVP_PKEY_METHOD *pmeth;
|
|
|
|
/* Engine that implements this method or NULL if builtin */
|
|
|
|
ENGINE *engine;
|
|
|
|
/* Key: may be NULL */
|
|
|
|
EVP_PKEY *pkey;
|
|
|
|
/* Peer key for key agreement, may be NULL */
|
|
|
|
EVP_PKEY *peerkey;
|
|
|
|
/* Algorithm specific data */
|
|
|
|
void *data;
|
|
|
|
/* Application specific data */
|
|
|
|
void *app_data;
|
|
|
|
/* Keygen callback */
|
|
|
|
EVP_PKEY_gen_cb *pkey_gencb;
|
|
|
|
/* implementation specific keygen data */
|
|
|
|
int *keygen_info;
|
|
|
|
int keygen_info_count;
|
|
|
|
} /* EVP_PKEY_CTX */ ;
|
|
|
|
|
|
|
|
#define EVP_PKEY_FLAG_DYNAMIC 1
|
|
|
|
|
|
|
|
struct evp_pkey_method_st {
|
|
|
|
int pkey_id;
|
|
|
|
int flags;
|
|
|
|
int (*init) (EVP_PKEY_CTX *ctx);
|
2019-01-16 04:51:25 +08:00
|
|
|
int (*copy) (EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src);
|
2015-03-24 06:57:47 +08:00
|
|
|
void (*cleanup) (EVP_PKEY_CTX *ctx);
|
|
|
|
int (*paramgen_init) (EVP_PKEY_CTX *ctx);
|
|
|
|
int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
|
|
|
|
int (*keygen_init) (EVP_PKEY_CTX *ctx);
|
|
|
|
int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
|
|
|
|
int (*sign_init) (EVP_PKEY_CTX *ctx);
|
|
|
|
int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
|
|
|
|
const unsigned char *tbs, size_t tbslen);
|
|
|
|
int (*verify_init) (EVP_PKEY_CTX *ctx);
|
|
|
|
int (*verify) (EVP_PKEY_CTX *ctx,
|
|
|
|
const unsigned char *sig, size_t siglen,
|
|
|
|
const unsigned char *tbs, size_t tbslen);
|
|
|
|
int (*verify_recover_init) (EVP_PKEY_CTX *ctx);
|
|
|
|
int (*verify_recover) (EVP_PKEY_CTX *ctx,
|
|
|
|
unsigned char *rout, size_t *routlen,
|
|
|
|
const unsigned char *sig, size_t siglen);
|
|
|
|
int (*signctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
|
|
|
|
int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
|
|
|
|
EVP_MD_CTX *mctx);
|
|
|
|
int (*verifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
|
|
|
|
int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen,
|
|
|
|
EVP_MD_CTX *mctx);
|
|
|
|
int (*encrypt_init) (EVP_PKEY_CTX *ctx);
|
|
|
|
int (*encrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
|
|
|
|
const unsigned char *in, size_t inlen);
|
|
|
|
int (*decrypt_init) (EVP_PKEY_CTX *ctx);
|
|
|
|
int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
|
|
|
|
const unsigned char *in, size_t inlen);
|
|
|
|
int (*derive_init) (EVP_PKEY_CTX *ctx);
|
|
|
|
int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
|
|
|
|
int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, void *p2);
|
|
|
|
int (*ctrl_str) (EVP_PKEY_CTX *ctx, const char *type, const char *value);
|
2017-05-20 04:31:46 +08:00
|
|
|
int (*digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen,
|
|
|
|
const unsigned char *tbs, size_t tbslen);
|
|
|
|
int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig,
|
|
|
|
size_t siglen, const unsigned char *tbs,
|
|
|
|
size_t tbslen);
|
2017-09-04 22:02:59 +08:00
|
|
|
int (*check) (EVP_PKEY *pkey);
|
2017-11-01 00:45:24 +08:00
|
|
|
int (*public_check) (EVP_PKEY *pkey);
|
|
|
|
int (*param_check) (EVP_PKEY *pkey);
|
2018-09-04 00:51:04 +08:00
|
|
|
|
|
|
|
int (*digest_custom) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
|
2015-03-24 06:57:47 +08:00
|
|
|
} /* EVP_PKEY_METHOD */ ;
|
|
|
|
|
2016-01-08 01:02:20 +08:00
|
|
|
DEFINE_STACK_OF_CONST(EVP_PKEY_METHOD)
|
2016-01-06 10:54:18 +08:00
|
|
|
|
2015-03-24 06:57:47 +08:00
|
|
|
void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx);
|
2015-09-20 05:13:22 +08:00
|
|
|
|
2019-09-19 21:31:27 +08:00
|
|
|
const EVP_PKEY_METHOD *cmac_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *dh_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *dhx_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *dsa_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *ec_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *sm2_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *ecx25519_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *ecx448_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *ed25519_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *ed448_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *hmac_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *rsa_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *rsa_pss_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *scrypt_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *tls1_prf_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *hkdf_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *poly1305_pkey_method(void);
|
|
|
|
const EVP_PKEY_METHOD *siphash_pkey_method(void);
|
2015-11-30 03:09:34 +08:00
|
|
|
|
2018-10-13 04:27:18 +08:00
|
|
|
struct evp_mac_st {
|
2019-05-07 18:39:58 +08:00
|
|
|
OSSL_PROVIDER *prov;
|
In provider implemented methods, save the name number, not the name string
Multiple names per implementation is already supported in the namemap,
but hasn't been used yet. However, as soon as we have multiple names,
we will get an issue with what name should be saved in the method.
The solution is to not save the name itself, but rather the number
it's associated with. This number is supposed to be unique for each
set of names, and we assume that algorithm names are globally unique,
i.e. there can be no name overlap between different algorithm types.
Incidently, it was also found that the 'get' function used by
ossl_construct_method() doesn't need all the parameters it was given;
most of what it needs, it can now get through the data structure given
by the caller of ossl_construct_method(). As a consequence,
ossl_construct_method() itself doesn't need all the parameters it was
given either.
There are some added internal functions that are expected to disappear
as soon as legacy code is removed, such as evp_first_name() and
ossl_namemap_num2name().
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9897)
2019-09-14 22:22:19 +08:00
|
|
|
int name_id;
|
2019-05-07 18:39:58 +08:00
|
|
|
|
|
|
|
CRYPTO_REF_COUNT refcnt;
|
|
|
|
CRYPTO_RWLOCK *lock;
|
|
|
|
|
|
|
|
OSSL_OP_mac_newctx_fn *newctx;
|
|
|
|
OSSL_OP_mac_dupctx_fn *dupctx;
|
|
|
|
OSSL_OP_mac_freectx_fn *freectx;
|
|
|
|
OSSL_OP_mac_size_fn *size;
|
|
|
|
OSSL_OP_mac_init_fn *init;
|
|
|
|
OSSL_OP_mac_update_fn *update;
|
|
|
|
OSSL_OP_mac_final_fn *final;
|
|
|
|
OSSL_OP_mac_gettable_params_fn *gettable_params;
|
|
|
|
OSSL_OP_mac_gettable_ctx_params_fn *gettable_ctx_params;
|
|
|
|
OSSL_OP_mac_settable_ctx_params_fn *settable_ctx_params;
|
|
|
|
OSSL_OP_mac_get_params_fn *get_params;
|
2019-08-16 15:04:29 +08:00
|
|
|
OSSL_OP_mac_get_ctx_params_fn *get_ctx_params;
|
|
|
|
OSSL_OP_mac_set_ctx_params_fn *set_ctx_params;
|
2018-10-13 04:27:18 +08:00
|
|
|
};
|
|
|
|
|
2019-04-22 15:18:56 +08:00
|
|
|
struct evp_kdf_st {
|
2019-08-21 16:54:35 +08:00
|
|
|
OSSL_PROVIDER *prov;
|
In provider implemented methods, save the name number, not the name string
Multiple names per implementation is already supported in the namemap,
but hasn't been used yet. However, as soon as we have multiple names,
we will get an issue with what name should be saved in the method.
The solution is to not save the name itself, but rather the number
it's associated with. This number is supposed to be unique for each
set of names, and we assume that algorithm names are globally unique,
i.e. there can be no name overlap between different algorithm types.
Incidently, it was also found that the 'get' function used by
ossl_construct_method() doesn't need all the parameters it was given;
most of what it needs, it can now get through the data structure given
by the caller of ossl_construct_method(). As a consequence,
ossl_construct_method() itself doesn't need all the parameters it was
given either.
There are some added internal functions that are expected to disappear
as soon as legacy code is removed, such as evp_first_name() and
ossl_namemap_num2name().
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9897)
2019-09-14 22:22:19 +08:00
|
|
|
int name_id;
|
2019-08-21 16:54:35 +08:00
|
|
|
CRYPTO_REF_COUNT refcnt;
|
|
|
|
CRYPTO_RWLOCK *lock;
|
|
|
|
|
|
|
|
OSSL_OP_kdf_newctx_fn *newctx;
|
|
|
|
OSSL_OP_kdf_dupctx_fn *dupctx;
|
|
|
|
OSSL_OP_kdf_freectx_fn *freectx;
|
|
|
|
OSSL_OP_kdf_reset_fn *reset;
|
|
|
|
OSSL_OP_kdf_derive_fn *derive;
|
|
|
|
OSSL_OP_kdf_gettable_params_fn *gettable_params;
|
|
|
|
OSSL_OP_kdf_gettable_ctx_params_fn *gettable_ctx_params;
|
|
|
|
OSSL_OP_kdf_settable_ctx_params_fn *settable_ctx_params;
|
|
|
|
OSSL_OP_kdf_get_params_fn *get_params;
|
|
|
|
OSSL_OP_kdf_get_ctx_params_fn *get_ctx_params;
|
|
|
|
OSSL_OP_kdf_set_ctx_params_fn *set_ctx_params;
|
2019-04-22 15:18:56 +08:00
|
|
|
};
|
2018-06-22 05:16:18 +08:00
|
|
|
|
2015-11-30 03:09:34 +08:00
|
|
|
struct evp_md_st {
|
2019-03-13 22:49:40 +08:00
|
|
|
/* nid */
|
2015-11-30 03:09:34 +08:00
|
|
|
int type;
|
2019-03-13 22:49:40 +08:00
|
|
|
|
|
|
|
/* Legacy structure members */
|
|
|
|
/* TODO(3.0): Remove these */
|
2015-11-30 03:09:34 +08:00
|
|
|
int pkey_type;
|
|
|
|
int md_size;
|
|
|
|
unsigned long flags;
|
|
|
|
int (*init) (EVP_MD_CTX *ctx);
|
|
|
|
int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);
|
|
|
|
int (*final) (EVP_MD_CTX *ctx, unsigned char *md);
|
|
|
|
int (*copy) (EVP_MD_CTX *to, const EVP_MD_CTX *from);
|
|
|
|
int (*cleanup) (EVP_MD_CTX *ctx);
|
|
|
|
int block_size;
|
|
|
|
int ctx_size; /* how big does the ctx->md_data need to be */
|
|
|
|
/* control function */
|
|
|
|
int (*md_ctrl) (EVP_MD_CTX *ctx, int cmd, int p1, void *p2);
|
2019-03-13 22:49:40 +08:00
|
|
|
|
|
|
|
/* New structure members */
|
|
|
|
/* TODO(3.0): Remove above comment when legacy has gone */
|
In provider implemented methods, save the name number, not the name string
Multiple names per implementation is already supported in the namemap,
but hasn't been used yet. However, as soon as we have multiple names,
we will get an issue with what name should be saved in the method.
The solution is to not save the name itself, but rather the number
it's associated with. This number is supposed to be unique for each
set of names, and we assume that algorithm names are globally unique,
i.e. there can be no name overlap between different algorithm types.
Incidently, it was also found that the 'get' function used by
ossl_construct_method() doesn't need all the parameters it was given;
most of what it needs, it can now get through the data structure given
by the caller of ossl_construct_method(). As a consequence,
ossl_construct_method() itself doesn't need all the parameters it was
given either.
There are some added internal functions that are expected to disappear
as soon as legacy code is removed, such as evp_first_name() and
ossl_namemap_num2name().
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9897)
2019-09-14 22:22:19 +08:00
|
|
|
int name_id;
|
2019-03-13 22:49:40 +08:00
|
|
|
OSSL_PROVIDER *prov;
|
|
|
|
CRYPTO_REF_COUNT refcnt;
|
|
|
|
CRYPTO_RWLOCK *lock;
|
|
|
|
OSSL_OP_digest_newctx_fn *newctx;
|
|
|
|
OSSL_OP_digest_init_fn *dinit;
|
|
|
|
OSSL_OP_digest_update_fn *dupdate;
|
|
|
|
OSSL_OP_digest_final_fn *dfinal;
|
|
|
|
OSSL_OP_digest_digest_fn *digest;
|
|
|
|
OSSL_OP_digest_freectx_fn *freectx;
|
2019-03-14 00:17:17 +08:00
|
|
|
OSSL_OP_digest_dupctx_fn *dupctx;
|
2019-04-11 18:27:59 +08:00
|
|
|
OSSL_OP_digest_get_params_fn *get_params;
|
2019-08-16 15:04:29 +08:00
|
|
|
OSSL_OP_digest_set_ctx_params_fn *set_ctx_params;
|
|
|
|
OSSL_OP_digest_get_ctx_params_fn *get_ctx_params;
|
Add missing EVP param utility functions
These functions were missing for a completes API:
EVP_MD_get_params(), EVP_CIPHER_get_params(), EVP_CIPHER_CTX_set_params(),
and EVP_CIPHER_CTX_get_params
Additionally, we also add all the corresponding parameter descriptor
returning functions, along the correspoding provider dispatches:
EVP_MD_gettable_params(), EVP_MD_CTX_settable_params(),
EVP_MD_CTX_gettable_params(), EVP_CIPHER_gettable_params(),
EVP_CIPHER_CTX_settable_params(), and EVP_CIPHER_CTX_gettable_params()
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9576)
2019-08-12 20:56:18 +08:00
|
|
|
OSSL_OP_digest_gettable_params_fn *gettable_params;
|
|
|
|
OSSL_OP_digest_settable_ctx_params_fn *settable_ctx_params;
|
|
|
|
OSSL_OP_digest_gettable_ctx_params_fn *gettable_ctx_params;
|
2019-03-13 22:49:40 +08:00
|
|
|
|
2015-11-30 03:09:34 +08:00
|
|
|
} /* EVP_MD */ ;
|
|
|
|
|
2015-12-18 23:37:02 +08:00
|
|
|
struct evp_cipher_st {
|
|
|
|
int nid;
|
2019-04-03 22:38:07 +08:00
|
|
|
|
2015-12-18 23:37:02 +08:00
|
|
|
int block_size;
|
|
|
|
/* Default value for variable length ciphers */
|
|
|
|
int key_len;
|
|
|
|
int iv_len;
|
2019-04-03 22:38:07 +08:00
|
|
|
|
|
|
|
/* Legacy structure members */
|
|
|
|
/* TODO(3.0): Remove these */
|
2015-12-18 23:37:02 +08:00
|
|
|
/* Various flags */
|
|
|
|
unsigned long flags;
|
|
|
|
/* init key */
|
|
|
|
int (*init) (EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
|
|
|
const unsigned char *iv, int enc);
|
|
|
|
/* encrypt/decrypt data */
|
|
|
|
int (*do_cipher) (EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|
|
|
const unsigned char *in, size_t inl);
|
|
|
|
/* cleanup ctx */
|
|
|
|
int (*cleanup) (EVP_CIPHER_CTX *);
|
|
|
|
/* how big ctx->cipher_data needs to be */
|
|
|
|
int ctx_size;
|
|
|
|
/* Populate a ASN1_TYPE with parameters */
|
|
|
|
int (*set_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);
|
|
|
|
/* Get parameters from a ASN1_TYPE */
|
|
|
|
int (*get_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);
|
|
|
|
/* Miscellaneous operations */
|
|
|
|
int (*ctrl) (EVP_CIPHER_CTX *, int type, int arg, void *ptr);
|
|
|
|
/* Application data */
|
|
|
|
void *app_data;
|
2019-04-03 22:38:07 +08:00
|
|
|
|
|
|
|
/* New structure members */
|
|
|
|
/* TODO(3.0): Remove above comment when legacy has gone */
|
In provider implemented methods, save the name number, not the name string
Multiple names per implementation is already supported in the namemap,
but hasn't been used yet. However, as soon as we have multiple names,
we will get an issue with what name should be saved in the method.
The solution is to not save the name itself, but rather the number
it's associated with. This number is supposed to be unique for each
set of names, and we assume that algorithm names are globally unique,
i.e. there can be no name overlap between different algorithm types.
Incidently, it was also found that the 'get' function used by
ossl_construct_method() doesn't need all the parameters it was given;
most of what it needs, it can now get through the data structure given
by the caller of ossl_construct_method(). As a consequence,
ossl_construct_method() itself doesn't need all the parameters it was
given either.
There are some added internal functions that are expected to disappear
as soon as legacy code is removed, such as evp_first_name() and
ossl_namemap_num2name().
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9897)
2019-09-14 22:22:19 +08:00
|
|
|
int name_id;
|
2019-04-03 22:38:07 +08:00
|
|
|
OSSL_PROVIDER *prov;
|
|
|
|
CRYPTO_REF_COUNT refcnt;
|
|
|
|
CRYPTO_RWLOCK *lock;
|
|
|
|
OSSL_OP_cipher_newctx_fn *newctx;
|
|
|
|
OSSL_OP_cipher_encrypt_init_fn *einit;
|
|
|
|
OSSL_OP_cipher_decrypt_init_fn *dinit;
|
|
|
|
OSSL_OP_cipher_update_fn *cupdate;
|
|
|
|
OSSL_OP_cipher_final_fn *cfinal;
|
2019-04-04 01:01:21 +08:00
|
|
|
OSSL_OP_cipher_cipher_fn *ccipher;
|
2019-04-03 22:38:07 +08:00
|
|
|
OSSL_OP_cipher_freectx_fn *freectx;
|
|
|
|
OSSL_OP_cipher_dupctx_fn *dupctx;
|
|
|
|
OSSL_OP_cipher_get_params_fn *get_params;
|
2019-08-16 15:04:29 +08:00
|
|
|
OSSL_OP_cipher_get_ctx_params_fn *get_ctx_params;
|
|
|
|
OSSL_OP_cipher_set_ctx_params_fn *set_ctx_params;
|
Add missing EVP param utility functions
These functions were missing for a completes API:
EVP_MD_get_params(), EVP_CIPHER_get_params(), EVP_CIPHER_CTX_set_params(),
and EVP_CIPHER_CTX_get_params
Additionally, we also add all the corresponding parameter descriptor
returning functions, along the correspoding provider dispatches:
EVP_MD_gettable_params(), EVP_MD_CTX_settable_params(),
EVP_MD_CTX_gettable_params(), EVP_CIPHER_gettable_params(),
EVP_CIPHER_CTX_settable_params(), and EVP_CIPHER_CTX_gettable_params()
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9576)
2019-08-12 20:56:18 +08:00
|
|
|
OSSL_OP_cipher_gettable_params_fn *gettable_params;
|
|
|
|
OSSL_OP_cipher_gettable_ctx_params_fn *gettable_ctx_params;
|
|
|
|
OSSL_OP_cipher_settable_ctx_params_fn *settable_ctx_params;
|
2015-12-18 23:37:02 +08:00
|
|
|
} /* EVP_CIPHER */ ;
|
|
|
|
|
|
|
|
/* Macros to code block cipher wrappers */
|
|
|
|
|
|
|
|
/* Wrapper functions for each cipher mode */
|
|
|
|
|
2016-03-07 18:17:27 +08:00
|
|
|
#define EVP_C_DATA(kstruct, ctx) \
|
|
|
|
((kstruct *)EVP_CIPHER_CTX_get_cipher_data(ctx))
|
2015-12-18 23:37:02 +08:00
|
|
|
|
|
|
|
#define BLOCK_CIPHER_ecb_loop() \
|
|
|
|
size_t i, bl; \
|
|
|
|
bl = EVP_CIPHER_CTX_cipher(ctx)->block_size; \
|
2016-06-29 06:18:50 +08:00
|
|
|
if (inl < bl) return 1;\
|
2015-12-18 23:37:02 +08:00
|
|
|
inl -= bl; \
|
2016-06-29 06:18:50 +08:00
|
|
|
for (i=0; i <= inl; i+=bl)
|
2015-12-18 23:37:02 +08:00
|
|
|
|
|
|
|
#define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
|
|
|
|
static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
|
|
|
|
{\
|
|
|
|
BLOCK_CIPHER_ecb_loop() \
|
|
|
|
cprefix##_ecb_encrypt(in + i, out + i, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_encrypting(ctx)); \
|
|
|
|
return 1;\
|
|
|
|
}
|
|
|
|
|
|
|
|
#define EVP_MAXCHUNK ((size_t)1<<(sizeof(long)*8-2))
|
|
|
|
|
|
|
|
#define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \
|
|
|
|
static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
|
|
|
|
{\
|
|
|
|
while(inl>=EVP_MAXCHUNK) {\
|
|
|
|
int num = EVP_CIPHER_CTX_num(ctx);\
|
|
|
|
cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), &num); \
|
|
|
|
EVP_CIPHER_CTX_set_num(ctx, num);\
|
|
|
|
inl-=EVP_MAXCHUNK;\
|
|
|
|
in +=EVP_MAXCHUNK;\
|
|
|
|
out+=EVP_MAXCHUNK;\
|
|
|
|
}\
|
|
|
|
if (inl) {\
|
|
|
|
int num = EVP_CIPHER_CTX_num(ctx);\
|
|
|
|
cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), &num); \
|
|
|
|
EVP_CIPHER_CTX_set_num(ctx, num);\
|
|
|
|
}\
|
|
|
|
return 1;\
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
|
|
|
|
static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
|
|
|
|
{\
|
|
|
|
while(inl>=EVP_MAXCHUNK) \
|
|
|
|
{\
|
|
|
|
cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));\
|
|
|
|
inl-=EVP_MAXCHUNK;\
|
|
|
|
in +=EVP_MAXCHUNK;\
|
|
|
|
out+=EVP_MAXCHUNK;\
|
|
|
|
}\
|
|
|
|
if (inl)\
|
|
|
|
cprefix##_cbc_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));\
|
|
|
|
return 1;\
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
|
|
|
|
static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
|
|
|
|
{\
|
2016-06-29 06:18:50 +08:00
|
|
|
size_t chunk = EVP_MAXCHUNK;\
|
|
|
|
if (cbits == 1) chunk >>= 3;\
|
|
|
|
if (inl < chunk) chunk = inl;\
|
|
|
|
while (inl && inl >= chunk)\
|
|
|
|
{\
|
|
|
|
int num = EVP_CIPHER_CTX_num(ctx);\
|
|
|
|
cprefix##_cfb##cbits##_encrypt(in, out, (long) \
|
|
|
|
((cbits == 1) \
|
|
|
|
&& !EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS) \
|
2018-02-21 22:48:02 +08:00
|
|
|
? chunk*8 : chunk), \
|
2016-06-29 06:18:50 +08:00
|
|
|
&EVP_C_DATA(kstruct, ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx),\
|
|
|
|
&num, EVP_CIPHER_CTX_encrypting(ctx));\
|
|
|
|
EVP_CIPHER_CTX_set_num(ctx, num);\
|
|
|
|
inl -= chunk;\
|
|
|
|
in += chunk;\
|
|
|
|
out += chunk;\
|
|
|
|
if (inl < chunk) chunk = inl;\
|
|
|
|
}\
|
|
|
|
return 1;\
|
2015-12-18 23:37:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
|
|
|
|
BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
|
|
|
|
BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
|
|
|
|
BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
|
|
|
|
BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched)
|
|
|
|
|
|
|
|
#define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \
|
|
|
|
key_len, iv_len, flags, init_key, cleanup, \
|
|
|
|
set_asn1, get_asn1, ctrl) \
|
|
|
|
static const EVP_CIPHER cname##_##mode = { \
|
|
|
|
nid##_##nmode, block_size, key_len, iv_len, \
|
|
|
|
flags | EVP_CIPH_##MODE##_MODE, \
|
|
|
|
init_key, \
|
|
|
|
cname##_##mode##_cipher, \
|
|
|
|
cleanup, \
|
|
|
|
sizeof(kstruct), \
|
|
|
|
set_asn1, get_asn1,\
|
|
|
|
ctrl, \
|
|
|
|
NULL \
|
|
|
|
}; \
|
|
|
|
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
|
|
|
|
|
|
|
|
#define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, \
|
|
|
|
iv_len, flags, init_key, cleanup, set_asn1, \
|
|
|
|
get_asn1, ctrl) \
|
|
|
|
BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \
|
|
|
|
iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
|
|
|
|
|
|
|
|
#define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, \
|
|
|
|
iv_len, cbits, flags, init_key, cleanup, \
|
|
|
|
set_asn1, get_asn1, ctrl) \
|
|
|
|
BLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, \
|
|
|
|
key_len, iv_len, flags, init_key, cleanup, set_asn1, \
|
|
|
|
get_asn1, ctrl)
|
|
|
|
|
|
|
|
#define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, \
|
|
|
|
iv_len, cbits, flags, init_key, cleanup, \
|
|
|
|
set_asn1, get_asn1, ctrl) \
|
|
|
|
BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, \
|
|
|
|
key_len, iv_len, flags, init_key, cleanup, set_asn1, \
|
|
|
|
get_asn1, ctrl)
|
|
|
|
|
|
|
|
#define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \
|
|
|
|
flags, init_key, cleanup, set_asn1, \
|
|
|
|
get_asn1, ctrl) \
|
|
|
|
BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \
|
|
|
|
0, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
|
|
|
|
|
|
|
|
#define BLOCK_CIPHER_defs(cname, kstruct, \
|
|
|
|
nid, block_size, key_len, iv_len, cbits, flags, \
|
|
|
|
init_key, cleanup, set_asn1, get_asn1, ctrl) \
|
|
|
|
BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \
|
|
|
|
init_key, cleanup, set_asn1, get_asn1, ctrl) \
|
|
|
|
BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \
|
|
|
|
flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
|
|
|
|
BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \
|
|
|
|
flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
|
|
|
|
BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, flags, \
|
|
|
|
init_key, cleanup, set_asn1, get_asn1, ctrl)
|
|
|
|
|
|
|
|
/*-
|
|
|
|
#define BLOCK_CIPHER_defs(cname, kstruct, \
|
|
|
|
nid, block_size, key_len, iv_len, flags,\
|
|
|
|
init_key, cleanup, set_asn1, get_asn1, ctrl)\
|
|
|
|
static const EVP_CIPHER cname##_cbc = {\
|
|
|
|
nid##_cbc, block_size, key_len, iv_len, \
|
|
|
|
flags | EVP_CIPH_CBC_MODE,\
|
|
|
|
init_key,\
|
|
|
|
cname##_cbc_cipher,\
|
|
|
|
cleanup,\
|
|
|
|
sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
|
|
|
|
sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
|
|
|
|
set_asn1, get_asn1,\
|
|
|
|
ctrl, \
|
|
|
|
NULL \
|
|
|
|
};\
|
|
|
|
const EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\
|
|
|
|
static const EVP_CIPHER cname##_cfb = {\
|
|
|
|
nid##_cfb64, 1, key_len, iv_len, \
|
|
|
|
flags | EVP_CIPH_CFB_MODE,\
|
|
|
|
init_key,\
|
|
|
|
cname##_cfb_cipher,\
|
|
|
|
cleanup,\
|
|
|
|
sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
|
|
|
|
sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
|
|
|
|
set_asn1, get_asn1,\
|
|
|
|
ctrl,\
|
|
|
|
NULL \
|
|
|
|
};\
|
|
|
|
const EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\
|
|
|
|
static const EVP_CIPHER cname##_ofb = {\
|
|
|
|
nid##_ofb64, 1, key_len, iv_len, \
|
|
|
|
flags | EVP_CIPH_OFB_MODE,\
|
|
|
|
init_key,\
|
|
|
|
cname##_ofb_cipher,\
|
|
|
|
cleanup,\
|
|
|
|
sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
|
|
|
|
sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
|
|
|
|
set_asn1, get_asn1,\
|
|
|
|
ctrl,\
|
|
|
|
NULL \
|
|
|
|
};\
|
|
|
|
const EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\
|
|
|
|
static const EVP_CIPHER cname##_ecb = {\
|
|
|
|
nid##_ecb, block_size, key_len, iv_len, \
|
|
|
|
flags | EVP_CIPH_ECB_MODE,\
|
|
|
|
init_key,\
|
|
|
|
cname##_ecb_cipher,\
|
|
|
|
cleanup,\
|
|
|
|
sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
|
|
|
|
sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
|
|
|
|
set_asn1, get_asn1,\
|
|
|
|
ctrl,\
|
|
|
|
NULL \
|
|
|
|
};\
|
|
|
|
const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \
|
|
|
|
block_size, key_len, iv_len, cbits, \
|
|
|
|
flags, init_key, \
|
|
|
|
cleanup, set_asn1, get_asn1, ctrl) \
|
|
|
|
BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
|
|
|
|
BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \
|
|
|
|
cbits, flags, init_key, cleanup, set_asn1, \
|
|
|
|
get_asn1, ctrl)
|
|
|
|
|
|
|
|
#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len,fl) \
|
|
|
|
BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \
|
|
|
|
BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \
|
|
|
|
NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \
|
|
|
|
(fl)|EVP_CIPH_FLAG_DEFAULT_ASN1, \
|
|
|
|
cipher##_init_key, NULL, NULL, NULL, NULL)
|
|
|
|
|
2016-01-19 08:21:12 +08:00
|
|
|
|
2018-02-28 22:59:44 +08:00
|
|
|
# ifndef OPENSSL_NO_EC
|
|
|
|
|
|
|
|
#define X25519_KEYLEN 32
|
|
|
|
#define X448_KEYLEN 56
|
2019-09-19 21:31:27 +08:00
|
|
|
#define ED25519_KEYLEN 32
|
2018-02-28 22:59:44 +08:00
|
|
|
#define ED448_KEYLEN 57
|
|
|
|
|
|
|
|
#define MAX_KEYLEN ED448_KEYLEN
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned char pubkey[MAX_KEYLEN];
|
|
|
|
unsigned char *privkey;
|
|
|
|
} ECX_KEY;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-01-19 08:21:12 +08:00
|
|
|
/*
|
|
|
|
* Type needs to be a bit field Sub-type needs to be for variations on the
|
|
|
|
* method, as in, can it do arbitrary encryption....
|
|
|
|
*/
|
|
|
|
struct evp_pkey_st {
|
2019-07-05 06:31:42 +08:00
|
|
|
/* == Legacy attributes == */
|
2016-01-19 08:21:12 +08:00
|
|
|
int type;
|
|
|
|
int save_type;
|
|
|
|
const EVP_PKEY_ASN1_METHOD *ameth;
|
|
|
|
ENGINE *engine;
|
2017-10-09 22:21:11 +08:00
|
|
|
ENGINE *pmeth_engine; /* If not NULL public key ENGINE to use */
|
2016-01-19 08:21:12 +08:00
|
|
|
union {
|
2016-08-10 03:53:37 +08:00
|
|
|
void *ptr;
|
2016-01-19 08:21:12 +08:00
|
|
|
# ifndef OPENSSL_NO_RSA
|
|
|
|
struct rsa_st *rsa; /* RSA */
|
|
|
|
# endif
|
|
|
|
# ifndef OPENSSL_NO_DSA
|
|
|
|
struct dsa_st *dsa; /* DSA */
|
|
|
|
# endif
|
|
|
|
# ifndef OPENSSL_NO_DH
|
|
|
|
struct dh_st *dh; /* DH */
|
|
|
|
# endif
|
|
|
|
# ifndef OPENSSL_NO_EC
|
|
|
|
struct ec_key_st *ec; /* ECC */
|
2018-02-28 22:59:44 +08:00
|
|
|
ECX_KEY *ecx; /* X25519, X448, Ed25519, Ed448 */
|
2016-01-19 08:21:12 +08:00
|
|
|
# endif
|
|
|
|
} pkey;
|
2019-07-05 06:31:42 +08:00
|
|
|
|
|
|
|
/* == Common attributes == */
|
|
|
|
CRYPTO_REF_COUNT references;
|
2016-02-26 20:21:15 +08:00
|
|
|
CRYPTO_RWLOCK *lock;
|
2019-07-05 06:31:42 +08:00
|
|
|
STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
|
|
|
|
int save_parameters;
|
|
|
|
|
|
|
|
/* == Provider attributes == */
|
|
|
|
/*
|
|
|
|
* To support transparent export/import between providers that
|
|
|
|
* support the methods for it, and still not having to do the
|
2019-10-14 14:41:17 +08:00
|
|
|
* export/import every time a key or domain params are used, we
|
|
|
|
* maintain a cache of imported key / domain params, indexed by
|
|
|
|
* provider address. pkeys[0] is *always* the "original" data.
|
2019-07-05 06:31:42 +08:00
|
|
|
*/
|
|
|
|
struct {
|
|
|
|
EVP_KEYMGMT *keymgmt;
|
2019-10-14 14:41:17 +08:00
|
|
|
void *provdata;
|
|
|
|
/* 0 = provdata is a key, 1 = provdata is domain params */
|
|
|
|
int domainparams;
|
2019-07-05 06:31:42 +08:00
|
|
|
} pkeys[10];
|
2019-07-07 03:57:15 +08:00
|
|
|
/*
|
|
|
|
* If there is a legacy key assigned to this structure, we keep
|
|
|
|
* a copy of that key's dirty count.
|
|
|
|
*/
|
|
|
|
size_t dirty_cnt_copy;
|
2020-01-08 10:44:28 +08:00
|
|
|
|
|
|
|
/* Cache of domain parameter / key information */
|
|
|
|
struct {
|
|
|
|
int bits;
|
|
|
|
int security_bits;
|
|
|
|
int size;
|
|
|
|
} cache;
|
2016-01-19 08:21:12 +08:00
|
|
|
} /* EVP_PKEY */ ;
|
2016-02-09 00:43:03 +08:00
|
|
|
|
2019-09-05 06:13:25 +08:00
|
|
|
#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)
|
2016-02-09 00:43:03 +08:00
|
|
|
|
2019-10-01 16:40:57 +08:00
|
|
|
#define EVP_PKEY_CTX_IS_ASYM_CIPHER_OP(ctx) \
|
|
|
|
((ctx)->operation == EVP_PKEY_OP_ENCRYPT \
|
|
|
|
|| (ctx)->operation == EVP_PKEY_OP_DECRYPT)
|
|
|
|
|
2016-04-12 19:20:16 +08:00
|
|
|
void openssl_add_all_ciphers_int(void);
|
|
|
|
void openssl_add_all_digests_int(void);
|
|
|
|
void evp_cleanup_int(void);
|
2017-09-11 23:15:55 +08:00
|
|
|
void evp_app_cleanup_int(void);
|
2017-01-10 04:29:42 +08:00
|
|
|
|
2019-07-10 20:30:55 +08:00
|
|
|
/* KEYMGMT helper functions */
|
2019-10-14 14:41:17 +08:00
|
|
|
void *evp_keymgmt_export_to_provider(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt,
|
|
|
|
int domainparams);
|
2019-07-10 20:30:55 +08:00
|
|
|
void evp_keymgmt_clear_pkey_cache(EVP_PKEY *pk);
|
2020-01-08 10:44:28 +08:00
|
|
|
void evp_keymgmt_cache_pkey(EVP_PKEY *pk, size_t index, EVP_KEYMGMT *keymgmt,
|
|
|
|
void *provdata, int domainparams);
|
2019-10-15 20:50:35 +08:00
|
|
|
void *evp_keymgmt_fromdata(EVP_PKEY *target, EVP_KEYMGMT *keymgmt,
|
|
|
|
const OSSL_PARAM params[], int domainparams);
|
|
|
|
|
2019-07-07 03:57:15 +08:00
|
|
|
|
2019-07-11 18:52:16 +08:00
|
|
|
/* KEYMGMT provider interface functions */
|
|
|
|
void *evp_keymgmt_importdomparams(const EVP_KEYMGMT *keymgmt,
|
|
|
|
const OSSL_PARAM params[]);
|
|
|
|
void *evp_keymgmt_gendomparams(const EVP_KEYMGMT *keymgmt,
|
|
|
|
const OSSL_PARAM params[]);
|
|
|
|
void evp_keymgmt_freedomparams(const EVP_KEYMGMT *keymgmt,
|
|
|
|
void *provdomparams);
|
|
|
|
int evp_keymgmt_exportdomparams(const EVP_KEYMGMT *keymgmt,
|
2019-11-08 22:24:42 +08:00
|
|
|
void *provdomparams,
|
|
|
|
OSSL_CALLBACK *param_cb, void *cbarg);
|
2019-07-11 18:52:16 +08:00
|
|
|
const OSSL_PARAM *
|
|
|
|
evp_keymgmt_importdomparam_types(const EVP_KEYMGMT *keymgmt);
|
|
|
|
const OSSL_PARAM *
|
|
|
|
evp_keymgmt_exportdomparam_types(const EVP_KEYMGMT *keymgmt);
|
2020-01-08 10:44:28 +08:00
|
|
|
int evp_keymgmt_get_domparam_params(const EVP_KEYMGMT *keymgmt,
|
|
|
|
void *provdomparam, OSSL_PARAM params[]);
|
|
|
|
const OSSL_PARAM *
|
|
|
|
evp_keymgmt_gettable_domparam_params(const EVP_KEYMGMT *keymgmt);
|
2019-07-11 18:52:16 +08:00
|
|
|
|
|
|
|
void *evp_keymgmt_importkey(const EVP_KEYMGMT *keymgmt,
|
|
|
|
const OSSL_PARAM params[]);
|
|
|
|
void *evp_keymgmt_genkey(const EVP_KEYMGMT *keymgmt, void *domparams,
|
|
|
|
const OSSL_PARAM params[]);
|
|
|
|
void *evp_keymgmt_loadkey(const EVP_KEYMGMT *keymgmt,
|
|
|
|
void *id, size_t idlen);
|
|
|
|
void evp_keymgmt_freekey(const EVP_KEYMGMT *keymgmt, void *provkey);
|
2019-11-08 22:24:42 +08:00
|
|
|
int evp_keymgmt_exportkey(const EVP_KEYMGMT *keymgmt, void *provkey,
|
|
|
|
OSSL_CALLBACK *param_cb, void *cbarg);
|
2019-07-11 18:52:16 +08:00
|
|
|
const OSSL_PARAM *evp_keymgmt_importkey_types(const EVP_KEYMGMT *keymgmt);
|
|
|
|
const OSSL_PARAM *evp_keymgmt_exportkey_types(const EVP_KEYMGMT *keymgmt);
|
2020-01-08 10:44:28 +08:00
|
|
|
int evp_keymgmt_get_key_params(const EVP_KEYMGMT *keymgmt,
|
|
|
|
void *provkey, OSSL_PARAM params[]);
|
|
|
|
const OSSL_PARAM *evp_keymgmt_gettable_key_params(const EVP_KEYMGMT *keymgmt);
|
2019-07-11 18:52:16 +08:00
|
|
|
|
2017-11-12 08:03:10 +08:00
|
|
|
/* Pulling defines out of C source files */
|
2017-01-10 04:29:42 +08:00
|
|
|
|
|
|
|
#define EVP_RC4_KEY_SIZE 16
|
|
|
|
#ifndef TLS1_1_VERSION
|
|
|
|
# define TLS1_1_VERSION 0x0302
|
|
|
|
#endif
|
2018-04-09 22:06:50 +08:00
|
|
|
|
|
|
|
void evp_encode_ctx_set_flags(EVP_ENCODE_CTX *ctx, unsigned int flags);
|
|
|
|
|
|
|
|
/* EVP_ENCODE_CTX flags */
|
2018-04-09 22:50:20 +08:00
|
|
|
/* Don't generate new lines when encoding */
|
|
|
|
#define EVP_ENCODE_CTX_NO_NEWLINES 1
|
|
|
|
/* Use the SRP base64 alphabet instead of the standard one */
|
|
|
|
#define EVP_ENCODE_CTX_USE_SRP_ALPHABET 2
|
2019-11-01 22:13:49 +08:00
|
|
|
|
|
|
|
const EVP_CIPHER *evp_get_cipherbyname_ex(OPENSSL_CTX *libctx, const char *name);
|
|
|
|
const EVP_MD *evp_get_digestbyname_ex(OPENSSL_CTX *libctx, const char *name);
|
2020-01-12 09:32:12 +08:00
|
|
|
|