zcrypt_cex2a.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * zcrypt 2.1.0
  3. *
  4. * Copyright IBM Corp. 2001, 2006
  5. * Author(s): Robert Burroughs
  6. * Eric Rossman (edrossma@us.ibm.com)
  7. *
  8. * Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
  9. * Major cleanup & driver split: Martin Schwidefsky <schwidefsky@de.ibm.com>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2, or (at your option)
  14. * any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. */
  25. #ifndef _ZCRYPT_CEX2A_H_
  26. #define _ZCRYPT_CEX2A_H_
  27. /**
  28. * The type 50 message family is associated with a CEX2A card.
  29. *
  30. * The four members of the family are described below.
  31. *
  32. * Note that all unsigned char arrays are right-justified and left-padded
  33. * with zeroes.
  34. *
  35. * Note that all reserved fields must be zeroes.
  36. */
  37. struct type50_hdr {
  38. unsigned char reserved1;
  39. unsigned char msg_type_code; /* 0x50 */
  40. unsigned short msg_len;
  41. unsigned char reserved2;
  42. unsigned char ignored;
  43. unsigned short reserved3;
  44. } __attribute__((packed));
  45. #define TYPE50_TYPE_CODE 0x50
  46. #define TYPE50_MEB1_FMT 0x0001
  47. #define TYPE50_MEB2_FMT 0x0002
  48. #define TYPE50_MEB3_FMT 0x0003
  49. #define TYPE50_CRB1_FMT 0x0011
  50. #define TYPE50_CRB2_FMT 0x0012
  51. #define TYPE50_CRB3_FMT 0x0013
  52. /* Mod-Exp, with a small modulus */
  53. struct type50_meb1_msg {
  54. struct type50_hdr header;
  55. unsigned short keyblock_type; /* 0x0001 */
  56. unsigned char reserved[6];
  57. unsigned char exponent[128];
  58. unsigned char modulus[128];
  59. unsigned char message[128];
  60. } __attribute__((packed));
  61. /* Mod-Exp, with a large modulus */
  62. struct type50_meb2_msg {
  63. struct type50_hdr header;
  64. unsigned short keyblock_type; /* 0x0002 */
  65. unsigned char reserved[6];
  66. unsigned char exponent[256];
  67. unsigned char modulus[256];
  68. unsigned char message[256];
  69. } __attribute__((packed));
  70. /* Mod-Exp, with a larger modulus */
  71. struct type50_meb3_msg {
  72. struct type50_hdr header;
  73. unsigned short keyblock_type; /* 0x0003 */
  74. unsigned char reserved[6];
  75. unsigned char exponent[512];
  76. unsigned char modulus[512];
  77. unsigned char message[512];
  78. } __attribute__((packed));
  79. /* CRT, with a small modulus */
  80. struct type50_crb1_msg {
  81. struct type50_hdr header;
  82. unsigned short keyblock_type; /* 0x0011 */
  83. unsigned char reserved[6];
  84. unsigned char p[64];
  85. unsigned char q[64];
  86. unsigned char dp[64];
  87. unsigned char dq[64];
  88. unsigned char u[64];
  89. unsigned char message[128];
  90. } __attribute__((packed));
  91. /* CRT, with a large modulus */
  92. struct type50_crb2_msg {
  93. struct type50_hdr header;
  94. unsigned short keyblock_type; /* 0x0012 */
  95. unsigned char reserved[6];
  96. unsigned char p[128];
  97. unsigned char q[128];
  98. unsigned char dp[128];
  99. unsigned char dq[128];
  100. unsigned char u[128];
  101. unsigned char message[256];
  102. } __attribute__((packed));
  103. /* CRT, with a larger modulus */
  104. struct type50_crb3_msg {
  105. struct type50_hdr header;
  106. unsigned short keyblock_type; /* 0x0013 */
  107. unsigned char reserved[6];
  108. unsigned char p[256];
  109. unsigned char q[256];
  110. unsigned char dp[256];
  111. unsigned char dq[256];
  112. unsigned char u[256];
  113. unsigned char message[512];
  114. } __attribute__((packed));
  115. /**
  116. * The type 80 response family is associated with a CEX2A card.
  117. *
  118. * Note that all unsigned char arrays are right-justified and left-padded
  119. * with zeroes.
  120. *
  121. * Note that all reserved fields must be zeroes.
  122. */
  123. #define TYPE80_RSP_CODE 0x80
  124. struct type80_hdr {
  125. unsigned char reserved1;
  126. unsigned char type; /* 0x80 */
  127. unsigned short len;
  128. unsigned char code; /* 0x00 */
  129. unsigned char reserved2[3];
  130. unsigned char reserved3[8];
  131. } __attribute__((packed));
  132. int zcrypt_cex2a_init(void);
  133. void zcrypt_cex2a_exit(void);
  134. #endif /* _ZCRYPT_CEX2A_H_ */