Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[pandora-kernel.git] / drivers / s390 / crypto / zcrypt_cex2a.h
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
28 #ifndef _ZCRYPT_CEX2A_H_
29 #define _ZCRYPT_CEX2A_H_
30
31 /**
32  * The type 50 message family is associated with a CEX2A 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 type50_hdr {
42         unsigned char   reserved1;
43         unsigned char   msg_type_code;  /* 0x50 */
44         unsigned short  msg_len;
45         unsigned char   reserved2;
46         unsigned char   ignored;
47         unsigned short  reserved3;
48 } __attribute__((packed));
49
50 #define TYPE50_TYPE_CODE        0x50
51
52 #define TYPE50_MEB1_FMT         0x0001
53 #define TYPE50_MEB2_FMT         0x0002
54 #define TYPE50_MEB3_FMT         0x0003
55 #define TYPE50_CRB1_FMT         0x0011
56 #define TYPE50_CRB2_FMT         0x0012
57 #define TYPE50_CRB3_FMT         0x0013
58
59 /* Mod-Exp, with a small modulus */
60 struct type50_meb1_msg {
61         struct type50_hdr header;
62         unsigned short  keyblock_type;  /* 0x0001 */
63         unsigned char   reserved[6];
64         unsigned char   exponent[128];
65         unsigned char   modulus[128];
66         unsigned char   message[128];
67 } __attribute__((packed));
68
69 /* Mod-Exp, with a large modulus */
70 struct type50_meb2_msg {
71         struct type50_hdr header;
72         unsigned short  keyblock_type;  /* 0x0002 */
73         unsigned char   reserved[6];
74         unsigned char   exponent[256];
75         unsigned char   modulus[256];
76         unsigned char   message[256];
77 } __attribute__((packed));
78
79 /* Mod-Exp, with a larger modulus */
80 struct type50_meb3_msg {
81         struct type50_hdr header;
82         unsigned short  keyblock_type;  /* 0x0003 */
83         unsigned char   reserved[6];
84         unsigned char   exponent[512];
85         unsigned char   modulus[512];
86         unsigned char   message[512];
87 } __attribute__((packed));
88
89 /* CRT, with a small modulus */
90 struct type50_crb1_msg {
91         struct type50_hdr header;
92         unsigned short  keyblock_type;  /* 0x0011 */
93         unsigned char   reserved[6];
94         unsigned char   p[64];
95         unsigned char   q[64];
96         unsigned char   dp[64];
97         unsigned char   dq[64];
98         unsigned char   u[64];
99         unsigned char   message[128];
100 } __attribute__((packed));
101
102 /* CRT, with a large modulus */
103 struct type50_crb2_msg {
104         struct type50_hdr header;
105         unsigned short  keyblock_type;  /* 0x0012 */
106         unsigned char   reserved[6];
107         unsigned char   p[128];
108         unsigned char   q[128];
109         unsigned char   dp[128];
110         unsigned char   dq[128];
111         unsigned char   u[128];
112         unsigned char   message[256];
113 } __attribute__((packed));
114
115 /* CRT, with a larger modulus */
116 struct type50_crb3_msg {
117         struct type50_hdr header;
118         unsigned short  keyblock_type;  /* 0x0013 */
119         unsigned char   reserved[6];
120         unsigned char   p[256];
121         unsigned char   q[256];
122         unsigned char   dp[256];
123         unsigned char   dq[256];
124         unsigned char   u[256];
125         unsigned char   message[512];
126 } __attribute__((packed));
127
128 /**
129  * The type 80 response family is associated with a CEX2A card.
130  *
131  * Note that all unsigned char arrays are right-justified and left-padded
132  * with zeroes.
133  *
134  * Note that all reserved fields must be zeroes.
135  */
136
137 #define TYPE80_RSP_CODE 0x80
138
139 struct type80_hdr {
140         unsigned char   reserved1;
141         unsigned char   type;           /* 0x80 */
142         unsigned short  len;
143         unsigned char   code;           /* 0x00 */
144         unsigned char   reserved2[3];
145         unsigned char   reserved3[8];
146 } __attribute__((packed));
147
148 int zcrypt_cex2a_init(void);
149 void zcrypt_cex2a_exit(void);
150
151 #endif /* _ZCRYPT_CEX2A_H_ */