2016-01-19 13:57:19 +00:00
|
|
|
/*
|
2021-02-18 14:57:13 +00:00
|
|
|
* Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
|
2016-01-19 13:57:19 +00:00
|
|
|
*
|
2018-12-06 12:12:35 +00:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-17 18:24:17 +00: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
|
2016-01-19 13:57:19 +00:00
|
|
|
*/
|
|
|
|
|
2019-09-27 22:45:57 +00:00
|
|
|
#ifndef OPENSSL_KDF_H
|
|
|
|
# define OPENSSL_KDF_H
|
2019-09-27 22:46:00 +00:00
|
|
|
# pragma once
|
|
|
|
|
|
|
|
# include <openssl/macros.h>
|
2019-11-05 16:28:50 +00:00
|
|
|
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
2019-09-27 22:46:00 +00:00
|
|
|
# define HEADER_KDF_H
|
|
|
|
# endif
|
2016-01-19 13:57:19 +00:00
|
|
|
|
2019-02-14 15:22:59 +00:00
|
|
|
# include <stdarg.h>
|
|
|
|
# include <stddef.h>
|
2019-09-27 22:45:46 +00:00
|
|
|
# include <openssl/types.h>
|
2019-08-21 08:54:35 +00:00
|
|
|
# include <openssl/core.h>
|
|
|
|
|
2018-06-21 21:16:18 +00:00
|
|
|
# ifdef __cplusplus
|
2016-01-19 13:57:19 +00:00
|
|
|
extern "C" {
|
2018-06-21 21:16:18 +00:00
|
|
|
# endif
|
|
|
|
|
2019-08-21 08:54:35 +00:00
|
|
|
int EVP_KDF_up_ref(EVP_KDF *kdf);
|
|
|
|
void EVP_KDF_free(EVP_KDF *kdf);
|
2020-10-15 09:55:50 +00:00
|
|
|
EVP_KDF *EVP_KDF_fetch(OSSL_LIB_CTX *libctx, const char *algorithm,
|
2019-08-21 08:54:35 +00:00
|
|
|
const char *properties);
|
|
|
|
|
2020-06-18 08:30:48 +00:00
|
|
|
EVP_KDF_CTX *EVP_KDF_CTX_new(EVP_KDF *kdf);
|
|
|
|
void EVP_KDF_CTX_free(EVP_KDF_CTX *ctx);
|
|
|
|
EVP_KDF_CTX *EVP_KDF_CTX_dup(const EVP_KDF_CTX *src);
|
Rename all getters to use get/get0 in name
For functions that exist in 1.1.1 provide a simple aliases via #define.
Fixes #15236
Functions with OSSL_DECODER_, OSSL_ENCODER_, OSSL_STORE_LOADER_,
EVP_KEYEXCH_, EVP_KEM_, EVP_ASYM_CIPHER_, EVP_SIGNATURE_,
EVP_KEYMGMT_, EVP_RAND_, EVP_MAC_, EVP_KDF_, EVP_PKEY_,
EVP_MD_, and EVP_CIPHER_ prefixes are renamed.
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15405)
2021-05-21 14:58:08 +00:00
|
|
|
const char *EVP_KDF_get0_description(const EVP_KDF *kdf);
|
EVP: add missing common functionality
This adds the missing functions that should be common for all
fetchable EVP sub-APIs:
EVP_KEYMGMT_is_a(), EVP_KEYMGMT_do_all_provided(), EVP_KEYEXCH_is_a(),
EVP_KEYEXCH_do_all_provided(), EVP_KDF_is_a(), EVP_MD_is_a(),
EVP_SIGNATURE_do_all_provided(), EVP_SIGNATURE_is_a().
This also renames EVP_MD_do_all_ex(), EVP_CIPHER_do_all_ex(),
EVP_KDF_do_all_ex(), EVP_MAC_do_all_ex() to change '_ex'
to '_provided'.
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/9979)
2019-09-23 08:33:26 +00:00
|
|
|
int EVP_KDF_is_a(const EVP_KDF *kdf, const char *name);
|
Rename all getters to use get/get0 in name
For functions that exist in 1.1.1 provide a simple aliases via #define.
Fixes #15236
Functions with OSSL_DECODER_, OSSL_ENCODER_, OSSL_STORE_LOADER_,
EVP_KEYEXCH_, EVP_KEM_, EVP_ASYM_CIPHER_, EVP_SIGNATURE_,
EVP_KEYMGMT_, EVP_RAND_, EVP_MAC_, EVP_KDF_, EVP_PKEY_,
EVP_MD_, and EVP_CIPHER_ prefixes are renamed.
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15405)
2021-05-21 14:58:08 +00:00
|
|
|
const char *EVP_KDF_get0_name(const EVP_KDF *kdf);
|
|
|
|
const OSSL_PROVIDER *EVP_KDF_get0_provider(const EVP_KDF *kdf);
|
2020-06-18 08:30:48 +00:00
|
|
|
const EVP_KDF *EVP_KDF_CTX_kdf(EVP_KDF_CTX *ctx);
|
2018-06-21 21:16:18 +00:00
|
|
|
|
2020-10-13 04:30:12 +00:00
|
|
|
void EVP_KDF_CTX_reset(EVP_KDF_CTX *ctx);
|
|
|
|
size_t EVP_KDF_CTX_get_kdf_size(EVP_KDF_CTX *ctx);
|
2021-02-26 00:06:11 +00:00
|
|
|
int EVP_KDF_derive(EVP_KDF_CTX *ctx, unsigned char *key, size_t keylen,
|
|
|
|
const OSSL_PARAM params[]);
|
2019-08-21 08:54:35 +00:00
|
|
|
int EVP_KDF_get_params(EVP_KDF *kdf, OSSL_PARAM params[]);
|
2020-06-18 08:30:48 +00:00
|
|
|
int EVP_KDF_CTX_get_params(EVP_KDF_CTX *ctx, OSSL_PARAM params[]);
|
|
|
|
int EVP_KDF_CTX_set_params(EVP_KDF_CTX *ctx, const OSSL_PARAM params[]);
|
2019-08-21 08:54:35 +00:00
|
|
|
const OSSL_PARAM *EVP_KDF_gettable_params(const EVP_KDF *kdf);
|
2019-09-27 06:35:45 +00:00
|
|
|
const OSSL_PARAM *EVP_KDF_gettable_ctx_params(const EVP_KDF *kdf);
|
|
|
|
const OSSL_PARAM *EVP_KDF_settable_ctx_params(const EVP_KDF *kdf);
|
2021-02-23 00:46:08 +00:00
|
|
|
const OSSL_PARAM *EVP_KDF_CTX_gettable_params(EVP_KDF_CTX *ctx);
|
|
|
|
const OSSL_PARAM *EVP_KDF_CTX_settable_params(EVP_KDF_CTX *ctx);
|
2018-06-21 21:16:18 +00:00
|
|
|
|
2020-10-15 09:55:50 +00:00
|
|
|
void EVP_KDF_do_all_provided(OSSL_LIB_CTX *libctx,
|
EVP: add missing common functionality
This adds the missing functions that should be common for all
fetchable EVP sub-APIs:
EVP_KEYMGMT_is_a(), EVP_KEYMGMT_do_all_provided(), EVP_KEYEXCH_is_a(),
EVP_KEYEXCH_do_all_provided(), EVP_KDF_is_a(), EVP_MD_is_a(),
EVP_SIGNATURE_do_all_provided(), EVP_SIGNATURE_is_a().
This also renames EVP_MD_do_all_ex(), EVP_CIPHER_do_all_ex(),
EVP_KDF_do_all_ex(), EVP_MAC_do_all_ex() to change '_ex'
to '_provided'.
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/9979)
2019-09-23 08:33:26 +00:00
|
|
|
void (*fn)(EVP_KDF *kdf, void *arg),
|
|
|
|
void *arg);
|
2021-02-19 17:03:43 +00:00
|
|
|
int EVP_KDF_names_do_all(const EVP_KDF *kdf,
|
|
|
|
void (*fn)(const char *name, void *data),
|
|
|
|
void *data);
|
2018-06-21 21:16:18 +00:00
|
|
|
|
|
|
|
# define EVP_KDF_HKDF_MODE_EXTRACT_AND_EXPAND 0
|
|
|
|
# define EVP_KDF_HKDF_MODE_EXTRACT_ONLY 1
|
|
|
|
# define EVP_KDF_HKDF_MODE_EXPAND_ONLY 2
|
|
|
|
|
2021-02-01 07:58:58 +00:00
|
|
|
#define EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV 65
|
|
|
|
#define EVP_KDF_SSHKDF_TYPE_INITIAL_IV_SRV_TO_CLI 66
|
|
|
|
#define EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_CLI_TO_SRV 67
|
|
|
|
#define EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_SRV_TO_CLI 68
|
|
|
|
#define EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_CLI_TO_SRV 69
|
|
|
|
#define EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_SRV_TO_CLI 70
|
2018-06-21 21:16:18 +00:00
|
|
|
|
|
|
|
/**** The legacy PKEY-based KDF API follows. ****/
|
2016-01-19 13:57:19 +00:00
|
|
|
|
2016-11-07 10:16:57 +00:00
|
|
|
# define EVP_PKEY_CTRL_TLS_MD (EVP_PKEY_ALG_CTRL)
|
|
|
|
# define EVP_PKEY_CTRL_TLS_SECRET (EVP_PKEY_ALG_CTRL + 1)
|
|
|
|
# define EVP_PKEY_CTRL_TLS_SEED (EVP_PKEY_ALG_CTRL + 2)
|
|
|
|
# define EVP_PKEY_CTRL_HKDF_MD (EVP_PKEY_ALG_CTRL + 3)
|
|
|
|
# define EVP_PKEY_CTRL_HKDF_SALT (EVP_PKEY_ALG_CTRL + 4)
|
|
|
|
# define EVP_PKEY_CTRL_HKDF_KEY (EVP_PKEY_ALG_CTRL + 5)
|
|
|
|
# define EVP_PKEY_CTRL_HKDF_INFO (EVP_PKEY_ALG_CTRL + 6)
|
|
|
|
# define EVP_PKEY_CTRL_HKDF_MODE (EVP_PKEY_ALG_CTRL + 7)
|
2017-07-22 18:04:55 +00:00
|
|
|
# define EVP_PKEY_CTRL_PASS (EVP_PKEY_ALG_CTRL + 8)
|
|
|
|
# define EVP_PKEY_CTRL_SCRYPT_SALT (EVP_PKEY_ALG_CTRL + 9)
|
|
|
|
# define EVP_PKEY_CTRL_SCRYPT_N (EVP_PKEY_ALG_CTRL + 10)
|
|
|
|
# define EVP_PKEY_CTRL_SCRYPT_R (EVP_PKEY_ALG_CTRL + 11)
|
|
|
|
# define EVP_PKEY_CTRL_SCRYPT_P (EVP_PKEY_ALG_CTRL + 12)
|
|
|
|
# define EVP_PKEY_CTRL_SCRYPT_MAXMEM_BYTES (EVP_PKEY_ALG_CTRL + 13)
|
2016-11-07 10:16:57 +00:00
|
|
|
|
2018-06-21 21:16:18 +00:00
|
|
|
# define EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND \
|
|
|
|
EVP_KDF_HKDF_MODE_EXTRACT_AND_EXPAND
|
|
|
|
# define EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY \
|
|
|
|
EVP_KDF_HKDF_MODE_EXTRACT_ONLY
|
|
|
|
# define EVP_PKEY_HKDEF_MODE_EXPAND_ONLY \
|
|
|
|
EVP_KDF_HKDF_MODE_EXPAND_ONLY
|
2016-01-19 13:57:19 +00:00
|
|
|
|
2020-07-03 15:18:03 +00:00
|
|
|
int EVP_PKEY_CTX_set_tls1_prf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
|
2016-01-19 13:57:19 +00:00
|
|
|
|
2020-07-03 15:18:03 +00:00
|
|
|
int EVP_PKEY_CTX_set1_tls1_prf_secret(EVP_PKEY_CTX *pctx,
|
|
|
|
const unsigned char *sec, int seclen);
|
2016-01-19 13:57:19 +00:00
|
|
|
|
2020-07-03 15:18:03 +00:00
|
|
|
int EVP_PKEY_CTX_add1_tls1_prf_seed(EVP_PKEY_CTX *pctx,
|
|
|
|
const unsigned char *seed, int seedlen);
|
2016-01-19 13:57:19 +00:00
|
|
|
|
2020-07-20 17:06:55 +00:00
|
|
|
int EVP_PKEY_CTX_set_hkdf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
|
2016-03-02 23:58:27 +00:00
|
|
|
|
2020-07-20 17:06:55 +00:00
|
|
|
int EVP_PKEY_CTX_set1_hkdf_salt(EVP_PKEY_CTX *ctx,
|
|
|
|
const unsigned char *salt, int saltlen);
|
2016-03-02 23:58:27 +00:00
|
|
|
|
2020-07-20 17:06:55 +00:00
|
|
|
int EVP_PKEY_CTX_set1_hkdf_key(EVP_PKEY_CTX *ctx,
|
|
|
|
const unsigned char *key, int keylen);
|
2016-03-02 23:58:27 +00:00
|
|
|
|
2020-07-20 17:06:55 +00:00
|
|
|
int EVP_PKEY_CTX_add1_hkdf_info(EVP_PKEY_CTX *ctx,
|
|
|
|
const unsigned char *info, int infolen);
|
2016-03-02 23:58:27 +00:00
|
|
|
|
Rename all getters to use get/get0 in name
For functions that exist in 1.1.1 provide a simple aliases via #define.
Fixes #15236
Functions with OSSL_DECODER_, OSSL_ENCODER_, OSSL_STORE_LOADER_,
EVP_KEYEXCH_, EVP_KEM_, EVP_ASYM_CIPHER_, EVP_SIGNATURE_,
EVP_KEYMGMT_, EVP_RAND_, EVP_MAC_, EVP_KDF_, EVP_PKEY_,
EVP_MD_, and EVP_CIPHER_ prefixes are renamed.
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15405)
2021-05-21 14:58:08 +00:00
|
|
|
int EVP_PKEY_CTX_set_hkdf_mode(EVP_PKEY_CTX *ctx, int mode);
|
|
|
|
# define EVP_PKEY_CTX_hkdf_mode EVP_PKEY_CTX_set_hkdf_mode
|
2017-07-22 18:04:55 +00:00
|
|
|
|
2020-07-31 14:05:57 +00:00
|
|
|
int EVP_PKEY_CTX_set1_pbe_pass(EVP_PKEY_CTX *ctx, const char *pass,
|
|
|
|
int passlen);
|
2017-07-22 18:04:55 +00:00
|
|
|
|
2020-07-31 14:05:57 +00:00
|
|
|
int EVP_PKEY_CTX_set1_scrypt_salt(EVP_PKEY_CTX *ctx,
|
|
|
|
const unsigned char *salt, int saltlen);
|
2017-07-22 18:04:55 +00:00
|
|
|
|
2020-07-31 14:05:57 +00:00
|
|
|
int EVP_PKEY_CTX_set_scrypt_N(EVP_PKEY_CTX *ctx, uint64_t n);
|
2017-07-22 18:04:55 +00:00
|
|
|
|
2020-07-31 14:05:57 +00:00
|
|
|
int EVP_PKEY_CTX_set_scrypt_r(EVP_PKEY_CTX *ctx, uint64_t r);
|
2017-07-22 18:04:55 +00:00
|
|
|
|
2020-07-31 14:05:57 +00:00
|
|
|
int EVP_PKEY_CTX_set_scrypt_p(EVP_PKEY_CTX *ctx, uint64_t p);
|
2017-07-22 18:04:55 +00:00
|
|
|
|
2020-07-31 14:05:57 +00:00
|
|
|
int EVP_PKEY_CTX_set_scrypt_maxmem_bytes(EVP_PKEY_CTX *ctx,
|
|
|
|
uint64_t maxmem_bytes);
|
2017-07-22 18:04:55 +00:00
|
|
|
|
2016-03-02 04:11:02 +00:00
|
|
|
|
2018-06-21 21:16:18 +00:00
|
|
|
# ifdef __cplusplus
|
2016-01-19 13:57:19 +00:00
|
|
|
}
|
2016-05-23 19:02:34 +00:00
|
|
|
# endif
|
2016-01-19 13:57:19 +00:00
|
|
|
#endif
|