]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/kdf.h
Update copyright year
[thirdparty/openssl.git] / include / openssl / kdf.h
CommitLineData
1eff3485 1/*
a28d06f3 2 * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
1eff3485 3 *
48f4ad77 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
21dcbebc
RS
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
1eff3485
DSH
8 */
9
ae4186b0
DMSP
10#ifndef OPENSSL_KDF_H
11# define OPENSSL_KDF_H
d86167ec
DMSP
12# pragma once
13
14# include <openssl/macros.h>
936c2b9e 15# ifndef OPENSSL_NO_DEPRECATED_3_0
d86167ec
DMSP
16# define HEADER_KDF_H
17# endif
1eff3485 18
0cf5c6a9
MC
19# include <stdarg.h>
20# include <stddef.h>
50cd4768 21# include <openssl/types.h>
fb9e6dd6
P
22# include <openssl/core.h>
23
5a285add 24# ifdef __cplusplus
1eff3485 25extern "C" {
5a285add
DM
26# endif
27
fb9e6dd6
P
28int EVP_KDF_up_ref(EVP_KDF *kdf);
29void EVP_KDF_free(EVP_KDF *kdf);
b4250010 30EVP_KDF *EVP_KDF_fetch(OSSL_LIB_CTX *libctx, const char *algorithm,
fb9e6dd6 31 const char *properties);
fb9e6dd6 32
660c5344
MC
33EVP_KDF_CTX *EVP_KDF_CTX_new(EVP_KDF *kdf);
34void EVP_KDF_CTX_free(EVP_KDF_CTX *ctx);
35EVP_KDF_CTX *EVP_KDF_CTX_dup(const EVP_KDF_CTX *src);
506cb0f6 36int EVP_KDF_number(const EVP_KDF *kdf);
251e610c 37int EVP_KDF_is_a(const EVP_KDF *kdf, const char *name);
c9452d74 38const char *EVP_KDF_name(const EVP_KDF *kdf);
fb9e6dd6 39const OSSL_PROVIDER *EVP_KDF_provider(const EVP_KDF *kdf);
660c5344 40const EVP_KDF *EVP_KDF_CTX_kdf(EVP_KDF_CTX *ctx);
5a285add 41
1ba21239
SL
42void EVP_KDF_CTX_reset(EVP_KDF_CTX *ctx);
43size_t EVP_KDF_CTX_get_kdf_size(EVP_KDF_CTX *ctx);
5a285add 44int EVP_KDF_derive(EVP_KDF_CTX *ctx, unsigned char *key, size_t keylen);
fb9e6dd6 45int EVP_KDF_get_params(EVP_KDF *kdf, OSSL_PARAM params[]);
660c5344
MC
46int EVP_KDF_CTX_get_params(EVP_KDF_CTX *ctx, OSSL_PARAM params[]);
47int EVP_KDF_CTX_set_params(EVP_KDF_CTX *ctx, const OSSL_PARAM params[]);
fb9e6dd6 48const OSSL_PARAM *EVP_KDF_gettable_params(const EVP_KDF *kdf);
41f7ecf3
P
49const OSSL_PARAM *EVP_KDF_gettable_ctx_params(const EVP_KDF *kdf);
50const OSSL_PARAM *EVP_KDF_settable_ctx_params(const EVP_KDF *kdf);
5a285add 51
b4250010 52void EVP_KDF_do_all_provided(OSSL_LIB_CTX *libctx,
251e610c
RL
53 void (*fn)(EVP_KDF *kdf, void *arg),
54 void *arg);
f651c727
RL
55void EVP_KDF_names_do_all(const EVP_KDF *kdf,
56 void (*fn)(const char *name, void *data),
57 void *data);
5a285add 58
5a285add
DM
59# define EVP_KDF_HKDF_MODE_EXTRACT_AND_EXPAND 0
60# define EVP_KDF_HKDF_MODE_EXTRACT_ONLY 1
61# define EVP_KDF_HKDF_MODE_EXPAND_ONLY 2
62
270a5ce1
JC
63/* SSHKDF key exchange stages.*/
64/* See https://tools.ietf.org/html/rfc4253#section-7.2 */
65#define EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV {65, 0}
66#define EVP_KDF_SSHKDF_TYPE_INITIAL_IV_SRV_TO_CLI {66, 0}
67#define EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_CLI_TO_SRV {67, 0}
68#define EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_SRV_TO_CLI {68, 0}
69#define EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_CLI_TO_SRV {69, 0}
70#define EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_SRV_TO_CLI {70, 0}
5a285add
DM
71
72/**** The legacy PKEY-based KDF API follows. ****/
1eff3485 73
d2139cf8
MC
74# define EVP_PKEY_CTRL_TLS_MD (EVP_PKEY_ALG_CTRL)
75# define EVP_PKEY_CTRL_TLS_SECRET (EVP_PKEY_ALG_CTRL + 1)
76# define EVP_PKEY_CTRL_TLS_SEED (EVP_PKEY_ALG_CTRL + 2)
77# define EVP_PKEY_CTRL_HKDF_MD (EVP_PKEY_ALG_CTRL + 3)
78# define EVP_PKEY_CTRL_HKDF_SALT (EVP_PKEY_ALG_CTRL + 4)
79# define EVP_PKEY_CTRL_HKDF_KEY (EVP_PKEY_ALG_CTRL + 5)
80# define EVP_PKEY_CTRL_HKDF_INFO (EVP_PKEY_ALG_CTRL + 6)
81# define EVP_PKEY_CTRL_HKDF_MODE (EVP_PKEY_ALG_CTRL + 7)
cefa762e
JB
82# define EVP_PKEY_CTRL_PASS (EVP_PKEY_ALG_CTRL + 8)
83# define EVP_PKEY_CTRL_SCRYPT_SALT (EVP_PKEY_ALG_CTRL + 9)
84# define EVP_PKEY_CTRL_SCRYPT_N (EVP_PKEY_ALG_CTRL + 10)
85# define EVP_PKEY_CTRL_SCRYPT_R (EVP_PKEY_ALG_CTRL + 11)
86# define EVP_PKEY_CTRL_SCRYPT_P (EVP_PKEY_ALG_CTRL + 12)
87# define EVP_PKEY_CTRL_SCRYPT_MAXMEM_BYTES (EVP_PKEY_ALG_CTRL + 13)
d2139cf8 88
5a285add
DM
89# define EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND \
90 EVP_KDF_HKDF_MODE_EXTRACT_AND_EXPAND
91# define EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY \
92 EVP_KDF_HKDF_MODE_EXTRACT_ONLY
93# define EVP_PKEY_HKDEF_MODE_EXPAND_ONLY \
94 EVP_KDF_HKDF_MODE_EXPAND_ONLY
1eff3485 95
ac2d58c7 96int EVP_PKEY_CTX_set_tls1_prf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
1eff3485 97
ac2d58c7
MC
98int EVP_PKEY_CTX_set1_tls1_prf_secret(EVP_PKEY_CTX *pctx,
99 const unsigned char *sec, int seclen);
1eff3485 100
ac2d58c7
MC
101int EVP_PKEY_CTX_add1_tls1_prf_seed(EVP_PKEY_CTX *pctx,
102 const unsigned char *seed, int seedlen);
1eff3485 103
05d2f72e 104int EVP_PKEY_CTX_set_hkdf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
aacfb134 105
05d2f72e
MC
106int EVP_PKEY_CTX_set1_hkdf_salt(EVP_PKEY_CTX *ctx,
107 const unsigned char *salt, int saltlen);
aacfb134 108
05d2f72e
MC
109int EVP_PKEY_CTX_set1_hkdf_key(EVP_PKEY_CTX *ctx,
110 const unsigned char *key, int keylen);
aacfb134 111
05d2f72e
MC
112int EVP_PKEY_CTX_add1_hkdf_info(EVP_PKEY_CTX *ctx,
113 const unsigned char *info, int infolen);
aacfb134 114
05d2f72e 115int EVP_PKEY_CTX_hkdf_mode(EVP_PKEY_CTX *ctx, int mode);
cefa762e 116
194de849
MC
117int EVP_PKEY_CTX_set1_pbe_pass(EVP_PKEY_CTX *ctx, const char *pass,
118 int passlen);
cefa762e 119
194de849
MC
120int EVP_PKEY_CTX_set1_scrypt_salt(EVP_PKEY_CTX *ctx,
121 const unsigned char *salt, int saltlen);
cefa762e 122
194de849 123int EVP_PKEY_CTX_set_scrypt_N(EVP_PKEY_CTX *ctx, uint64_t n);
cefa762e 124
194de849 125int EVP_PKEY_CTX_set_scrypt_r(EVP_PKEY_CTX *ctx, uint64_t r);
cefa762e 126
194de849 127int EVP_PKEY_CTX_set_scrypt_p(EVP_PKEY_CTX *ctx, uint64_t p);
cefa762e 128
194de849
MC
129int EVP_PKEY_CTX_set_scrypt_maxmem_bytes(EVP_PKEY_CTX *ctx,
130 uint64_t maxmem_bytes);
cefa762e 131
3e30fa0a 132
5a285add 133# ifdef __cplusplus
1eff3485 134}
0cd0a820 135# endif
1eff3485 136#endif