CTR, HASH and HMAC DRBGs in provider
[openssl.git] / crypto / evp / evp_local.h
index 95dd1c036e88c729e05161f9de1c8b1adaf35a2f..132534464fdf9508942170b8c6c71bb1e255ed42 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -10,6 +10,7 @@
 /* EVP_MD_CTX related stuff */
 
 #include <openssl/core_numbers.h>
+#include "internal/refcount.h"
 
 #define EVP_CTRL_RET_UNSUPPORTED -1
 
@@ -65,6 +66,43 @@ struct evp_kdf_ctx_st {
     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_OP_rand_newctx_fn *newctx;
+    OSSL_OP_rand_freectx_fn *freectx;
+    OSSL_OP_rand_instantiate_fn *instantiate;
+    OSSL_OP_rand_uninstantiate_fn *uninstantiate;
+    OSSL_OP_rand_generate_fn *generate;
+    OSSL_OP_rand_reseed_fn *reseed;
+    OSSL_OP_rand_nonce_fn *nonce;
+    OSSL_OP_rand_enable_locking_fn *enable_locking;
+    OSSL_OP_rand_lock_fn *lock;
+    OSSL_OP_rand_unlock_fn *unlock;
+    OSSL_OP_rand_gettable_params_fn *gettable_params;
+    OSSL_OP_rand_gettable_ctx_params_fn *gettable_ctx_params;
+    OSSL_OP_rand_settable_ctx_params_fn *settable_ctx_params;
+    OSSL_OP_rand_get_params_fn *get_params;
+    OSSL_OP_rand_get_ctx_params_fn *get_ctx_params;
+    OSSL_OP_rand_set_ctx_params_fn *set_ctx_params;
+    OSSL_OP_rand_set_callbacks_fn *set_callbacks;
+    OSSL_OP_rand_verify_zeroization_fn *verify_zeroization;
+} /* EVP_RAND */ ;
+
 struct evp_keymgmt_st {
     int id;                      /* libcrypto internal */
 
@@ -78,17 +116,29 @@ struct evp_keymgmt_st {
     OSSL_OP_keymgmt_free_fn *free;
     OSSL_OP_keymgmt_get_params_fn *get_params;
     OSSL_OP_keymgmt_gettable_params_fn *gettable_params;
+    OSSL_OP_keymgmt_set_params_fn *set_params;
+    OSSL_OP_keymgmt_settable_params_fn *settable_params;
+
+    /* Generation, a complex constructor */
+    OSSL_OP_keymgmt_gen_init_fn *gen_init;
+    OSSL_OP_keymgmt_gen_set_template_fn *gen_set_template;
+    OSSL_OP_keymgmt_gen_set_params_fn *gen_set_params;
+    OSSL_OP_keymgmt_gen_settable_params_fn *gen_settable_params;
+    OSSL_OP_keymgmt_gen_fn *gen;
+    OSSL_OP_keymgmt_gen_cleanup_fn *gen_cleanup;
 
     /* Key object checking */
     OSSL_OP_keymgmt_query_operation_name_fn *query_operation_name;
     OSSL_OP_keymgmt_has_fn *has;
     OSSL_OP_keymgmt_validate_fn *validate;
+    OSSL_OP_keymgmt_match_fn *match;
 
     /* Import and export routines */
     OSSL_OP_keymgmt_import_fn *import;
     OSSL_OP_keymgmt_import_types_fn *import_types;
     OSSL_OP_keymgmt_export_fn *export;
     OSSL_OP_keymgmt_export_types_fn *export_types;
+    OSSL_OP_keymgmt_copy_fn *copy;
 } /* EVP_KEYMGMT */ ;
 
 struct evp_keyexch_st {
@@ -105,6 +155,8 @@ struct evp_keyexch_st {
     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_OP_keyexch_get_ctx_params_fn *get_ctx_params;
+    OSSL_OP_keyexch_gettable_ctx_params_fn *gettable_ctx_params;
 } /* EVP_KEYEXCH */;
 
 struct evp_signature_st {
@@ -123,9 +175,11 @@ struct evp_signature_st {
     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_sign_fn *digest_sign;
     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_digest_verify_fn *digest_verify;
     OSSL_OP_signature_freectx_fn *freectx;
     OSSL_OP_signature_dupctx_fn *dupctx;
     OSSL_OP_signature_get_ctx_params_fn *get_ctx_params;
@@ -263,12 +317,10 @@ OSSL_PARAM *evp_pkey_to_param(EVP_PKEY *pkey, size_t *sz);
 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);
+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);
-void *evp_pkey_make_provided(EVP_PKEY *pk, OPENSSL_CTX *libctx,
-                             EVP_KEYMGMT **keymgmt, const char *propquery);