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 13 #ifndef _ZCRYPT_CEX2A_H_ 14 #define _ZCRYPT_CEX2A_H_ 15 16 /** 17 * The type 50 message family is associated with a CEX2A card. 18 * 19 * The four members of the family are described below. 20 * 21 * Note that all unsigned char arrays are right-justified and left-padded 22 * with zeroes. 23 * 24 * Note that all reserved fields must be zeroes. 25 */ 26 struct type50_hdr { 27 unsigned char reserved1; 28 unsigned char msg_type_code; /* 0x50 */ 29 unsigned short msg_len; 30 unsigned char reserved2; 31 unsigned char ignored; 32 unsigned short reserved3; 33 } __attribute__((packed)); 34 35 #define TYPE50_TYPE_CODE 0x50 36 37 #define TYPE50_MEB1_FMT 0x0001 38 #define TYPE50_MEB2_FMT 0x0002 39 #define TYPE50_MEB3_FMT 0x0003 40 #define TYPE50_CRB1_FMT 0x0011 41 #define TYPE50_CRB2_FMT 0x0012 42 #define TYPE50_CRB3_FMT 0x0013 43 44 /* Mod-Exp, with a small modulus */ 45 struct type50_meb1_msg { 46 struct type50_hdr header; 47 unsigned short keyblock_type; /* 0x0001 */ 48 unsigned char reserved[6]; 49 unsigned char exponent[128]; 50 unsigned char modulus[128]; 51 unsigned char message[128]; 52 } __attribute__((packed)); 53 54 /* Mod-Exp, with a large modulus */ 55 struct type50_meb2_msg { 56 struct type50_hdr header; 57 unsigned short keyblock_type; /* 0x0002 */ 58 unsigned char reserved[6]; 59 unsigned char exponent[256]; 60 unsigned char modulus[256]; 61 unsigned char message[256]; 62 } __attribute__((packed)); 63 64 /* Mod-Exp, with a larger modulus */ 65 struct type50_meb3_msg { 66 struct type50_hdr header; 67 unsigned short keyblock_type; /* 0x0003 */ 68 unsigned char reserved[6]; 69 unsigned char exponent[512]; 70 unsigned char modulus[512]; 71 unsigned char message[512]; 72 } __attribute__((packed)); 73 74 /* CRT, with a small modulus */ 75 struct type50_crb1_msg { 76 struct type50_hdr header; 77 unsigned short keyblock_type; /* 0x0011 */ 78 unsigned char reserved[6]; 79 unsigned char p[64]; 80 unsigned char q[64]; 81 unsigned char dp[64]; 82 unsigned char dq[64]; 83 unsigned char u[64]; 84 unsigned char message[128]; 85 } __attribute__((packed)); 86 87 /* CRT, with a large modulus */ 88 struct type50_crb2_msg { 89 struct type50_hdr header; 90 unsigned short keyblock_type; /* 0x0012 */ 91 unsigned char reserved[6]; 92 unsigned char p[128]; 93 unsigned char q[128]; 94 unsigned char dp[128]; 95 unsigned char dq[128]; 96 unsigned char u[128]; 97 unsigned char message[256]; 98 } __attribute__((packed)); 99 100 /* CRT, with a larger modulus */ 101 struct type50_crb3_msg { 102 struct type50_hdr header; 103 unsigned short keyblock_type; /* 0x0013 */ 104 unsigned char reserved[6]; 105 unsigned char p[256]; 106 unsigned char q[256]; 107 unsigned char dp[256]; 108 unsigned char dq[256]; 109 unsigned char u[256]; 110 unsigned char message[512]; 111 } __attribute__((packed)); 112 113 /** 114 * The type 80 response family is associated with a CEX2A card. 115 * 116 * Note that all unsigned char arrays are right-justified and left-padded 117 * with zeroes. 118 * 119 * Note that all reserved fields must be zeroes. 120 */ 121 122 #define TYPE80_RSP_CODE 0x80 123 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 133 int zcrypt_cex2a_init(void); 134 void zcrypt_cex2a_exit(void); 135 136 #endif /* _ZCRYPT_CEX2A_H_ */ 137