pkey.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * Userspace interface to the pkey device driver
  4. *
  5. * Copyright IBM Corp. 2017, 2023
  6. *
  7. * Author: Harald Freudenberger <freude@de.ibm.com>
  8. *
  9. */
  10. #ifndef _UAPI_PKEY_H
  11. #define _UAPI_PKEY_H
  12. #include <linux/ioctl.h>
  13. #include <linux/types.h>
  14. /*
  15. * Ioctl calls supported by the pkey device driver
  16. */
  17. #define PKEY_IOCTL_MAGIC 'p'
  18. #define SECKEYBLOBSIZE 64 /* secure key blob size is always 64 bytes */
  19. #define PROTKEYBLOBSIZE 80 /* protected key blob size is always 80 bytes */
  20. #define MAXPROTKEYSIZE 64 /* a protected key blob may be up to 64 bytes */
  21. #define MAXCLRKEYSIZE 32 /* a clear key value may be up to 32 bytes */
  22. #define MAXAESCIPHERKEYSIZE 136 /* our aes cipher keys have always 136 bytes */
  23. #define MINEP11AESKEYBLOBSIZE 256 /* min EP11 AES key blob size */
  24. #define MAXEP11AESKEYBLOBSIZE 336 /* max EP11 AES key blob size */
  25. /* Minimum size of a key blob */
  26. #define MINKEYBLOBSIZE SECKEYBLOBSIZE
  27. /* defines for the type field within the pkey_protkey struct */
  28. #define PKEY_KEYTYPE_AES_128 1
  29. #define PKEY_KEYTYPE_AES_192 2
  30. #define PKEY_KEYTYPE_AES_256 3
  31. #define PKEY_KEYTYPE_ECC 4
  32. #define PKEY_KEYTYPE_ECC_P256 5
  33. #define PKEY_KEYTYPE_ECC_P384 6
  34. #define PKEY_KEYTYPE_ECC_P521 7
  35. #define PKEY_KEYTYPE_ECC_ED25519 8
  36. #define PKEY_KEYTYPE_ECC_ED448 9
  37. #define PKEY_KEYTYPE_AES_XTS_128 10
  38. #define PKEY_KEYTYPE_AES_XTS_256 11
  39. #define PKEY_KEYTYPE_HMAC_512 12
  40. #define PKEY_KEYTYPE_HMAC_1024 13
  41. /* the newer ioctls use a pkey_key_type enum for type information */
  42. enum pkey_key_type {
  43. PKEY_TYPE_CCA_DATA = (__u32) 1,
  44. PKEY_TYPE_CCA_CIPHER = (__u32) 2,
  45. PKEY_TYPE_EP11 = (__u32) 3,
  46. PKEY_TYPE_CCA_ECC = (__u32) 0x1f,
  47. PKEY_TYPE_EP11_AES = (__u32) 6,
  48. PKEY_TYPE_EP11_ECC = (__u32) 7,
  49. PKEY_TYPE_PROTKEY = (__u32) 8,
  50. };
  51. /* the newer ioctls use a pkey_key_size enum for key size information */
  52. enum pkey_key_size {
  53. PKEY_SIZE_AES_128 = (__u32) 128,
  54. PKEY_SIZE_AES_192 = (__u32) 192,
  55. PKEY_SIZE_AES_256 = (__u32) 256,
  56. PKEY_SIZE_UNKNOWN = (__u32) 0xFFFFFFFF,
  57. };
  58. /* some of the newer ioctls use these flags */
  59. #define PKEY_FLAGS_MATCH_CUR_MKVP 0x00000002
  60. #define PKEY_FLAGS_MATCH_ALT_MKVP 0x00000004
  61. /* keygenflags defines for CCA AES cipher keys */
  62. #define PKEY_KEYGEN_XPRT_SYM 0x00008000
  63. #define PKEY_KEYGEN_XPRT_UASY 0x00004000
  64. #define PKEY_KEYGEN_XPRT_AASY 0x00002000
  65. #define PKEY_KEYGEN_XPRT_RAW 0x00001000
  66. #define PKEY_KEYGEN_XPRT_CPAC 0x00000800
  67. #define PKEY_KEYGEN_XPRT_DES 0x00000080
  68. #define PKEY_KEYGEN_XPRT_AES 0x00000040
  69. #define PKEY_KEYGEN_XPRT_RSA 0x00000008
  70. /* Struct to hold apqn target info (card/domain pair) */
  71. struct pkey_apqn {
  72. __u16 card;
  73. __u16 domain;
  74. };
  75. /* Struct to hold a CCA AES secure key blob */
  76. struct pkey_seckey {
  77. __u8 seckey[SECKEYBLOBSIZE]; /* the secure key blob */
  78. };
  79. /* Struct to hold protected key and length info */
  80. struct pkey_protkey {
  81. __u32 type; /* key type, one of the PKEY_KEYTYPE_AES values */
  82. __u32 len; /* bytes actually stored in protkey[] */
  83. __u8 protkey[MAXPROTKEYSIZE]; /* the protected key blob */
  84. };
  85. /* Struct to hold an AES clear key value */
  86. struct pkey_clrkey {
  87. __u8 clrkey[MAXCLRKEYSIZE]; /* 16, 24, or 32 byte clear key value */
  88. };
  89. /*
  90. * EP11 key blobs of type PKEY_TYPE_EP11_AES and PKEY_TYPE_EP11_ECC
  91. * are ep11 blobs prepended by this header:
  92. */
  93. struct ep11kblob_header {
  94. __u8 type; /* always 0x00 */
  95. __u8 hver; /* header version, currently needs to be 0x00 */
  96. __u16 len; /* total length in bytes (including this header) */
  97. __u8 version; /* PKEY_TYPE_EP11_AES or PKEY_TYPE_EP11_ECC */
  98. __u8 res0; /* unused */
  99. __u16 bitlen; /* clear key bit len, 0 for unknown */
  100. __u8 res1[8]; /* unused */
  101. } __packed;
  102. /*
  103. * Generate CCA AES secure key.
  104. */
  105. struct pkey_genseck {
  106. __u16 cardnr; /* in: card to use or FFFF for any */
  107. __u16 domain; /* in: domain or FFFF for any */
  108. __u32 keytype; /* in: key type to generate */
  109. struct pkey_seckey seckey; /* out: the secure key blob */
  110. };
  111. #define PKEY_GENSECK _IOWR(PKEY_IOCTL_MAGIC, 0x01, struct pkey_genseck)
  112. /*
  113. * Construct CCA AES secure key from clear key value
  114. */
  115. struct pkey_clr2seck {
  116. __u16 cardnr; /* in: card to use or FFFF for any */
  117. __u16 domain; /* in: domain or FFFF for any */
  118. __u32 keytype; /* in: key type to generate */
  119. struct pkey_clrkey clrkey; /* in: the clear key value */
  120. struct pkey_seckey seckey; /* out: the secure key blob */
  121. };
  122. #define PKEY_CLR2SECK _IOWR(PKEY_IOCTL_MAGIC, 0x02, struct pkey_clr2seck)
  123. /*
  124. * Fabricate AES protected key from a CCA AES secure key
  125. */
  126. struct pkey_sec2protk {
  127. __u16 cardnr; /* in: card to use or FFFF for any */
  128. __u16 domain; /* in: domain or FFFF for any */
  129. struct pkey_seckey seckey; /* in: the secure key blob */
  130. struct pkey_protkey protkey; /* out: the protected key */
  131. };
  132. #define PKEY_SEC2PROTK _IOWR(PKEY_IOCTL_MAGIC, 0x03, struct pkey_sec2protk)
  133. /*
  134. * Fabricate AES protected key from clear key value
  135. */
  136. struct pkey_clr2protk {
  137. __u32 keytype; /* in: key type to generate */
  138. struct pkey_clrkey clrkey; /* in: the clear key value */
  139. struct pkey_protkey protkey; /* out: the protected key */
  140. };
  141. #define PKEY_CLR2PROTK _IOWR(PKEY_IOCTL_MAGIC, 0x04, struct pkey_clr2protk)
  142. /*
  143. * Search for matching crypto card based on the Master Key
  144. * Verification Pattern provided inside a CCA AES secure key.
  145. */
  146. struct pkey_findcard {
  147. struct pkey_seckey seckey; /* in: the secure key blob */
  148. __u16 cardnr; /* out: card number */
  149. __u16 domain; /* out: domain number */
  150. };
  151. #define PKEY_FINDCARD _IOWR(PKEY_IOCTL_MAGIC, 0x05, struct pkey_findcard)
  152. /*
  153. * Combined together: findcard + sec2prot
  154. */
  155. struct pkey_skey2pkey {
  156. struct pkey_seckey seckey; /* in: the secure key blob */
  157. struct pkey_protkey protkey; /* out: the protected key */
  158. };
  159. #define PKEY_SKEY2PKEY _IOWR(PKEY_IOCTL_MAGIC, 0x06, struct pkey_skey2pkey)
  160. /*
  161. * Verify the given CCA AES secure key for being able to be usable with
  162. * the pkey module. Check for correct key type and check for having at
  163. * least one crypto card being able to handle this key (master key
  164. * or old master key verification pattern matches).
  165. * Return some info about the key: keysize in bits, keytype (currently
  166. * only AES), flag if key is wrapped with an old MKVP.
  167. */
  168. struct pkey_verifykey {
  169. struct pkey_seckey seckey; /* in: the secure key blob */
  170. __u16 cardnr; /* out: card number */
  171. __u16 domain; /* out: domain number */
  172. __u16 keysize; /* out: key size in bits */
  173. __u32 attributes; /* out: attribute bits */
  174. };
  175. #define PKEY_VERIFYKEY _IOWR(PKEY_IOCTL_MAGIC, 0x07, struct pkey_verifykey)
  176. #define PKEY_VERIFY_ATTR_AES 0x00000001 /* key is an AES key */
  177. #define PKEY_VERIFY_ATTR_OLD_MKVP 0x00000100 /* key has old MKVP value */
  178. /*
  179. * Generate AES random protected key.
  180. */
  181. struct pkey_genprotk {
  182. __u32 keytype; /* in: key type to generate */
  183. struct pkey_protkey protkey; /* out: the protected key */
  184. };
  185. #define PKEY_GENPROTK _IOWR(PKEY_IOCTL_MAGIC, 0x08, struct pkey_genprotk)
  186. /*
  187. * Verify an AES protected key.
  188. */
  189. struct pkey_verifyprotk {
  190. struct pkey_protkey protkey; /* in: the protected key to verify */
  191. };
  192. #define PKEY_VERIFYPROTK _IOW(PKEY_IOCTL_MAGIC, 0x09, struct pkey_verifyprotk)
  193. /*
  194. * Transform an key blob (of any type) into a protected key
  195. */
  196. struct pkey_kblob2pkey {
  197. __u8 __user *key; /* in: the key blob */
  198. __u32 keylen; /* in: the key blob length */
  199. struct pkey_protkey protkey; /* out: the protected key */
  200. };
  201. #define PKEY_KBLOB2PROTK _IOWR(PKEY_IOCTL_MAGIC, 0x0A, struct pkey_kblob2pkey)
  202. /*
  203. * Generate secure key, version 2.
  204. * Generate CCA AES secure key, CCA AES cipher key or EP11 AES secure key.
  205. * There needs to be a list of apqns given with at least one entry in there.
  206. * All apqns in the list need to be exact apqns, 0xFFFF as ANY card or domain
  207. * is not supported. The implementation walks through the list of apqns and
  208. * tries to send the request to each apqn without any further checking (like
  209. * card type or online state). If the apqn fails, simple the next one in the
  210. * list is tried until success (return 0) or the end of the list is reached
  211. * (return -1 with errno ENODEV). You may use the PKEY_APQNS4KT ioctl to
  212. * generate a list of apqns based on the key type to generate.
  213. * The keygenflags argument is passed to the low level generation functions
  214. * individual for the key type and has a key type specific meaning. When
  215. * generating CCA cipher keys you can use one or more of the PKEY_KEYGEN_*
  216. * flags to widen the export possibilities. By default a cipher key is
  217. * only exportable for CPACF (PKEY_KEYGEN_XPRT_CPAC).
  218. * The keygenflag argument for generating an EP11 AES key should either be 0
  219. * to use the defaults which are XCP_BLOB_ENCRYPT, XCP_BLOB_DECRYPT and
  220. * XCP_BLOB_PROTKEY_EXTRACTABLE or a valid combination of XCP_BLOB_* flags.
  221. */
  222. struct pkey_genseck2 {
  223. struct pkey_apqn __user *apqns; /* in: ptr to list of apqn targets*/
  224. __u32 apqn_entries; /* in: # of apqn target list entries */
  225. enum pkey_key_type type; /* in: key type to generate */
  226. enum pkey_key_size size; /* in: key size to generate */
  227. __u32 keygenflags; /* in: key generation flags */
  228. __u8 __user *key; /* in: pointer to key blob buffer */
  229. __u32 keylen; /* in: available key blob buffer size */
  230. /* out: actual key blob size */
  231. };
  232. #define PKEY_GENSECK2 _IOWR(PKEY_IOCTL_MAGIC, 0x11, struct pkey_genseck2)
  233. /*
  234. * Generate secure key from clear key value, version 2.
  235. * Construct an CCA AES secure key, CCA AES cipher key or EP11 AES secure
  236. * key from a given clear key value.
  237. * There needs to be a list of apqns given with at least one entry in there.
  238. * All apqns in the list need to be exact apqns, 0xFFFF as ANY card or domain
  239. * is not supported. The implementation walks through the list of apqns and
  240. * tries to send the request to each apqn without any further checking (like
  241. * card type or online state). If the apqn fails, simple the next one in the
  242. * list is tried until success (return 0) or the end of the list is reached
  243. * (return -1 with errno ENODEV). You may use the PKEY_APQNS4KT ioctl to
  244. * generate a list of apqns based on the key type to generate.
  245. * The keygenflags argument is passed to the low level generation functions
  246. * individual for the key type and has a key type specific meaning. When
  247. * generating CCA cipher keys you can use one or more of the PKEY_KEYGEN_*
  248. * flags to widen the export possibilities. By default a cipher key is
  249. * only exportable for CPACF (PKEY_KEYGEN_XPRT_CPAC).
  250. * The keygenflag argument for generating an EP11 AES key should either be 0
  251. * to use the defaults which are XCP_BLOB_ENCRYPT, XCP_BLOB_DECRYPT and
  252. * XCP_BLOB_PROTKEY_EXTRACTABLE or a valid combination of XCP_BLOB_* flags.
  253. */
  254. struct pkey_clr2seck2 {
  255. struct pkey_apqn __user *apqns; /* in: ptr to list of apqn targets */
  256. __u32 apqn_entries; /* in: # of apqn target list entries */
  257. enum pkey_key_type type; /* in: key type to generate */
  258. enum pkey_key_size size; /* in: key size to generate */
  259. __u32 keygenflags; /* in: key generation flags */
  260. struct pkey_clrkey clrkey; /* in: the clear key value */
  261. __u8 __user *key; /* in: pointer to key blob buffer */
  262. __u32 keylen; /* in: available key blob buffer size */
  263. /* out: actual key blob size */
  264. };
  265. #define PKEY_CLR2SECK2 _IOWR(PKEY_IOCTL_MAGIC, 0x12, struct pkey_clr2seck2)
  266. /*
  267. * Verify the given secure key, version 2.
  268. * Check for correct key type. If cardnr and domain are given (are not
  269. * 0xFFFF) also check if this apqn is able to handle this type of key.
  270. * If cardnr and/or domain is 0xFFFF, on return these values are filled
  271. * with one apqn able to handle this key.
  272. * The function also checks for the master key verification patterns
  273. * of the key matching to the current or alternate mkvp of the apqn.
  274. * For CCA AES secure keys and CCA AES cipher keys this means to check
  275. * the key's mkvp against the current or old mkvp of the apqns. The flags
  276. * field is updated with some additional info about the apqn mkvp
  277. * match: If the current mkvp matches to the key's mkvp then the
  278. * PKEY_FLAGS_MATCH_CUR_MKVP bit is set, if the alternate mkvp matches to
  279. * the key's mkvp the PKEY_FLAGS_MATCH_ALT_MKVP is set. For CCA keys the
  280. * alternate mkvp is the old master key verification pattern.
  281. * CCA AES secure keys are also checked to have the CPACF export allowed
  282. * bit enabled (XPRTCPAC) in the kmf1 field.
  283. * EP11 keys are also supported and the wkvp of the key is checked against
  284. * the current wkvp of the apqns. There is no alternate for this type of
  285. * key and so on a match the flag PKEY_FLAGS_MATCH_CUR_MKVP always is set.
  286. * EP11 keys are also checked to have XCP_BLOB_PROTKEY_EXTRACTABLE set.
  287. * The ioctl returns 0 as long as the given or found apqn matches to
  288. * matches with the current or alternate mkvp to the key's mkvp. If the given
  289. * apqn does not match or there is no such apqn found, -1 with errno
  290. * ENODEV is returned.
  291. */
  292. struct pkey_verifykey2 {
  293. __u8 __user *key; /* in: pointer to key blob */
  294. __u32 keylen; /* in: key blob size */
  295. __u16 cardnr; /* in/out: card number */
  296. __u16 domain; /* in/out: domain number */
  297. enum pkey_key_type type; /* out: the key type */
  298. enum pkey_key_size size; /* out: the key size */
  299. __u32 flags; /* out: additional key info flags */
  300. };
  301. #define PKEY_VERIFYKEY2 _IOWR(PKEY_IOCTL_MAGIC, 0x17, struct pkey_verifykey2)
  302. /*
  303. * Transform a key blob into a protected key, version 2.
  304. * There needs to be a list of apqns given with at least one entry in there.
  305. * All apqns in the list need to be exact apqns, 0xFFFF as ANY card or domain
  306. * is not supported. The implementation walks through the list of apqns and
  307. * tries to send the request to each apqn without any further checking (like
  308. * card type or online state). If the apqn fails, simple the next one in the
  309. * list is tried until success (return 0) or the end of the list is reached
  310. * (return -1 with errno ENODEV). You may use the PKEY_APQNS4K ioctl to
  311. * generate a list of apqns based on the key.
  312. * Deriving ECC protected keys from ECC secure keys is not supported with
  313. * this ioctl, use PKEY_KBLOB2PROTK3 for this purpose.
  314. */
  315. struct pkey_kblob2pkey2 {
  316. __u8 __user *key; /* in: pointer to key blob */
  317. __u32 keylen; /* in: key blob size */
  318. struct pkey_apqn __user *apqns; /* in: ptr to list of apqn targets */
  319. __u32 apqn_entries; /* in: # of apqn target list entries */
  320. struct pkey_protkey protkey; /* out: the protected key */
  321. };
  322. #define PKEY_KBLOB2PROTK2 _IOWR(PKEY_IOCTL_MAGIC, 0x1A, struct pkey_kblob2pkey2)
  323. /*
  324. * Build a list of APQNs based on a key blob given.
  325. * Is able to find out which type of secure key is given (CCA AES secure
  326. * key, CCA AES cipher key, CCA ECC private key, EP11 AES key, EP11 ECC private
  327. * key) and tries to find all matching crypto cards based on the MKVP and maybe
  328. * other criteria (like CCA AES cipher keys need a CEX5C or higher, EP11 keys
  329. * with BLOB_PKEY_EXTRACTABLE need a CEX7 and EP11 api version 4). The list of
  330. * APQNs is further filtered by the key's mkvp which needs to match to either
  331. * the current mkvp (CCA and EP11) or the alternate mkvp (old mkvp, CCA adapters
  332. * only) of the apqns. The flags argument may be used to limit the matching
  333. * apqns. If the PKEY_FLAGS_MATCH_CUR_MKVP is given, only the current mkvp of
  334. * each apqn is compared. Likewise with the PKEY_FLAGS_MATCH_ALT_MKVP. If both
  335. * are given, it is assumed to return apqns where either the current or the
  336. * alternate mkvp matches. At least one of the matching flags needs to be given.
  337. * The flags argument for EP11 keys has no further action and is currently
  338. * ignored (but needs to be given as PKEY_FLAGS_MATCH_CUR_MKVP) as there is only
  339. * the wkvp from the key to match against the apqn's wkvp.
  340. * The list of matching apqns is stored into the space given by the apqns
  341. * argument and the number of stored entries goes into apqn_entries. If the list
  342. * is empty (apqn_entries is 0) the apqn_entries field is updated to the number
  343. * of apqn targets found and the ioctl returns with 0. If apqn_entries is > 0
  344. * but the number of apqn targets does not fit into the list, the apqn_targets
  345. * field is updated with the number of required entries but there are no apqn
  346. * values stored in the list and the ioctl returns with ENOSPC. If no matching
  347. * APQN is found, the ioctl returns with 0 but the apqn_entries value is 0.
  348. */
  349. struct pkey_apqns4key {
  350. __u8 __user *key; /* in: pointer to key blob */
  351. __u32 keylen; /* in: key blob size */
  352. __u32 flags; /* in: match controlling flags */
  353. struct pkey_apqn __user *apqns; /* in/out: ptr to list of apqn targets*/
  354. __u32 apqn_entries; /* in: max # of apqn entries in the list */
  355. /* out: # apqns stored into the list */
  356. };
  357. #define PKEY_APQNS4K _IOWR(PKEY_IOCTL_MAGIC, 0x1B, struct pkey_apqns4key)
  358. /*
  359. * Build a list of APQNs based on a key type given.
  360. * Build a list of APQNs based on a given key type and maybe further
  361. * restrict the list by given master key verification patterns.
  362. * For different key types there may be different ways to match the
  363. * master key verification patterns. For CCA keys (CCA data key and CCA
  364. * cipher key) the first 8 bytes of cur_mkvp refer to the current AES mkvp value
  365. * of the apqn and the first 8 bytes of the alt_mkvp refer to the old AES mkvp.
  366. * For CCA ECC keys it is similar but the match is against the APKA current/old
  367. * mkvp. The flags argument controls if the apqns current and/or alternate mkvp
  368. * should match. If the PKEY_FLAGS_MATCH_CUR_MKVP is given, only the current
  369. * mkvp of each apqn is compared. Likewise with the PKEY_FLAGS_MATCH_ALT_MKVP.
  370. * If both are given, it is assumed to return apqns where either the
  371. * current or the alternate mkvp matches. If no match flag is given
  372. * (flags is 0) the mkvp values are ignored for the match process.
  373. * For EP11 keys there is only the current wkvp. So if the apqns should also
  374. * match to a given wkvp, then the PKEY_FLAGS_MATCH_CUR_MKVP flag should be
  375. * set. The wkvp value is 32 bytes but only the leftmost 16 bytes are compared
  376. * against the leftmost 16 byte of the wkvp of the apqn.
  377. * The list of matching apqns is stored into the space given by the apqns
  378. * argument and the number of stored entries goes into apqn_entries. If the list
  379. * is empty (apqn_entries is 0) the apqn_entries field is updated to the number
  380. * of apqn targets found and the ioctl returns with 0. If apqn_entries is > 0
  381. * but the number of apqn targets does not fit into the list, the apqn_targets
  382. * field is updated with the number of required entries but there are no apqn
  383. * values stored in the list and the ioctl returns with ENOSPC. If no matching
  384. * APQN is found, the ioctl returns with 0 but the apqn_entries value is 0.
  385. */
  386. struct pkey_apqns4keytype {
  387. enum pkey_key_type type; /* in: key type */
  388. __u8 cur_mkvp[32]; /* in: current mkvp */
  389. __u8 alt_mkvp[32]; /* in: alternate mkvp */
  390. __u32 flags; /* in: match controlling flags */
  391. struct pkey_apqn __user *apqns; /* in/out: ptr to list of apqn targets*/
  392. __u32 apqn_entries; /* in: max # of apqn entries in the list */
  393. /* out: # apqns stored into the list */
  394. };
  395. #define PKEY_APQNS4KT _IOWR(PKEY_IOCTL_MAGIC, 0x1C, struct pkey_apqns4keytype)
  396. /*
  397. * Transform a key blob into a protected key, version 3.
  398. * The difference to version 2 of this ioctl is that the protected key
  399. * buffer is now explicitly and not within a struct pkey_protkey any more.
  400. * So this ioctl is also able to handle EP11 and CCA ECC secure keys and
  401. * provide ECC protected keys.
  402. * There needs to be a list of apqns given with at least one entry in there.
  403. * All apqns in the list need to be exact apqns, 0xFFFF as ANY card or domain
  404. * is not supported. The implementation walks through the list of apqns and
  405. * tries to send the request to each apqn without any further checking (like
  406. * card type or online state). If the apqn fails, simple the next one in the
  407. * list is tried until success (return 0) or the end of the list is reached
  408. * (return -1 with errno ENODEV). You may use the PKEY_APQNS4K ioctl to
  409. * generate a list of apqns based on the key.
  410. */
  411. struct pkey_kblob2pkey3 {
  412. __u8 __user *key; /* in: pointer to key blob */
  413. __u32 keylen; /* in: key blob size */
  414. struct pkey_apqn __user *apqns; /* in: ptr to list of apqn targets */
  415. __u32 apqn_entries; /* in: # of apqn target list entries */
  416. __u32 pkeytype; /* out: prot key type (enum pkey_key_type) */
  417. __u32 pkeylen; /* in/out: size of pkey buffer/actual len of pkey */
  418. __u8 __user *pkey; /* in: pkey blob buffer space ptr */
  419. };
  420. #define PKEY_KBLOB2PROTK3 _IOWR(PKEY_IOCTL_MAGIC, 0x1D, struct pkey_kblob2pkey3)
  421. #endif /* _UAPI_PKEY_H */