Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:44

0001 /*
0002  * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
0003  *
0004  * Licensed under the Apache License 2.0 (the "License").  You may not use
0005  * this file except in compliance with the License.  You can obtain a copy
0006  * in the file LICENSE in the source distribution or at
0007  * https://www.openssl.org/source/license.html
0008  */
0009 
0010 #ifndef OPENSSL_KDF_H
0011 # define OPENSSL_KDF_H
0012 # pragma once
0013 
0014 # include <openssl/macros.h>
0015 # ifndef OPENSSL_NO_DEPRECATED_3_0
0016 #  define HEADER_KDF_H
0017 # endif
0018 
0019 # include <stdarg.h>
0020 # include <stddef.h>
0021 # include <openssl/types.h>
0022 # include <openssl/core.h>
0023 
0024 # ifdef __cplusplus
0025 extern "C" {
0026 # endif
0027 
0028 int EVP_KDF_up_ref(EVP_KDF *kdf);
0029 void EVP_KDF_free(EVP_KDF *kdf);
0030 EVP_KDF *EVP_KDF_fetch(OSSL_LIB_CTX *libctx, const char *algorithm,
0031                        const char *properties);
0032 
0033 EVP_KDF_CTX *EVP_KDF_CTX_new(EVP_KDF *kdf);
0034 void EVP_KDF_CTX_free(EVP_KDF_CTX *ctx);
0035 EVP_KDF_CTX *EVP_KDF_CTX_dup(const EVP_KDF_CTX *src);
0036 const char *EVP_KDF_get0_description(const EVP_KDF *kdf);
0037 int EVP_KDF_is_a(const EVP_KDF *kdf, const char *name);
0038 const char *EVP_KDF_get0_name(const EVP_KDF *kdf);
0039 const OSSL_PROVIDER *EVP_KDF_get0_provider(const EVP_KDF *kdf);
0040 const EVP_KDF *EVP_KDF_CTX_kdf(EVP_KDF_CTX *ctx);
0041 
0042 void EVP_KDF_CTX_reset(EVP_KDF_CTX *ctx);
0043 size_t EVP_KDF_CTX_get_kdf_size(EVP_KDF_CTX *ctx);
0044 int EVP_KDF_derive(EVP_KDF_CTX *ctx, unsigned char *key, size_t keylen,
0045                    const OSSL_PARAM params[]);
0046 int EVP_KDF_get_params(EVP_KDF *kdf, OSSL_PARAM params[]);
0047 int EVP_KDF_CTX_get_params(EVP_KDF_CTX *ctx, OSSL_PARAM params[]);
0048 int EVP_KDF_CTX_set_params(EVP_KDF_CTX *ctx, const OSSL_PARAM params[]);
0049 const OSSL_PARAM *EVP_KDF_gettable_params(const EVP_KDF *kdf);
0050 const OSSL_PARAM *EVP_KDF_gettable_ctx_params(const EVP_KDF *kdf);
0051 const OSSL_PARAM *EVP_KDF_settable_ctx_params(const EVP_KDF *kdf);
0052 const OSSL_PARAM *EVP_KDF_CTX_gettable_params(EVP_KDF_CTX *ctx);
0053 const OSSL_PARAM *EVP_KDF_CTX_settable_params(EVP_KDF_CTX *ctx);
0054 
0055 void EVP_KDF_do_all_provided(OSSL_LIB_CTX *libctx,
0056                              void (*fn)(EVP_KDF *kdf, void *arg),
0057                              void *arg);
0058 int EVP_KDF_names_do_all(const EVP_KDF *kdf,
0059                          void (*fn)(const char *name, void *data),
0060                          void *data);
0061 
0062 # define EVP_KDF_HKDF_MODE_EXTRACT_AND_EXPAND  0
0063 # define EVP_KDF_HKDF_MODE_EXTRACT_ONLY        1
0064 # define EVP_KDF_HKDF_MODE_EXPAND_ONLY         2
0065 
0066 #define EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV     65
0067 #define EVP_KDF_SSHKDF_TYPE_INITIAL_IV_SRV_TO_CLI     66
0068 #define EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_CLI_TO_SRV 67
0069 #define EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_SRV_TO_CLI 68
0070 #define EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_CLI_TO_SRV  69
0071 #define EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_SRV_TO_CLI  70
0072 
0073 /**** The legacy PKEY-based KDF API follows. ****/
0074 
0075 # define EVP_PKEY_CTRL_TLS_MD                   (EVP_PKEY_ALG_CTRL)
0076 # define EVP_PKEY_CTRL_TLS_SECRET               (EVP_PKEY_ALG_CTRL + 1)
0077 # define EVP_PKEY_CTRL_TLS_SEED                 (EVP_PKEY_ALG_CTRL + 2)
0078 # define EVP_PKEY_CTRL_HKDF_MD                  (EVP_PKEY_ALG_CTRL + 3)
0079 # define EVP_PKEY_CTRL_HKDF_SALT                (EVP_PKEY_ALG_CTRL + 4)
0080 # define EVP_PKEY_CTRL_HKDF_KEY                 (EVP_PKEY_ALG_CTRL + 5)
0081 # define EVP_PKEY_CTRL_HKDF_INFO                (EVP_PKEY_ALG_CTRL + 6)
0082 # define EVP_PKEY_CTRL_HKDF_MODE                (EVP_PKEY_ALG_CTRL + 7)
0083 # define EVP_PKEY_CTRL_PASS                     (EVP_PKEY_ALG_CTRL + 8)
0084 # define EVP_PKEY_CTRL_SCRYPT_SALT              (EVP_PKEY_ALG_CTRL + 9)
0085 # define EVP_PKEY_CTRL_SCRYPT_N                 (EVP_PKEY_ALG_CTRL + 10)
0086 # define EVP_PKEY_CTRL_SCRYPT_R                 (EVP_PKEY_ALG_CTRL + 11)
0087 # define EVP_PKEY_CTRL_SCRYPT_P                 (EVP_PKEY_ALG_CTRL + 12)
0088 # define EVP_PKEY_CTRL_SCRYPT_MAXMEM_BYTES      (EVP_PKEY_ALG_CTRL + 13)
0089 
0090 # define EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND \
0091             EVP_KDF_HKDF_MODE_EXTRACT_AND_EXPAND
0092 # define EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY       \
0093             EVP_KDF_HKDF_MODE_EXTRACT_ONLY
0094 # define EVP_PKEY_HKDEF_MODE_EXPAND_ONLY        \
0095             EVP_KDF_HKDF_MODE_EXPAND_ONLY
0096 
0097 int EVP_PKEY_CTX_set_tls1_prf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
0098 
0099 int EVP_PKEY_CTX_set1_tls1_prf_secret(EVP_PKEY_CTX *pctx,
0100                                       const unsigned char *sec, int seclen);
0101 
0102 int EVP_PKEY_CTX_add1_tls1_prf_seed(EVP_PKEY_CTX *pctx,
0103                                     const unsigned char *seed, int seedlen);
0104 
0105 int EVP_PKEY_CTX_set_hkdf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
0106 
0107 int EVP_PKEY_CTX_set1_hkdf_salt(EVP_PKEY_CTX *ctx,
0108                                 const unsigned char *salt, int saltlen);
0109 
0110 int EVP_PKEY_CTX_set1_hkdf_key(EVP_PKEY_CTX *ctx,
0111                                const unsigned char *key, int keylen);
0112 
0113 int EVP_PKEY_CTX_add1_hkdf_info(EVP_PKEY_CTX *ctx,
0114                                 const unsigned char *info, int infolen);
0115 
0116 int EVP_PKEY_CTX_set_hkdf_mode(EVP_PKEY_CTX *ctx, int mode);
0117 # define EVP_PKEY_CTX_hkdf_mode EVP_PKEY_CTX_set_hkdf_mode
0118 
0119 int EVP_PKEY_CTX_set1_pbe_pass(EVP_PKEY_CTX *ctx, const char *pass,
0120                                int passlen);
0121 
0122 int EVP_PKEY_CTX_set1_scrypt_salt(EVP_PKEY_CTX *ctx,
0123                                   const unsigned char *salt, int saltlen);
0124 
0125 int EVP_PKEY_CTX_set_scrypt_N(EVP_PKEY_CTX *ctx, uint64_t n);
0126 
0127 int EVP_PKEY_CTX_set_scrypt_r(EVP_PKEY_CTX *ctx, uint64_t r);
0128 
0129 int EVP_PKEY_CTX_set_scrypt_p(EVP_PKEY_CTX *ctx, uint64_t p);
0130 
0131 int EVP_PKEY_CTX_set_scrypt_maxmem_bytes(EVP_PKEY_CTX *ctx,
0132                                          uint64_t maxmem_bytes);
0133 
0134 
0135 # ifdef __cplusplus
0136 }
0137 # endif
0138 #endif