pkey.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Kernelspace interface to the pkey device driver
  4. *
  5. * Copyright IBM Corp. 2016, 2023
  6. *
  7. * Author: Harald Freudenberger <freude@de.ibm.com>
  8. *
  9. */
  10. #ifndef _KAPI_PKEY_H
  11. #define _KAPI_PKEY_H
  12. #include <linux/ioctl.h>
  13. #include <linux/types.h>
  14. #include <uapi/asm/pkey.h>
  15. /*
  16. * In-kernel API: Transform an key blob (of any type) into a protected key.
  17. * @param key pointer to a buffer containing the key blob
  18. * @param keylen size of the key blob in bytes
  19. * @param protkey pointer to buffer receiving the protected key
  20. * @param xflags additional execution flags (see PKEY_XFLAG_* definitions below)
  21. * As of now the only supported flags are PKEY_XFLAG_NOMEMALLOC
  22. * and PKEY_XFLAG_NOCLEARKEY.
  23. * @return 0 on success, negative errno value on failure
  24. */
  25. int pkey_key2protkey(const u8 *key, u32 keylen,
  26. u8 *protkey, u32 *protkeylen, u32 *protkeytype,
  27. u32 xflags);
  28. /*
  29. * If this flag is given in the xflags parameter, the pkey implementation
  30. * is not allowed to allocate memory but instead should fall back to use
  31. * preallocated memory or simple fail with -ENOMEM.
  32. * This flag is for protected key derive within a cipher or similar
  33. * which must not allocate memory which would cause io operations - see
  34. * also the CRYPTO_ALG_ALLOCATES_MEMORY flag in crypto.h.
  35. */
  36. #define PKEY_XFLAG_NOMEMALLOC 0x0001
  37. /*
  38. * Do not accept a clear key token as source for a protected key.
  39. */
  40. #define PKEY_XFLAG_NOCLEARKEY 0x0002
  41. #endif /* _KAPI_PKEY_H */