zcrypt.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /*
  2. * include/asm-s390/zcrypt.h
  3. *
  4. * zcrypt 2.1.0 (user-visible header)
  5. *
  6. * Copyright (C) 2001, 2006 IBM Corporation
  7. * Author(s): Robert Burroughs
  8. * Eric Rossman (edrossma@us.ibm.com)
  9. *
  10. * Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2, or (at your option)
  15. * any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25. */
  26. #ifndef __ASM_S390_ZCRYPT_H
  27. #define __ASM_S390_ZCRYPT_H
  28. #define ZCRYPT_VERSION 2
  29. #define ZCRYPT_RELEASE 1
  30. #define ZCRYPT_VARIANT 1
  31. #include <linux/ioctl.h>
  32. #include <linux/compiler.h>
  33. /**
  34. * struct ica_rsa_modexpo
  35. *
  36. * Requirements:
  37. * - outputdatalength is at least as large as inputdatalength.
  38. * - All key parts are right justified in their fields, padded on
  39. * the left with zeroes.
  40. * - length(b_key) = inputdatalength
  41. * - length(n_modulus) = inputdatalength
  42. */
  43. struct ica_rsa_modexpo {
  44. char __user * inputdata;
  45. unsigned int inputdatalength;
  46. char __user * outputdata;
  47. unsigned int outputdatalength;
  48. char __user * b_key;
  49. char __user * n_modulus;
  50. };
  51. /**
  52. * struct ica_rsa_modexpo_crt
  53. *
  54. * Requirements:
  55. * - inputdatalength is even.
  56. * - outputdatalength is at least as large as inputdatalength.
  57. * - All key parts are right justified in their fields, padded on
  58. * the left with zeroes.
  59. * - length(bp_key) = inputdatalength/2 + 8
  60. * - length(bq_key) = inputdatalength/2
  61. * - length(np_key) = inputdatalength/2 + 8
  62. * - length(nq_key) = inputdatalength/2
  63. * - length(u_mult_inv) = inputdatalength/2 + 8
  64. */
  65. struct ica_rsa_modexpo_crt {
  66. char __user * inputdata;
  67. unsigned int inputdatalength;
  68. char __user * outputdata;
  69. unsigned int outputdatalength;
  70. char __user * bp_key;
  71. char __user * bq_key;
  72. char __user * np_prime;
  73. char __user * nq_prime;
  74. char __user * u_mult_inv;
  75. };
  76. /**
  77. * CPRBX
  78. * Note that all shorts and ints are big-endian.
  79. * All pointer fields are 16 bytes long, and mean nothing.
  80. *
  81. * A request CPRB is followed by a request_parameter_block.
  82. *
  83. * The request (or reply) parameter block is organized thus:
  84. * function code
  85. * VUD block
  86. * key block
  87. */
  88. struct CPRBX {
  89. unsigned short cprb_len; /* CPRB length 220 */
  90. unsigned char cprb_ver_id; /* CPRB version id. 0x02 */
  91. unsigned char pad_000[3]; /* Alignment pad bytes */
  92. unsigned char func_id[2]; /* function id 0x5432 */
  93. unsigned char cprb_flags[4]; /* Flags */
  94. unsigned int req_parml; /* request parameter buffer len */
  95. unsigned int req_datal; /* request data buffer */
  96. unsigned int rpl_msgbl; /* reply message block length */
  97. unsigned int rpld_parml; /* replied parameter block len */
  98. unsigned int rpl_datal; /* reply data block len */
  99. unsigned int rpld_datal; /* replied data block len */
  100. unsigned int req_extbl; /* request extension block len */
  101. unsigned char pad_001[4]; /* reserved */
  102. unsigned int rpld_extbl; /* replied extension block len */
  103. unsigned char padx000[16 - sizeof (char *)];
  104. unsigned char * req_parmb; /* request parm block 'address' */
  105. unsigned char padx001[16 - sizeof (char *)];
  106. unsigned char * req_datab; /* request data block 'address' */
  107. unsigned char padx002[16 - sizeof (char *)];
  108. unsigned char * rpl_parmb; /* reply parm block 'address' */
  109. unsigned char padx003[16 - sizeof (char *)];
  110. unsigned char * rpl_datab; /* reply data block 'address' */
  111. unsigned char padx004[16 - sizeof (char *)];
  112. unsigned char * req_extb; /* request extension block 'addr'*/
  113. unsigned char padx005[16 - sizeof (char *)];
  114. unsigned char * rpl_extb; /* reply extension block 'address'*/
  115. unsigned short ccp_rtcode; /* server return code */
  116. unsigned short ccp_rscode; /* server reason code */
  117. unsigned int mac_data_len; /* Mac Data Length */
  118. unsigned char logon_id[8]; /* Logon Identifier */
  119. unsigned char mac_value[8]; /* Mac Value */
  120. unsigned char mac_content_flgs;/* Mac content flag byte */
  121. unsigned char pad_002; /* Alignment */
  122. unsigned short domain; /* Domain */
  123. unsigned char usage_domain[4];/* Usage domain */
  124. unsigned char cntrl_domain[4];/* Control domain */
  125. unsigned char S390enf_mask[4];/* S/390 enforcement mask */
  126. unsigned char pad_004[36]; /* reserved */
  127. } __attribute__((packed));
  128. /**
  129. * xcRB
  130. */
  131. struct ica_xcRB {
  132. unsigned short agent_ID;
  133. unsigned int user_defined;
  134. unsigned short request_ID;
  135. unsigned int request_control_blk_length;
  136. unsigned char padding1[16 - sizeof (char *)];
  137. char __user * request_control_blk_addr;
  138. unsigned int request_data_length;
  139. char padding2[16 - sizeof (char *)];
  140. char __user * request_data_address;
  141. unsigned int reply_control_blk_length;
  142. char padding3[16 - sizeof (char *)];
  143. char __user * reply_control_blk_addr;
  144. unsigned int reply_data_length;
  145. char padding4[16 - sizeof (char *)];
  146. char __user * reply_data_addr;
  147. unsigned short priority_window;
  148. unsigned int status;
  149. } __attribute__((packed));
  150. #define AUTOSELECT ((unsigned int)0xFFFFFFFF)
  151. #define ZCRYPT_IOCTL_MAGIC 'z'
  152. /**
  153. * Interface notes:
  154. *
  155. * The ioctl()s which are implemented (along with relevant details)
  156. * are:
  157. *
  158. * ICARSAMODEXPO
  159. * Perform an RSA operation using a Modulus-Exponent pair
  160. * This takes an ica_rsa_modexpo struct as its arg.
  161. *
  162. * NOTE: please refer to the comments preceding this structure
  163. * for the implementation details for the contents of the
  164. * block
  165. *
  166. * ICARSACRT
  167. * Perform an RSA operation using a Chinese-Remainder Theorem key
  168. * This takes an ica_rsa_modexpo_crt struct as its arg.
  169. *
  170. * NOTE: please refer to the comments preceding this structure
  171. * for the implementation details for the contents of the
  172. * block
  173. *
  174. * ZSECSENDCPRB
  175. * Send an arbitrary CPRB to a crypto card.
  176. *
  177. * Z90STAT_STATUS_MASK
  178. * Return an 64 element array of unsigned chars for the status of
  179. * all devices.
  180. * 0x01: PCICA
  181. * 0x02: PCICC
  182. * 0x03: PCIXCC_MCL2
  183. * 0x04: PCIXCC_MCL3
  184. * 0x05: CEX2C
  185. * 0x06: CEX2A
  186. * 0x0d: device is disabled via the proc filesystem
  187. *
  188. * Z90STAT_QDEPTH_MASK
  189. * Return an 64 element array of unsigned chars for the queue
  190. * depth of all devices.
  191. *
  192. * Z90STAT_PERDEV_REQCNT
  193. * Return an 64 element array of unsigned integers for the number
  194. * of successfully completed requests per device since the device
  195. * was detected and made available.
  196. *
  197. * Z90STAT_REQUESTQ_COUNT
  198. * Return an integer count of the number of entries waiting to be
  199. * sent to a device.
  200. *
  201. * Z90STAT_PENDINGQ_COUNT
  202. * Return an integer count of the number of entries sent to all
  203. * devices awaiting the reply.
  204. *
  205. * Z90STAT_TOTALOPEN_COUNT
  206. * Return an integer count of the number of open file handles.
  207. *
  208. * Z90STAT_DOMAIN_INDEX
  209. * Return the integer value of the Cryptographic Domain.
  210. *
  211. * The following ioctls are deprecated and should be no longer used:
  212. *
  213. * Z90STAT_TOTALCOUNT
  214. * Return an integer count of all device types together.
  215. *
  216. * Z90STAT_PCICACOUNT
  217. * Return an integer count of all PCICAs.
  218. *
  219. * Z90STAT_PCICCCOUNT
  220. * Return an integer count of all PCICCs.
  221. *
  222. * Z90STAT_PCIXCCMCL2COUNT
  223. * Return an integer count of all MCL2 PCIXCCs.
  224. *
  225. * Z90STAT_PCIXCCMCL3COUNT
  226. * Return an integer count of all MCL3 PCIXCCs.
  227. *
  228. * Z90STAT_CEX2CCOUNT
  229. * Return an integer count of all CEX2Cs.
  230. *
  231. * Z90STAT_CEX2ACOUNT
  232. * Return an integer count of all CEX2As.
  233. *
  234. * ICAZ90STATUS
  235. * Return some device driver status in a ica_z90_status struct
  236. * This takes an ica_z90_status struct as its arg.
  237. *
  238. * Z90STAT_PCIXCCCOUNT
  239. * Return an integer count of all PCIXCCs (MCL2 + MCL3).
  240. * This is DEPRECATED now that MCL3 PCIXCCs are treated differently from
  241. * MCL2 PCIXCCs.
  242. */
  243. /**
  244. * Supported ioctl calls
  245. */
  246. #define ICARSAMODEXPO _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x05, 0)
  247. #define ICARSACRT _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x06, 0)
  248. #define ZSECSENDCPRB _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x81, 0)
  249. /* New status calls */
  250. #define Z90STAT_TOTALCOUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x40, int)
  251. #define Z90STAT_PCICACOUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x41, int)
  252. #define Z90STAT_PCICCCOUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x42, int)
  253. #define Z90STAT_PCIXCCMCL2COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x4b, int)
  254. #define Z90STAT_PCIXCCMCL3COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x4c, int)
  255. #define Z90STAT_CEX2CCOUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x4d, int)
  256. #define Z90STAT_CEX2ACOUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x4e, int)
  257. #define Z90STAT_REQUESTQ_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x44, int)
  258. #define Z90STAT_PENDINGQ_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x45, int)
  259. #define Z90STAT_TOTALOPEN_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x46, int)
  260. #define Z90STAT_DOMAIN_INDEX _IOR(ZCRYPT_IOCTL_MAGIC, 0x47, int)
  261. #define Z90STAT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x48, char[64])
  262. #define Z90STAT_QDEPTH_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x49, char[64])
  263. #define Z90STAT_PERDEV_REQCNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x4a, int[64])
  264. #endif /* __ASM_S390_ZCRYPT_H */