Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 /*
0003  *  Copyright IBM Corp. 2001, 2006
0004  *  Author(s): Robert Burroughs
0005  *         Eric Rossman (edrossma@us.ibm.com)
0006  *
0007  *  Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
0008  *  Major cleanup & driver split: Martin Schwidefsky <schwidefsky@de.ibm.com>
0009  */
0010 
0011 #ifndef _ZCRYPT_CEX2A_H_
0012 #define _ZCRYPT_CEX2A_H_
0013 
0014 /**
0015  * The type 50 message family is associated with CEXxA cards.
0016  *
0017  * The four members of the family are described below.
0018  *
0019  * Note that all unsigned char arrays are right-justified and left-padded
0020  * with zeroes.
0021  *
0022  * Note that all reserved fields must be zeroes.
0023  */
0024 struct type50_hdr {
0025     unsigned char   reserved1;
0026     unsigned char   msg_type_code;  /* 0x50 */
0027     unsigned short  msg_len;
0028     unsigned char   reserved2;
0029     unsigned char   ignored;
0030     unsigned short  reserved3;
0031 } __packed;
0032 
0033 #define TYPE50_TYPE_CODE    0x50
0034 
0035 #define TYPE50_MEB1_FMT     0x0001
0036 #define TYPE50_MEB2_FMT     0x0002
0037 #define TYPE50_MEB3_FMT     0x0003
0038 #define TYPE50_CRB1_FMT     0x0011
0039 #define TYPE50_CRB2_FMT     0x0012
0040 #define TYPE50_CRB3_FMT     0x0013
0041 
0042 /* Mod-Exp, with a small modulus */
0043 struct type50_meb1_msg {
0044     struct type50_hdr header;
0045     unsigned short  keyblock_type;  /* 0x0001 */
0046     unsigned char   reserved[6];
0047     unsigned char   exponent[128];
0048     unsigned char   modulus[128];
0049     unsigned char   message[128];
0050 } __packed;
0051 
0052 /* Mod-Exp, with a large modulus */
0053 struct type50_meb2_msg {
0054     struct type50_hdr header;
0055     unsigned short  keyblock_type;  /* 0x0002 */
0056     unsigned char   reserved[6];
0057     unsigned char   exponent[256];
0058     unsigned char   modulus[256];
0059     unsigned char   message[256];
0060 } __packed;
0061 
0062 /* Mod-Exp, with a larger modulus */
0063 struct type50_meb3_msg {
0064     struct type50_hdr header;
0065     unsigned short  keyblock_type;  /* 0x0003 */
0066     unsigned char   reserved[6];
0067     unsigned char   exponent[512];
0068     unsigned char   modulus[512];
0069     unsigned char   message[512];
0070 } __packed;
0071 
0072 /* CRT, with a small modulus */
0073 struct type50_crb1_msg {
0074     struct type50_hdr header;
0075     unsigned short  keyblock_type;  /* 0x0011 */
0076     unsigned char   reserved[6];
0077     unsigned char   p[64];
0078     unsigned char   q[64];
0079     unsigned char   dp[64];
0080     unsigned char   dq[64];
0081     unsigned char   u[64];
0082     unsigned char   message[128];
0083 } __packed;
0084 
0085 /* CRT, with a large modulus */
0086 struct type50_crb2_msg {
0087     struct type50_hdr header;
0088     unsigned short  keyblock_type;  /* 0x0012 */
0089     unsigned char   reserved[6];
0090     unsigned char   p[128];
0091     unsigned char   q[128];
0092     unsigned char   dp[128];
0093     unsigned char   dq[128];
0094     unsigned char   u[128];
0095     unsigned char   message[256];
0096 } __packed;
0097 
0098 /* CRT, with a larger modulus */
0099 struct type50_crb3_msg {
0100     struct type50_hdr header;
0101     unsigned short  keyblock_type;  /* 0x0013 */
0102     unsigned char   reserved[6];
0103     unsigned char   p[256];
0104     unsigned char   q[256];
0105     unsigned char   dp[256];
0106     unsigned char   dq[256];
0107     unsigned char   u[256];
0108     unsigned char   message[512];
0109 } __packed;
0110 
0111 /**
0112  * The type 80 response family is associated with a CEXxA cards.
0113  *
0114  * Note that all unsigned char arrays are right-justified and left-padded
0115  * with zeroes.
0116  *
0117  * Note that all reserved fields must be zeroes.
0118  */
0119 
0120 #define TYPE80_RSP_CODE 0x80
0121 
0122 struct type80_hdr {
0123     unsigned char   reserved1;
0124     unsigned char   type;       /* 0x80 */
0125     unsigned short  len;
0126     unsigned char   code;       /* 0x00 */
0127     unsigned char   reserved2[3];
0128     unsigned char   reserved3[8];
0129 } __packed;
0130 
0131 int zcrypt_cex2a_init(void);
0132 void zcrypt_cex2a_exit(void);
0133 
0134 #endif /* _ZCRYPT_CEX2A_H_ */