zcrypt_cex2a.h 4.1 KB

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