/*
- * Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
/* EVP_MD_CTX related stuff */
-#include <openssl/core_numbers.h>
+#include <openssl/core_dispatch.h>
+#include "internal/refcount.h"
#define EVP_CTRL_RET_UNSUPPORTED -1
void *data; /* Algorithm-specific data */
} /* EVP_KDF_CTX */ ;
+struct evp_rand_ctx_st {
+ EVP_RAND *meth; /* Method structure */
+ void *data; /* Algorithm-specific data */
+ size_t max_request; /*
+ * Cached: maximum number of bytes generated
+ * in a single call to the generate function
+ */
+ unsigned int strength; /* Cached: bit strength of generator */
+} /* EVP_RAND_CTX */ ;
+
+struct evp_rand_st {
+ OSSL_PROVIDER *prov;
+ int name_id;
+ CRYPTO_REF_COUNT refcnt;
+ CRYPTO_RWLOCK *refcnt_lock;
+
+ const OSSL_DISPATCH *dispatch;
+ OSSL_FUNC_rand_newctx_fn *newctx;
+ OSSL_FUNC_rand_freectx_fn *freectx;
+ OSSL_FUNC_rand_instantiate_fn *instantiate;
+ OSSL_FUNC_rand_uninstantiate_fn *uninstantiate;
+ OSSL_FUNC_rand_generate_fn *generate;
+ OSSL_FUNC_rand_reseed_fn *reseed;
+ OSSL_FUNC_rand_nonce_fn *nonce;
+ OSSL_FUNC_rand_enable_locking_fn *enable_locking;
+ OSSL_FUNC_rand_lock_fn *lock;
+ OSSL_FUNC_rand_unlock_fn *unlock;
+ OSSL_FUNC_rand_gettable_params_fn *gettable_params;
+ OSSL_FUNC_rand_gettable_ctx_params_fn *gettable_ctx_params;
+ OSSL_FUNC_rand_settable_ctx_params_fn *settable_ctx_params;
+ OSSL_FUNC_rand_get_params_fn *get_params;
+ OSSL_FUNC_rand_get_ctx_params_fn *get_ctx_params;
+ OSSL_FUNC_rand_set_ctx_params_fn *set_ctx_params;
+ OSSL_FUNC_rand_set_callbacks_fn *set_callbacks;
+ OSSL_FUNC_rand_verify_zeroization_fn *verify_zeroization;
+} /* EVP_RAND */ ;
+
struct evp_keymgmt_st {
int id; /* libcrypto internal */
CRYPTO_REF_COUNT refcnt;
CRYPTO_RWLOCK *lock;
- /* Domain parameter routines */
- OSSL_OP_keymgmt_importdomparams_fn *importdomparams;
- OSSL_OP_keymgmt_gendomparams_fn *gendomparams;
- OSSL_OP_keymgmt_freedomparams_fn *freedomparams;
- OSSL_OP_keymgmt_exportdomparams_fn *exportdomparams;
- OSSL_OP_keymgmt_importdomparam_types_fn *importdomparam_types;
- OSSL_OP_keymgmt_exportdomparam_types_fn *exportdomparam_types;
-
- /* Key routines */
- OSSL_OP_keymgmt_importkey_fn *importkey;
- OSSL_OP_keymgmt_genkey_fn *genkey;
- OSSL_OP_keymgmt_loadkey_fn *loadkey;
- OSSL_OP_keymgmt_freekey_fn *freekey;
- OSSL_OP_keymgmt_exportkey_fn *exportkey;
- OSSL_OP_keymgmt_importkey_types_fn *importkey_types;
- OSSL_OP_keymgmt_exportkey_types_fn *exportkey_types;
+ /* Constructor(s), destructor, information */
+ OSSL_FUNC_keymgmt_new_fn *new;
+ OSSL_FUNC_keymgmt_free_fn *free;
+ OSSL_FUNC_keymgmt_get_params_fn *get_params;
+ OSSL_FUNC_keymgmt_gettable_params_fn *gettable_params;
+ OSSL_FUNC_keymgmt_set_params_fn *set_params;
+ OSSL_FUNC_keymgmt_settable_params_fn *settable_params;
+
+ /* Generation, a complex constructor */
+ OSSL_FUNC_keymgmt_gen_init_fn *gen_init;
+ OSSL_FUNC_keymgmt_gen_set_template_fn *gen_set_template;
+ OSSL_FUNC_keymgmt_gen_set_params_fn *gen_set_params;
+ OSSL_FUNC_keymgmt_gen_settable_params_fn *gen_settable_params;
+ OSSL_FUNC_keymgmt_gen_fn *gen;
+ OSSL_FUNC_keymgmt_gen_cleanup_fn *gen_cleanup;
+
+ /* Key object checking */
+ OSSL_FUNC_keymgmt_query_operation_name_fn *query_operation_name;
+ OSSL_FUNC_keymgmt_has_fn *has;
+ OSSL_FUNC_keymgmt_validate_fn *validate;
+ OSSL_FUNC_keymgmt_match_fn *match;
+
+ /* Import and export routines */
+ OSSL_FUNC_keymgmt_import_fn *import;
+ OSSL_FUNC_keymgmt_import_types_fn *import_types;
+ OSSL_FUNC_keymgmt_export_fn *export;
+ OSSL_FUNC_keymgmt_export_types_fn *export_types;
+ OSSL_FUNC_keymgmt_copy_fn *copy;
} /* EVP_KEYMGMT */ ;
-struct keymgmt_data_st {
- OPENSSL_CTX *ctx;
- const char *properties;
-};
-
struct evp_keyexch_st {
int name_id;
OSSL_PROVIDER *prov;
CRYPTO_REF_COUNT refcnt;
CRYPTO_RWLOCK *lock;
- OSSL_OP_keyexch_newctx_fn *newctx;
- OSSL_OP_keyexch_init_fn *init;
- OSSL_OP_keyexch_set_peer_fn *set_peer;
- OSSL_OP_keyexch_derive_fn *derive;
- OSSL_OP_keyexch_freectx_fn *freectx;
- OSSL_OP_keyexch_dupctx_fn *dupctx;
- OSSL_OP_keyexch_set_ctx_params_fn *set_ctx_params;
- OSSL_OP_keyexch_settable_ctx_params_fn *settable_ctx_params;
+ OSSL_FUNC_keyexch_newctx_fn *newctx;
+ OSSL_FUNC_keyexch_init_fn *init;
+ OSSL_FUNC_keyexch_set_peer_fn *set_peer;
+ OSSL_FUNC_keyexch_derive_fn *derive;
+ OSSL_FUNC_keyexch_freectx_fn *freectx;
+ OSSL_FUNC_keyexch_dupctx_fn *dupctx;
+ OSSL_FUNC_keyexch_set_ctx_params_fn *set_ctx_params;
+ OSSL_FUNC_keyexch_settable_ctx_params_fn *settable_ctx_params;
+ OSSL_FUNC_keyexch_get_ctx_params_fn *get_ctx_params;
+ OSSL_FUNC_keyexch_gettable_ctx_params_fn *gettable_ctx_params;
} /* EVP_KEYEXCH */;
struct evp_signature_st {
CRYPTO_REF_COUNT refcnt;
CRYPTO_RWLOCK *lock;
- OSSL_OP_signature_newctx_fn *newctx;
- OSSL_OP_signature_sign_init_fn *sign_init;
- OSSL_OP_signature_sign_fn *sign;
- OSSL_OP_signature_verify_init_fn *verify_init;
- OSSL_OP_signature_verify_fn *verify;
- OSSL_OP_signature_verify_recover_init_fn *verify_recover_init;
- OSSL_OP_signature_verify_recover_fn *verify_recover;
- OSSL_OP_signature_digest_sign_init_fn *digest_sign_init;
- OSSL_OP_signature_digest_sign_update_fn *digest_sign_update;
- OSSL_OP_signature_digest_sign_final_fn *digest_sign_final;
- OSSL_OP_signature_digest_verify_init_fn *digest_verify_init;
- OSSL_OP_signature_digest_verify_update_fn *digest_verify_update;
- OSSL_OP_signature_digest_verify_final_fn *digest_verify_final;
- OSSL_OP_signature_freectx_fn *freectx;
- OSSL_OP_signature_dupctx_fn *dupctx;
- OSSL_OP_signature_get_ctx_params_fn *get_ctx_params;
- OSSL_OP_signature_gettable_ctx_params_fn *gettable_ctx_params;
- OSSL_OP_signature_set_ctx_params_fn *set_ctx_params;
- OSSL_OP_signature_settable_ctx_params_fn *settable_ctx_params;
- OSSL_OP_signature_get_ctx_md_params_fn *get_ctx_md_params;
- OSSL_OP_signature_gettable_ctx_md_params_fn *gettable_ctx_md_params;
- OSSL_OP_signature_set_ctx_md_params_fn *set_ctx_md_params;
- OSSL_OP_signature_settable_ctx_md_params_fn *settable_ctx_md_params;
+ OSSL_FUNC_signature_newctx_fn *newctx;
+ OSSL_FUNC_signature_sign_init_fn *sign_init;
+ OSSL_FUNC_signature_sign_fn *sign;
+ OSSL_FUNC_signature_verify_init_fn *verify_init;
+ OSSL_FUNC_signature_verify_fn *verify;
+ OSSL_FUNC_signature_verify_recover_init_fn *verify_recover_init;
+ OSSL_FUNC_signature_verify_recover_fn *verify_recover;
+ OSSL_FUNC_signature_digest_sign_init_fn *digest_sign_init;
+ OSSL_FUNC_signature_digest_sign_update_fn *digest_sign_update;
+ OSSL_FUNC_signature_digest_sign_final_fn *digest_sign_final;
+ OSSL_FUNC_signature_digest_sign_fn *digest_sign;
+ OSSL_FUNC_signature_digest_verify_init_fn *digest_verify_init;
+ OSSL_FUNC_signature_digest_verify_update_fn *digest_verify_update;
+ OSSL_FUNC_signature_digest_verify_final_fn *digest_verify_final;
+ OSSL_FUNC_signature_digest_verify_fn *digest_verify;
+ OSSL_FUNC_signature_freectx_fn *freectx;
+ OSSL_FUNC_signature_dupctx_fn *dupctx;
+ OSSL_FUNC_signature_get_ctx_params_fn *get_ctx_params;
+ OSSL_FUNC_signature_gettable_ctx_params_fn *gettable_ctx_params;
+ OSSL_FUNC_signature_set_ctx_params_fn *set_ctx_params;
+ OSSL_FUNC_signature_settable_ctx_params_fn *settable_ctx_params;
+ OSSL_FUNC_signature_get_ctx_md_params_fn *get_ctx_md_params;
+ OSSL_FUNC_signature_gettable_ctx_md_params_fn *gettable_ctx_md_params;
+ OSSL_FUNC_signature_set_ctx_md_params_fn *set_ctx_md_params;
+ OSSL_FUNC_signature_settable_ctx_md_params_fn *settable_ctx_md_params;
} /* EVP_SIGNATURE */;
+struct evp_asym_cipher_st {
+ int name_id;
+ OSSL_PROVIDER *prov;
+ CRYPTO_REF_COUNT refcnt;
+ CRYPTO_RWLOCK *lock;
+
+ OSSL_FUNC_asym_cipher_newctx_fn *newctx;
+ OSSL_FUNC_asym_cipher_encrypt_init_fn *encrypt_init;
+ OSSL_FUNC_asym_cipher_encrypt_fn *encrypt;
+ OSSL_FUNC_asym_cipher_decrypt_init_fn *decrypt_init;
+ OSSL_FUNC_asym_cipher_decrypt_fn *decrypt;
+ OSSL_FUNC_asym_cipher_freectx_fn *freectx;
+ OSSL_FUNC_asym_cipher_dupctx_fn *dupctx;
+ OSSL_FUNC_asym_cipher_get_ctx_params_fn *get_ctx_params;
+ OSSL_FUNC_asym_cipher_gettable_ctx_params_fn *gettable_ctx_params;
+ OSSL_FUNC_asym_cipher_set_ctx_params_fn *set_ctx_params;
+ OSSL_FUNC_asym_cipher_settable_ctx_params_fn *settable_ctx_params;
+} /* EVP_ASYM_CIPHER */;
+
int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass,
int passlen, ASN1_TYPE *param,
const EVP_CIPHER *c, const EVP_MD *md,
const char *name, const char *properties,
void *(*new_method)(int name_id,
const OSSL_DISPATCH *fns,
- OSSL_PROVIDER *prov,
- void *method_data),
- void *method_data,
+ OSSL_PROVIDER *prov),
int (*up_ref_method)(void *),
void (*free_method)(void *));
void *evp_generic_fetch_by_number(OPENSSL_CTX *ctx, int operation_id,
int name_id, const char *properties,
void *(*new_method)(int name_id,
const OSSL_DISPATCH *fns,
- OSSL_PROVIDER *prov,
- void *method_data),
- void *method_data,
+ OSSL_PROVIDER *prov),
int (*up_ref_method)(void *),
void (*free_method)(void *));
void evp_generic_do_all(OPENSSL_CTX *libctx, int operation_id,
void *user_arg,
void *(*new_method)(int name_id,
const OSSL_DISPATCH *fns,
- OSSL_PROVIDER *prov,
- void *method_data),
- void *method_data,
+ OSSL_PROVIDER *prov),
void (*free_method)(void *));
/* Internal fetchers for method types that are to be combined with others */
void evp_pkey_ctx_free_old_ops(EVP_PKEY_CTX *ctx);
/* OSSL_PROVIDER * is only used to get the library context */
-const char *evp_first_name(OSSL_PROVIDER *prov, int name_id);
-int evp_is_a(OSSL_PROVIDER *prov, int number, const char *name);
+const char *evp_first_name(const OSSL_PROVIDER *prov, int name_id);
+int evp_is_a(OSSL_PROVIDER *prov, int number,
+ const char *legacy_name, const char *name);
void evp_names_do_all(OSSL_PROVIDER *prov, int number,
void (*fn)(const char *name, void *data),
void *data);
+int evp_cipher_cache_constants(EVP_CIPHER *cipher);