pkey.h 20 KB

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