zcrypt_cex2a.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * zcrypt 2.1.0
  4. *
  5. * Copyright IBM Corp. 2001, 2006
  6. * Author(s): Robert Burroughs
  7. * Eric Rossman (edrossma@us.ibm.com)
  8. *
  9. * Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
  10. * Major cleanup & driver split: Martin Schwidefsky <schwidefsky@de.ibm.com>
  11. */
  12. #ifndef _ZCRYPT_CEX2A_H_
  13. #define _ZCRYPT_CEX2A_H_
  14. /**
  15. * The type 50 message family is associated with a CEX2A card.
  16. *
  17. * The four members of the family are described below.
  18. *
  19. * Note that all unsigned char arrays are right-justified and left-padded
  20. * with zeroes.
  21. *
  22. * Note that all reserved fields must be zeroes.
  23. */
  24. struct type50_hdr {
  25. unsigned char reserved1;
  26. unsigned char msg_type_code; /* 0x50 */
  27. unsigned short msg_len;
  28. unsigned char reserved2;
  29. unsigned char ignored;
  30. unsigned short reserved3;
  31. } __packed;
  32. #define TYPE50_TYPE_CODE 0x50
  33. #define TYPE50_MEB1_FMT 0x0001
  34. #define TYPE50_MEB2_FMT 0x0002
  35. #define TYPE50_MEB3_FMT 0x0003
  36. #define TYPE50_CRB1_FMT 0x0011
  37. #define TYPE50_CRB2_FMT 0x0012
  38. #define TYPE50_CRB3_FMT 0x0013
  39. /* Mod-Exp, with a small modulus */
  40. struct type50_meb1_msg {
  41. struct type50_hdr header;
  42. unsigned short keyblock_type; /* 0x0001 */
  43. unsigned char reserved[6];
  44. unsigned char exponent[128];
  45. unsigned char modulus[128];
  46. unsigned char message[128];
  47. } __packed;
  48. /* Mod-Exp, with a large modulus */
  49. struct type50_meb2_msg {
  50. struct type50_hdr header;
  51. unsigned short keyblock_type; /* 0x0002 */
  52. unsigned char reserved[6];
  53. unsigned char exponent[256];
  54. unsigned char modulus[256];
  55. unsigned char message[256];
  56. } __packed;
  57. /* Mod-Exp, with a larger modulus */
  58. struct type50_meb3_msg {
  59. struct type50_hdr header;
  60. unsigned short keyblock_type; /* 0x0003 */
  61. unsigned char reserved[6];
  62. unsigned char exponent[512];
  63. unsigned char modulus[512];
  64. unsigned char message[512];
  65. } __packed;
  66. /* CRT, with a small modulus */
  67. struct type50_crb1_msg {
  68. struct type50_hdr header;
  69. unsigned short keyblock_type; /* 0x0011 */
  70. unsigned char reserved[6];
  71. unsigned char p[64];
  72. unsigned char q[64];
  73. unsigned char dp[64];
  74. unsigned char dq[64];
  75. unsigned char u[64];
  76. unsigned char message[128];
  77. } __packed;
  78. /* CRT, with a large modulus */
  79. struct type50_crb2_msg {
  80. struct type50_hdr header;
  81. unsigned short keyblock_type; /* 0x0012 */
  82. unsigned char reserved[6];
  83. unsigned char p[128];
  84. unsigned char q[128];
  85. unsigned char dp[128];
  86. unsigned char dq[128];
  87. unsigned char u[128];
  88. unsigned char message[256];
  89. } __packed;
  90. /* CRT, with a larger modulus */
  91. struct type50_crb3_msg {
  92. struct type50_hdr header;
  93. unsigned short keyblock_type; /* 0x0013 */
  94. unsigned char reserved[6];
  95. unsigned char p[256];
  96. unsigned char q[256];
  97. unsigned char dp[256];
  98. unsigned char dq[256];
  99. unsigned char u[256];
  100. unsigned char message[512];
  101. } __packed;
  102. /**
  103. * The type 80 response family is associated with a CEX2A card.
  104. *
  105. * Note that all unsigned char arrays are right-justified and left-padded
  106. * with zeroes.
  107. *
  108. * Note that all reserved fields must be zeroes.
  109. */
  110. #define TYPE80_RSP_CODE 0x80
  111. struct type80_hdr {
  112. unsigned char reserved1;
  113. unsigned char type; /* 0x80 */
  114. unsigned short len;
  115. unsigned char code; /* 0x00 */
  116. unsigned char reserved2[3];
  117. unsigned char reserved3[8];
  118. } __packed;
  119. int zcrypt_cex2a_init(void);
  120. void zcrypt_cex2a_exit(void);
  121. #endif /* _ZCRYPT_CEX2A_H_ */