kdf.h 4.2 KB

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