1 /* 2 * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. 3 * 4 * Licensed under the OpenSSL license (the "License"). You may not use 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 8 */ 9 10 #ifndef HEADER_KDF_H 11 # define HEADER_KDF_H 12 13 # include <openssl/kdferr.h> 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 # define EVP_PKEY_CTRL_TLS_MD (EVP_PKEY_ALG_CTRL) 19 # define EVP_PKEY_CTRL_TLS_SECRET (EVP_PKEY_ALG_CTRL + 1) 20 # define EVP_PKEY_CTRL_TLS_SEED (EVP_PKEY_ALG_CTRL + 2) 21 # define EVP_PKEY_CTRL_HKDF_MD (EVP_PKEY_ALG_CTRL + 3) 22 # define EVP_PKEY_CTRL_HKDF_SALT (EVP_PKEY_ALG_CTRL + 4) 23 # define EVP_PKEY_CTRL_HKDF_KEY (EVP_PKEY_ALG_CTRL + 5) 24 # define EVP_PKEY_CTRL_HKDF_INFO (EVP_PKEY_ALG_CTRL + 6) 25 # define EVP_PKEY_CTRL_HKDF_MODE (EVP_PKEY_ALG_CTRL + 7) 26 # define EVP_PKEY_CTRL_PASS (EVP_PKEY_ALG_CTRL + 8) 27 # define EVP_PKEY_CTRL_SCRYPT_SALT (EVP_PKEY_ALG_CTRL + 9) 28 # define EVP_PKEY_CTRL_SCRYPT_N (EVP_PKEY_ALG_CTRL + 10) 29 # define EVP_PKEY_CTRL_SCRYPT_R (EVP_PKEY_ALG_CTRL + 11) 30 # define EVP_PKEY_CTRL_SCRYPT_P (EVP_PKEY_ALG_CTRL + 12) 31 # define EVP_PKEY_CTRL_SCRYPT_MAXMEM_BYTES (EVP_PKEY_ALG_CTRL + 13) 32 33 # define EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND 0 34 # define EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY 1 35 # define EVP_PKEY_HKDEF_MODE_EXPAND_ONLY 2 36 37 # define EVP_PKEY_CTX_set_tls1_prf_md(pctx, md) \ 38 EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 39 EVP_PKEY_CTRL_TLS_MD, 0, (void *)(md)) 40 41 # define EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, sec, seclen) \ 42 EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 43 EVP_PKEY_CTRL_TLS_SECRET, seclen, (void *)(sec)) 44 45 # define EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed, seedlen) \ 46 EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 47 EVP_PKEY_CTRL_TLS_SEED, seedlen, (void *)(seed)) 48 49 # define EVP_PKEY_CTX_set_hkdf_md(pctx, md) \ 50 EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 51 EVP_PKEY_CTRL_HKDF_MD, 0, (void *)(md)) 52 53 # define EVP_PKEY_CTX_set1_hkdf_salt(pctx, salt, saltlen) \ 54 EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 55 EVP_PKEY_CTRL_HKDF_SALT, saltlen, (void *)(salt)) 56 57 # define EVP_PKEY_CTX_set1_hkdf_key(pctx, key, keylen) \ 58 EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 59 EVP_PKEY_CTRL_HKDF_KEY, keylen, (void *)(key)) 60 61 # define EVP_PKEY_CTX_add1_hkdf_info(pctx, info, infolen) \ 62 EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 63 EVP_PKEY_CTRL_HKDF_INFO, infolen, (void *)(info)) 64 65 # define EVP_PKEY_CTX_hkdf_mode(pctx, mode) \ 66 EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 67 EVP_PKEY_CTRL_HKDF_MODE, mode, NULL) 68 69 # define EVP_PKEY_CTX_set1_pbe_pass(pctx, pass, passlen) \ 70 EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 71 EVP_PKEY_CTRL_PASS, passlen, (void *)(pass)) 72 73 # define EVP_PKEY_CTX_set1_scrypt_salt(pctx, salt, saltlen) \ 74 EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ 75 EVP_PKEY_CTRL_SCRYPT_SALT, saltlen, (void *)(salt)) 76 77 # define EVP_PKEY_CTX_set_scrypt_N(pctx, n) \ 78 EVP_PKEY_CTX_ctrl_uint64(pctx, -1, EVP_PKEY_OP_DERIVE, \ 79 EVP_PKEY_CTRL_SCRYPT_N, n) 80 81 # define EVP_PKEY_CTX_set_scrypt_r(pctx, r) \ 82 EVP_PKEY_CTX_ctrl_uint64(pctx, -1, EVP_PKEY_OP_DERIVE, \ 83 EVP_PKEY_CTRL_SCRYPT_R, r) 84 85 # define EVP_PKEY_CTX_set_scrypt_p(pctx, p) \ 86 EVP_PKEY_CTX_ctrl_uint64(pctx, -1, EVP_PKEY_OP_DERIVE, \ 87 EVP_PKEY_CTRL_SCRYPT_P, p) 88 89 # define EVP_PKEY_CTX_set_scrypt_maxmem_bytes(pctx, maxmem_bytes) \ 90 EVP_PKEY_CTX_ctrl_uint64(pctx, -1, EVP_PKEY_OP_DERIVE, \ 91 EVP_PKEY_CTRL_SCRYPT_MAXMEM_BYTES, maxmem_bytes) 92 93 94 # ifdef __cplusplus 95 } 96 # endif 97 #endif 98