blob: 0350665810cf53032c9e172210887b5f480b73c2 [file] [log] [blame]
Martin Schwidefsky963ed932006-09-20 15:58:29 +02001/*
2 * linux/drivers/s390/crypto/zcrypt_cex2a.h
3 *
Ralph Wuerthner54321142006-09-20 15:58:36 +02004 * zcrypt 2.1.0
Martin Schwidefsky963ed932006-09-20 15:58:29 +02005 *
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 */
41struct 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
Felix Beck3e309a62011-01-05 12:47:45 +010054#define TYPE50_MEB3_FMT 0x0003
Martin Schwidefsky963ed932006-09-20 15:58:29 +020055#define TYPE50_CRB1_FMT 0x0011
56#define TYPE50_CRB2_FMT 0x0012
Felix Beck3e309a62011-01-05 12:47:45 +010057#define TYPE50_CRB3_FMT 0x0013
Martin Schwidefsky963ed932006-09-20 15:58:29 +020058
59/* Mod-Exp, with a small modulus */
60struct 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 */
70struct 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
Felix Beck3e309a62011-01-05 12:47:45 +010079/* Mod-Exp, with a larger modulus */
80struct 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
Martin Schwidefsky963ed932006-09-20 15:58:29 +020089/* CRT, with a small modulus */
90struct 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 */
103struct 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
Felix Beck3e309a62011-01-05 12:47:45 +0100115/* CRT, with a larger modulus */
116struct 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
Martin Schwidefsky963ed932006-09-20 15:58:29 +0200128/**
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
139struct 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
148int zcrypt_cex2a_init(void);
149void zcrypt_cex2a_exit(void);
150
151#endif /* _ZCRYPT_CEX2A_H_ */