1 /*
2  *  linux/drivers/s390/crypto/zcrypt_pcica.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 
28 #ifndef _ZCRYPT_PCICA_H_
29 #define _ZCRYPT_PCICA_H_
30 
31 /**
32  * The type 4 message family is associated with a PCICA card.
33  *
34  * The four members of the family are described below.
35  *
36  * Note that all unsigned char arrays are right-justified and left-padded
37  * with zeroes.
38  *
39  * Note that all reserved fields must be zeroes.
40  */
41 struct type4_hdr {
42 	unsigned char  reserved1;
43 	unsigned char  msg_type_code;	/* 0x04 */
44 	unsigned short msg_len;
45 	unsigned char  request_code;	/* 0x40 */
46 	unsigned char  msg_fmt;
47 	unsigned short reserved2;
48 } __attribute__((packed));
49 
50 #define TYPE4_TYPE_CODE 0x04
51 #define TYPE4_REQU_CODE 0x40
52 
53 #define TYPE4_SME_FMT 0x00
54 #define TYPE4_LME_FMT 0x10
55 #define TYPE4_SCR_FMT 0x40
56 #define TYPE4_LCR_FMT 0x50
57 
58 /* Mod-Exp, with a small modulus */
59 struct type4_sme {
60 	struct type4_hdr header;
61 	unsigned char	 message[128];
62 	unsigned char	 exponent[128];
63 	unsigned char	 modulus[128];
64 } __attribute__((packed));
65 
66 /* Mod-Exp, with a large modulus */
67 struct type4_lme {
68 	struct type4_hdr header;
69 	unsigned char	 message[256];
70 	unsigned char	 exponent[256];
71 	unsigned char	 modulus[256];
72 } __attribute__((packed));
73 
74 /* CRT, with a small modulus */
75 struct type4_scr {
76 	struct type4_hdr header;
77 	unsigned char	 message[128];
78 	unsigned char	 dp[72];
79 	unsigned char	 dq[64];
80 	unsigned char	 p[72];
81 	unsigned char	 q[64];
82 	unsigned char	 u[72];
83 } __attribute__((packed));
84 
85 /* CRT, with a large modulus */
86 struct type4_lcr {
87 	struct type4_hdr header;
88 	unsigned char	 message[256];
89 	unsigned char	 dp[136];
90 	unsigned char	 dq[128];
91 	unsigned char	 p[136];
92 	unsigned char	 q[128];
93 	unsigned char	 u[136];
94 } __attribute__((packed));
95 
96 /**
97  * The type 84 response family is associated with a PCICA card.
98  *
99  * Note that all unsigned char arrays are right-justified and left-padded
100  * with zeroes.
101  *
102  * Note that all reserved fields must be zeroes.
103  */
104 
105 struct type84_hdr {
106 	unsigned char  reserved1;
107 	unsigned char  code;
108 	unsigned short len;
109 	unsigned char  reserved2[4];
110 } __attribute__((packed));
111 
112 #define TYPE84_RSP_CODE 0x84
113 
114 int zcrypt_pcica_init(void);
115 void zcrypt_pcica_exit(void);
116 
117 #endif /* _ZCRYPT_PCICA_H_ */
118