1 /* Copyright (c) 2012-2020, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
5 #include "lib/crypt_ops/crypto_cipher.h"
6 #include "core/or/or.h"
9 #define RENDSERVICE_PRIVATE
10 #include "feature/rend/rendservice.h"
12 static uint8_t v0_test_plaintext
[] =
13 /* 20 bytes of rendezvous point nickname */
14 { 0x4e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65,
15 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16 0x00, 0x00, 0x00, 0x00,
17 /* 20 bytes dummy rendezvous cookie */
18 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
19 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
20 0x10, 0x11, 0x12, 0x13,
21 /* 128 bytes dummy DH handshake data */
22 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
23 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
24 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
25 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
26 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
27 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
28 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
29 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
30 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
31 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
32 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
33 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
34 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
35 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
36 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
37 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };
39 static uint8_t v1_test_plaintext
[] =
42 /* 42 bytes of dummy rendezvous point hex digest */
43 0x24, 0x30, 0x30, 0x30, 0x31, 0x30, 0x32, 0x30,
44 0x33, 0x30, 0x34, 0x30, 0x35, 0x30, 0x36, 0x30,
45 0x37, 0x30, 0x38, 0x30, 0x39, 0x30, 0x41, 0x30,
46 0x42, 0x30, 0x43, 0x30, 0x44, 0x30, 0x45, 0x30,
47 0x46, 0x31, 0x30, 0x31, 0x31, 0x31, 0x32, 0x31,
49 /* 20 bytes dummy rendezvous cookie */
50 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
51 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
52 0x10, 0x11, 0x12, 0x13,
53 /* 128 bytes dummy DH handshake data */
54 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
55 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
56 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
57 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
58 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
59 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
60 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
61 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
62 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
63 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
64 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
65 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
66 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
67 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
68 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
69 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };
71 static uint8_t v2_test_plaintext
[] =
74 /* 4 bytes rendezvous point's IP address */
75 0xc0, 0xa8, 0x00, 0x01,
76 /* 2 bytes rendezvous point's OR port */
78 /* 20 bytes dummy rendezvous point's identity digest */
79 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
80 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
81 0x10, 0x11, 0x12, 0x13,
82 /* 2 bytes length of onion key */
84 /* Onion key (140 bytes taken from live test) */
85 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xb1,
86 0xcd, 0x46, 0xa9, 0x18, 0xd2, 0x0f, 0x01, 0xf8,
87 0xb2, 0xad, 0xa4, 0x79, 0xb4, 0xbb, 0x4b, 0xf4,
88 0x54, 0x1e, 0x3f, 0x03, 0x54, 0xcf, 0x7c, 0xb6,
89 0xb5, 0xf0, 0xfe, 0xed, 0x4b, 0x7d, 0xd7, 0x61,
90 0xdb, 0x6d, 0xd9, 0x19, 0xe2, 0x72, 0x04, 0xaa,
91 0x3e, 0x89, 0x26, 0x14, 0x62, 0x9a, 0x6c, 0x11,
92 0x0b, 0x35, 0x99, 0x2c, 0x9f, 0x2c, 0x64, 0xa1,
93 0xd9, 0xe2, 0x88, 0xce, 0xf6, 0x54, 0xfe, 0x1d,
94 0x37, 0x5e, 0x6d, 0x73, 0x95, 0x54, 0x90, 0xf0,
95 0x7b, 0xfa, 0xd4, 0x44, 0xac, 0xb2, 0x23, 0x9f,
96 0x75, 0x36, 0xe2, 0x78, 0x62, 0x82, 0x80, 0xa4,
97 0x23, 0x22, 0xc9, 0xbf, 0xc4, 0x36, 0xd1, 0x31,
98 0x33, 0x8e, 0x64, 0xb4, 0xa9, 0x74, 0xa1, 0xcb,
99 0x42, 0x8d, 0x60, 0xc7, 0xbb, 0x8e, 0x6e, 0x0f,
100 0x36, 0x74, 0x8e, 0xf4, 0x08, 0x99, 0x06, 0x92,
101 0xb1, 0x3f, 0xb3, 0xdd, 0xed, 0xf7, 0xc9, 0x02,
102 0x03, 0x01, 0x00, 0x01,
103 /* 20 bytes dummy rendezvous cookie */
104 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
105 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
106 0x10, 0x11, 0x12, 0x13,
107 /* 128 bytes dummy DH handshake data */
108 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
109 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
110 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
111 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
112 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
113 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
114 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
115 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
116 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
117 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
118 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
119 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
120 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
121 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
122 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
123 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };
125 static uint8_t v3_no_auth_test_plaintext
[] =
128 /* Auth type (0 for no auth len/auth data) */
131 0x50, 0x0b, 0xb5, 0xaa,
132 /* 4 bytes rendezvous point's IP address */
133 0xc0, 0xa8, 0x00, 0x01,
134 /* 2 bytes rendezvous point's OR port */
136 /* 20 bytes dummy rendezvous point's identity digest */
137 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
138 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
139 0x10, 0x11, 0x12, 0x13,
140 /* 2 bytes length of onion key */
142 /* Onion key (140 bytes taken from live test) */
143 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xb1,
144 0xcd, 0x46, 0xa9, 0x18, 0xd2, 0x0f, 0x01, 0xf8,
145 0xb2, 0xad, 0xa4, 0x79, 0xb4, 0xbb, 0x4b, 0xf4,
146 0x54, 0x1e, 0x3f, 0x03, 0x54, 0xcf, 0x7c, 0xb6,
147 0xb5, 0xf0, 0xfe, 0xed, 0x4b, 0x7d, 0xd7, 0x61,
148 0xdb, 0x6d, 0xd9, 0x19, 0xe2, 0x72, 0x04, 0xaa,
149 0x3e, 0x89, 0x26, 0x14, 0x62, 0x9a, 0x6c, 0x11,
150 0x0b, 0x35, 0x99, 0x2c, 0x9f, 0x2c, 0x64, 0xa1,
151 0xd9, 0xe2, 0x88, 0xce, 0xf6, 0x54, 0xfe, 0x1d,
152 0x37, 0x5e, 0x6d, 0x73, 0x95, 0x54, 0x90, 0xf0,
153 0x7b, 0xfa, 0xd4, 0x44, 0xac, 0xb2, 0x23, 0x9f,
154 0x75, 0x36, 0xe2, 0x78, 0x62, 0x82, 0x80, 0xa4,
155 0x23, 0x22, 0xc9, 0xbf, 0xc4, 0x36, 0xd1, 0x31,
156 0x33, 0x8e, 0x64, 0xb4, 0xa9, 0x74, 0xa1, 0xcb,
157 0x42, 0x8d, 0x60, 0xc7, 0xbb, 0x8e, 0x6e, 0x0f,
158 0x36, 0x74, 0x8e, 0xf4, 0x08, 0x99, 0x06, 0x92,
159 0xb1, 0x3f, 0xb3, 0xdd, 0xed, 0xf7, 0xc9, 0x02,
160 0x03, 0x01, 0x00, 0x01,
161 /* 20 bytes dummy rendezvous cookie */
162 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
163 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
164 0x10, 0x11, 0x12, 0x13,
165 /* 128 bytes dummy DH handshake data */
166 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
167 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
168 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
169 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
170 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
171 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
172 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
173 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
174 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
175 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
176 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
177 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
178 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
179 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
180 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
181 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };
183 static uint8_t v3_basic_auth_test_plaintext
[] =
186 /* Auth type (1 for REND_BASIC_AUTH) */
188 /* Auth len (must be 16 bytes for REND_BASIC_AUTH) */
190 /* Auth data (a 16-byte dummy descriptor cookie) */
191 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
192 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
194 0x50, 0x0b, 0xb5, 0xaa,
195 /* 4 bytes rendezvous point's IP address */
196 0xc0, 0xa8, 0x00, 0x01,
197 /* 2 bytes rendezvous point's OR port */
199 /* 20 bytes dummy rendezvous point's identity digest */
200 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
201 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
202 0x10, 0x11, 0x12, 0x13,
203 /* 2 bytes length of onion key */
205 /* Onion key (140 bytes taken from live test) */
206 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xb1,
207 0xcd, 0x46, 0xa9, 0x18, 0xd2, 0x0f, 0x01, 0xf8,
208 0xb2, 0xad, 0xa4, 0x79, 0xb4, 0xbb, 0x4b, 0xf4,
209 0x54, 0x1e, 0x3f, 0x03, 0x54, 0xcf, 0x7c, 0xb6,
210 0xb5, 0xf0, 0xfe, 0xed, 0x4b, 0x7d, 0xd7, 0x61,
211 0xdb, 0x6d, 0xd9, 0x19, 0xe2, 0x72, 0x04, 0xaa,
212 0x3e, 0x89, 0x26, 0x14, 0x62, 0x9a, 0x6c, 0x11,
213 0x0b, 0x35, 0x99, 0x2c, 0x9f, 0x2c, 0x64, 0xa1,
214 0xd9, 0xe2, 0x88, 0xce, 0xf6, 0x54, 0xfe, 0x1d,
215 0x37, 0x5e, 0x6d, 0x73, 0x95, 0x54, 0x90, 0xf0,
216 0x7b, 0xfa, 0xd4, 0x44, 0xac, 0xb2, 0x23, 0x9f,
217 0x75, 0x36, 0xe2, 0x78, 0x62, 0x82, 0x80, 0xa4,
218 0x23, 0x22, 0xc9, 0xbf, 0xc4, 0x36, 0xd1, 0x31,
219 0x33, 0x8e, 0x64, 0xb4, 0xa9, 0x74, 0xa1, 0xcb,
220 0x42, 0x8d, 0x60, 0xc7, 0xbb, 0x8e, 0x6e, 0x0f,
221 0x36, 0x74, 0x8e, 0xf4, 0x08, 0x99, 0x06, 0x92,
222 0xb1, 0x3f, 0xb3, 0xdd, 0xed, 0xf7, 0xc9, 0x02,
223 0x03, 0x01, 0x00, 0x01,
224 /* 20 bytes dummy rendezvous cookie */
225 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
226 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
227 0x10, 0x11, 0x12, 0x13,
228 /* 128 bytes dummy DH handshake data */
229 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
230 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
231 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
232 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
233 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
234 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
235 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
236 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
237 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
238 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
239 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
240 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
241 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
242 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
243 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
244 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };
246 static void do_decrypt_test(uint8_t *plaintext
, size_t plaintext_len
);
247 static void do_early_parse_test(uint8_t *plaintext
, size_t plaintext_len
);
248 static void do_late_parse_test(uint8_t *plaintext
, size_t plaintext_len
);
249 static void do_parse_test(uint8_t *plaintext
, size_t plaintext_len
, int phase
);
250 static ssize_t
make_intro_from_plaintext(
251 void *buf
, size_t len
, crypto_pk_t
*key
, void **cell_out
);
253 #define EARLY_PARSE_ONLY 1
254 #define DECRYPT_ONLY 2
255 #define ALL_PARSING 3
258 do_early_parse_test(uint8_t *plaintext
, size_t plaintext_len
)
260 do_parse_test(plaintext
, plaintext_len
, EARLY_PARSE_ONLY
);
264 do_decrypt_test(uint8_t *plaintext
, size_t plaintext_len
)
266 do_parse_test(plaintext
, plaintext_len
, DECRYPT_ONLY
);
270 do_late_parse_test(uint8_t *plaintext
, size_t plaintext_len
)
272 do_parse_test(plaintext
, plaintext_len
, ALL_PARSING
);
275 /** Test utility function: checks that the <b>plaintext_len</b>-byte string at
276 * <b>plaintext</b> is at least superficially parseable.
279 do_parse_test(uint8_t *plaintext
, size_t plaintext_len
, int phase
)
281 crypto_pk_t
*k
= NULL
;
283 uint8_t *cell
= NULL
;
285 rend_intro_cell_t
*parsed_req
= NULL
;
286 char *err_msg
= NULL
;
287 char digest
[DIGEST_LEN
];
292 r
= crypto_pk_read_private_key_from_string(k
, AUTHORITY_SIGNKEY_1
, -1);
295 /* Get digest for future comparison */
296 r
= crypto_pk_get_digest(k
, digest
);
299 /* Make a cell out of it */
300 r
= make_intro_from_plaintext(
301 plaintext
, plaintext_len
,
302 k
, (void **)(&cell
));
307 /* Do early parsing */
308 parsed_req
= rend_service_begin_parse_intro(cell
, cell_len
, 2, &err_msg
);
309 tt_assert(parsed_req
);
310 tt_ptr_op(err_msg
, OP_EQ
, NULL
);
311 tt_mem_op(parsed_req
->pk
,OP_EQ
, digest
, DIGEST_LEN
);
312 tt_assert(parsed_req
->ciphertext
);
313 tt_assert(parsed_req
->ciphertext_len
> 0);
315 if (phase
== EARLY_PARSE_ONLY
)
319 r
= rend_service_decrypt_intro(parsed_req
, k
, &err_msg
);
321 tt_ptr_op(err_msg
, OP_EQ
, NULL
);
322 tt_assert(parsed_req
->plaintext
);
323 tt_assert(parsed_req
->plaintext_len
> 0);
325 if (phase
== DECRYPT_ONLY
)
328 /* Do late parsing */
329 r
= rend_service_parse_intro_plaintext(parsed_req
, &err_msg
);
331 tt_ptr_op(err_msg
, OP_EQ
, NULL
);
332 tt_assert(parsed_req
->parsed
);
337 rend_service_free_intro(parsed_req
);
341 /** Given the plaintext of the encrypted part of an INTRODUCE1/2 and a key,
342 * construct the encrypted cell for testing.
346 make_intro_from_plaintext(
347 void *buf
, size_t len
, crypto_pk_t
*key
, void **cell_out
)
350 ssize_t cell_len
= -1, r
;
351 /* Assemble key digest and ciphertext, then construct the cell */
352 ssize_t ciphertext_size
;
354 if (!(buf
&& key
&& len
> 0 && cell_out
)) goto done
;
357 * Figure out an upper bound on how big the ciphertext will be
358 * (see crypto_pk_obsolete_public_hybrid_encrypt())
360 ciphertext_size
= PKCS1_OAEP_PADDING_OVERHEAD
;
361 ciphertext_size
+= crypto_pk_keysize(key
);
362 ciphertext_size
+= CIPHER_KEY_LEN
;
363 ciphertext_size
+= len
;
366 * Allocate space for the cell
368 cell
= tor_malloc(DIGEST_LEN
+ ciphertext_size
);
370 /* Compute key digest (will be first DIGEST_LEN octets of cell) */
371 r
= crypto_pk_get_digest(key
, cell
);
375 r
= crypto_pk_obsolete_public_hybrid_encrypt(
376 key
, cell
+ DIGEST_LEN
, ciphertext_size
,
378 PK_PKCS1_OAEP_PADDING
, 0);
381 /* Figure out cell length */
382 cell_len
= DIGEST_LEN
+ r
;
384 /* Output the cell */
393 /** Test v0 INTRODUCE2 parsing through decryption only
397 test_introduce_decrypt_v0(void *arg
)
400 do_decrypt_test(v0_test_plaintext
, sizeof(v0_test_plaintext
));
403 /** Test v1 INTRODUCE2 parsing through decryption only
407 test_introduce_decrypt_v1(void *arg
)
410 do_decrypt_test(v1_test_plaintext
, sizeof(v1_test_plaintext
));
413 /** Test v2 INTRODUCE2 parsing through decryption only
417 test_introduce_decrypt_v2(void *arg
)
420 do_decrypt_test(v2_test_plaintext
, sizeof(v2_test_plaintext
));
423 /** Test v3 INTRODUCE2 parsing through decryption only
427 test_introduce_decrypt_v3(void *arg
)
431 v3_no_auth_test_plaintext
, sizeof(v3_no_auth_test_plaintext
));
433 v3_basic_auth_test_plaintext
, sizeof(v3_basic_auth_test_plaintext
));
436 /** Test v0 INTRODUCE2 parsing through early parsing only
440 test_introduce_early_parse_v0(void *arg
)
443 do_early_parse_test(v0_test_plaintext
, sizeof(v0_test_plaintext
));
446 /** Test v1 INTRODUCE2 parsing through early parsing only
450 test_introduce_early_parse_v1(void *arg
)
453 do_early_parse_test(v1_test_plaintext
, sizeof(v1_test_plaintext
));
456 /** Test v2 INTRODUCE2 parsing through early parsing only
460 test_introduce_early_parse_v2(void *arg
)
463 do_early_parse_test(v2_test_plaintext
, sizeof(v2_test_plaintext
));
466 /** Test v3 INTRODUCE2 parsing through early parsing only
470 test_introduce_early_parse_v3(void *arg
)
474 v3_no_auth_test_plaintext
, sizeof(v3_no_auth_test_plaintext
));
476 v3_basic_auth_test_plaintext
, sizeof(v3_basic_auth_test_plaintext
));
479 /** Test v0 INTRODUCE2 parsing
483 test_introduce_late_parse_v0(void *arg
)
486 do_late_parse_test(v0_test_plaintext
, sizeof(v0_test_plaintext
));
489 /** Test v1 INTRODUCE2 parsing
493 test_introduce_late_parse_v1(void *arg
)
496 do_late_parse_test(v1_test_plaintext
, sizeof(v1_test_plaintext
));
499 /** Test v2 INTRODUCE2 parsing
503 test_introduce_late_parse_v2(void *arg
)
506 do_late_parse_test(v2_test_plaintext
, sizeof(v2_test_plaintext
));
509 /** Test v3 INTRODUCE2 parsing
513 test_introduce_late_parse_v3(void *arg
)
517 v3_no_auth_test_plaintext
, sizeof(v3_no_auth_test_plaintext
));
519 v3_basic_auth_test_plaintext
, sizeof(v3_basic_auth_test_plaintext
));
522 #define INTRODUCE_LEGACY(name) \
523 { #name, test_introduce_ ## name , 0, NULL, NULL }
525 struct testcase_t introduce_tests
[] = {
526 INTRODUCE_LEGACY(early_parse_v0
),
527 INTRODUCE_LEGACY(early_parse_v1
),
528 INTRODUCE_LEGACY(early_parse_v2
),
529 INTRODUCE_LEGACY(early_parse_v3
),
530 INTRODUCE_LEGACY(decrypt_v0
),
531 INTRODUCE_LEGACY(decrypt_v1
),
532 INTRODUCE_LEGACY(decrypt_v2
),
533 INTRODUCE_LEGACY(decrypt_v3
),
534 INTRODUCE_LEGACY(late_parse_v0
),
535 INTRODUCE_LEGACY(late_parse_v1
),
536 INTRODUCE_LEGACY(late_parse_v2
),
537 INTRODUCE_LEGACY(late_parse_v3
),