This source file includes following definitions.
- rng_type6CPRB_msgX
1
2
3
4
5
6
7
8
9
10
11
12 #ifndef _ZCRYPT_MSGTYPE6_H_
13 #define _ZCRYPT_MSGTYPE6_H_
14
15 #include <asm/zcrypt.h>
16
17 #define MSGTYPE06_NAME "zcrypt_msgtype6"
18 #define MSGTYPE06_VARIANT_DEFAULT 0
19 #define MSGTYPE06_VARIANT_NORNG 1
20 #define MSGTYPE06_VARIANT_EP11 2
21
22 #define MSGTYPE06_MAX_MSG_SIZE (12*1024)
23
24
25
26
27
28
29
30
31
32 struct type6_hdr {
33 unsigned char reserved1;
34 unsigned char type;
35 unsigned char reserved2[2];
36 unsigned char right[4];
37 unsigned char reserved3[2];
38 unsigned char reserved4[2];
39 unsigned char apfs[4];
40 unsigned int offset1;
41 unsigned int offset2;
42 unsigned int offset3;
43 unsigned int offset4;
44 unsigned char agent_id[16];
45
46 unsigned char rqid[2];
47 unsigned char reserved5[2];
48 unsigned char function_code[2];
49 unsigned char reserved6[2];
50 unsigned int ToCardLen1;
51 unsigned int ToCardLen2;
52 unsigned int ToCardLen3;
53 unsigned int ToCardLen4;
54 unsigned int FromCardLen1;
55 unsigned int FromCardLen2;
56 unsigned int FromCardLen3;
57 unsigned int FromCardLen4;
58 } __packed;
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 struct type86_hdr {
74 unsigned char reserved1;
75 unsigned char type;
76 unsigned char format;
77 unsigned char reserved2;
78 unsigned char reply_code;
79 unsigned char reserved3[3];
80 } __packed;
81
82 #define TYPE86_RSP_CODE 0x86
83 #define TYPE87_RSP_CODE 0x87
84 #define TYPE86_FMT2 0x02
85
86 struct type86_fmt2_ext {
87 unsigned char reserved[4];
88 unsigned char apfs[4];
89 unsigned int count1;
90 unsigned int offset1;
91 unsigned int count2;
92 unsigned int offset2;
93 unsigned int count3;
94 unsigned int offset3;
95 unsigned int count4;
96 unsigned int offset4;
97 } __packed;
98
99 unsigned int get_cprb_fc(struct ica_xcRB *, struct ap_message *,
100 unsigned int *, unsigned short **);
101 unsigned int get_ep11cprb_fc(struct ep11_urb *, struct ap_message *,
102 unsigned int *);
103 unsigned int get_rng_fc(struct ap_message *, int *, unsigned int *);
104
105 #define LOW 10
106 #define MEDIUM 100
107 #define HIGH 500
108
109 int speed_idx_cca(int);
110 int speed_idx_ep11(int);
111
112
113
114
115
116
117
118 static inline void rng_type6CPRB_msgX(struct ap_message *ap_msg,
119 unsigned int random_number_length,
120 unsigned int *domain)
121 {
122 struct {
123 struct type6_hdr hdr;
124 struct CPRBX cprbx;
125 char function_code[2];
126 short int rule_length;
127 char rule[8];
128 short int verb_length;
129 short int key_length;
130 } __packed * msg = ap_msg->message;
131 static struct type6_hdr static_type6_hdrX = {
132 .type = 0x06,
133 .offset1 = 0x00000058,
134 .agent_id = {'C', 'A'},
135 .function_code = {'R', 'L'},
136 .ToCardLen1 = sizeof(*msg) - sizeof(msg->hdr),
137 .FromCardLen1 = sizeof(*msg) - sizeof(msg->hdr),
138 };
139 static struct CPRBX local_cprbx = {
140 .cprb_len = 0x00dc,
141 .cprb_ver_id = 0x02,
142 .func_id = {0x54, 0x32},
143 .req_parml = sizeof(*msg) - sizeof(msg->hdr) -
144 sizeof(msg->cprbx),
145 .rpl_msgbl = sizeof(*msg) - sizeof(msg->hdr),
146 };
147
148 msg->hdr = static_type6_hdrX;
149 msg->hdr.FromCardLen2 = random_number_length,
150 msg->cprbx = local_cprbx;
151 msg->cprbx.rpl_datal = random_number_length,
152 memcpy(msg->function_code, msg->hdr.function_code, 0x02);
153 msg->rule_length = 0x0a;
154 memcpy(msg->rule, "RANDOM ", 8);
155 msg->verb_length = 0x02;
156 msg->key_length = 0x02;
157 ap_msg->length = sizeof(*msg);
158 *domain = (unsigned short)msg->cprbx.domain;
159 }
160
161 void zcrypt_msgtype6_init(void);
162 void zcrypt_msgtype6_exit(void);
163
164 #endif