Martin Schwidefsky | 963ed93 | 2006-09-20 15:58:29 +0200 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/s390/crypto/zcrypt_cex2a.h |
| 3 | * |
Ralph Wuerthner | 5432114 | 2006-09-20 15:58:36 +0200 | [diff] [blame] | 4 | * zcrypt 2.1.0 |
Martin Schwidefsky | 963ed93 | 2006-09-20 15:58:29 +0200 | [diff] [blame] | 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_CRB1_FMT 0x0011 |
| 55 | #define TYPE50_CRB2_FMT 0x0012 |
| 56 | |
| 57 | /* Mod-Exp, with a small modulus */ |
| 58 | struct type50_meb1_msg { |
| 59 | struct type50_hdr header; |
| 60 | unsigned short keyblock_type; /* 0x0001 */ |
| 61 | unsigned char reserved[6]; |
| 62 | unsigned char exponent[128]; |
| 63 | unsigned char modulus[128]; |
| 64 | unsigned char message[128]; |
| 65 | } __attribute__((packed)); |
| 66 | |
| 67 | /* Mod-Exp, with a large modulus */ |
| 68 | struct type50_meb2_msg { |
| 69 | struct type50_hdr header; |
| 70 | unsigned short keyblock_type; /* 0x0002 */ |
| 71 | unsigned char reserved[6]; |
| 72 | unsigned char exponent[256]; |
| 73 | unsigned char modulus[256]; |
| 74 | unsigned char message[256]; |
| 75 | } __attribute__((packed)); |
| 76 | |
| 77 | /* CRT, with a small modulus */ |
| 78 | struct type50_crb1_msg { |
| 79 | struct type50_hdr header; |
| 80 | unsigned short keyblock_type; /* 0x0011 */ |
| 81 | unsigned char reserved[6]; |
| 82 | unsigned char p[64]; |
| 83 | unsigned char q[64]; |
| 84 | unsigned char dp[64]; |
| 85 | unsigned char dq[64]; |
| 86 | unsigned char u[64]; |
| 87 | unsigned char message[128]; |
| 88 | } __attribute__((packed)); |
| 89 | |
| 90 | /* CRT, with a large modulus */ |
| 91 | struct type50_crb2_msg { |
| 92 | struct type50_hdr header; |
| 93 | unsigned short keyblock_type; /* 0x0012 */ |
| 94 | unsigned char reserved[6]; |
| 95 | unsigned char p[128]; |
| 96 | unsigned char q[128]; |
| 97 | unsigned char dp[128]; |
| 98 | unsigned char dq[128]; |
| 99 | unsigned char u[128]; |
| 100 | unsigned char message[256]; |
| 101 | } __attribute__((packed)); |
| 102 | |
| 103 | /** |
| 104 | * The type 80 response family is associated with a CEX2A card. |
| 105 | * |
| 106 | * Note that all unsigned char arrays are right-justified and left-padded |
| 107 | * with zeroes. |
| 108 | * |
| 109 | * Note that all reserved fields must be zeroes. |
| 110 | */ |
| 111 | |
| 112 | #define TYPE80_RSP_CODE 0x80 |
| 113 | |
| 114 | struct type80_hdr { |
| 115 | unsigned char reserved1; |
| 116 | unsigned char type; /* 0x80 */ |
| 117 | unsigned short len; |
| 118 | unsigned char code; /* 0x00 */ |
| 119 | unsigned char reserved2[3]; |
| 120 | unsigned char reserved3[8]; |
| 121 | } __attribute__((packed)); |
| 122 | |
| 123 | int zcrypt_cex2a_init(void); |
| 124 | void zcrypt_cex2a_exit(void); |
| 125 | |
| 126 | #endif /* _ZCRYPT_CEX2A_H_ */ |