tpm2_kdfe.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* SPDX-License-Identifier: BSD-3-Clause */
  2. #ifndef SRC_TPM_KDFE_H_
  3. #define SRC_TPM_KDFE_H_
  4. #include <tss2/tss2_sys.h>
  5. /**
  6. * The KDFe function, defined in Appendix C.6.1 of TPM 2.0 Library
  7. * Specification Part1
  8. * (https://trustedcomputinggroup.org/resource/tpm-library-specification/)
  9. *
  10. * @param hash_alg
  11. * The hashing algorithm to use.
  12. * @param Z
  13. * The ECDH shared secret. Z is the x coordinate of the product of d and Q,
  14. * where d is a private key and Q is the other party's public key.
  15. * @param label
  16. * The label value. ie. "DUPLICATE\0" or "IDENTITY\0".
  17. * @param label_length
  18. * Length of the label.
  19. * @param party_u_info
  20. * The x-coordinate of the public key
  21. * @param party_v_info
  22. * The x-coordinate of the other party's public key
  23. * @param size_in_bits
  24. * The number of bits of the key stream to be generated
  25. * @param result_key
  26. * The buffer to write the generated key stream
  27. * @return
  28. * TPM2_RC_SUCCESS on success
  29. */
  30. TSS2_RC tpm2_kdfe(
  31. TPMI_ALG_HASH hash_alg, TPM2B_ECC_PARAMETER *Z,
  32. const unsigned char *label, int label_length,
  33. TPM2B_ECC_PARAMETER *party_u_info, TPM2B_ECC_PARAMETER *party_v_info,
  34. UINT16 size_in_bits, TPM2B_MAX_BUFFER *result_key );
  35. /**
  36. * Derive the seed value and protected seed value, as specified
  37. * in Appendix C.6.3 of TPM 2.0 Library Specification Part1
  38. * (https://trustedcomputinggroup.org/resource/tpm-library-specification/)
  39. *
  40. * @param[in] parent_pub
  41. * The parents ECC public key.
  42. * @param[in] label
  43. * The label value. ie. "DUPLICATE\0" or "IDENTITY\0".
  44. * @param[in] label_len
  45. * Length of the label.
  46. * @param[out] seed
  47. * The derived seed value
  48. * @param[out] out_sym_seed
  49. * protedted seed value, ie the public key for the ephemeral key.
  50. * @return
  51. * True on success, false otherwise.
  52. */
  53. bool ecdh_derive_seed_and_encrypted_seed(
  54. TPM2B_PUBLIC *parent_pub, const unsigned char *label, int label_len,
  55. TPM2B_DIGEST *seed, TPM2B_ENCRYPTED_SECRET *out_sym_seed);
  56. #endif /* SRC_TPM_KDFE_H_ */