Debian Codegraph @

test/core/tsi/alts/crypt/aes_gcm_test.cc

raw
1 /*
2 *
3 * Copyright 2018 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19 #include <gtest/gtest.h>
20
21 #include <grpc/support/alloc.h>
22 #include <grpc/support/log.h>
23
24 #include "src/core/tsi/alts/crypt/gsec.h"
25 #include "test/core/tsi/alts/crypt/gsec_test_util.h"
26 #include "test/core/util/test_config.h"
27
28 const size_t kTestMinTagLengthForCorruption = 8;
29 const size_t kTestNumCrypters = 3;
30 const size_t kTestMaxSlices = 5;
31 const size_t kTestMaxLength = 1024;
32 const size_t kTestNumEncryptions = 100;
33
34 /* Struct for pre-generated test vector */
35 typedef struct gsec_aead_test_vector {
36 uint8_t* nonce;
37 uint8_t* aad;
38 uint8_t* key;
39 uint8_t* plaintext;
40 uint8_t* ciphertext_and_tag;
41 size_t nonce_length;
42 size_t aad_length;
43 size_t key_length;
44 size_t plaintext_length;
45 size_t ciphertext_and_tag_length;
46 } gsec_aead_test_vector;
47
48 static void gsec_randomly_slice(uint8_t* input, size_t input_length,
49 struct iovec** output, size_t* output_length) {
50 if (input_length == 0) {
51 *output = nullptr;
52 *output_length = 0;
53 return;
54 }
55 *output_length = gsec_test_bias_random_uint32(kTestMaxSlices) + 1;
56 *output =
57 static_cast<struct iovec*>(malloc(*output_length * sizeof(**output)));
58 size_t i;
59 for (i = 0; i < *output_length - 1; i++) {
60 size_t slice_length =
61 gsec_test_bias_random_uint32(static_cast<uint32_t>(input_length));
62 struct iovec slice = {input, slice_length};
63 (*output)[i] = slice;
64 input += slice_length;
65 input_length -= slice_length;
66 }
67 struct iovec slice = {input, input_length};
68 (*output)[*output_length - 1] = slice;
69 }
70
71 static void gsec_assert_ok(grpc_status_code status, const char* error_detail) {
72 char empty_string[] = "";
73 if (error_detail == nullptr) {
74 error_detail = empty_string;
75 }
76 if (status != GRPC_STATUS_OK) {
77 fprintf(stderr, "Status is not ok: %s\n", error_detail);
78 }
79 ASSERT_EQ(status, GRPC_STATUS_OK);
80 }
81
82 static void gsec_test_random_encrypt_decrypt(gsec_aead_crypter* crypter,
83 size_t aad_length,
84 size_t message_length) {
85 ASSERT_NE(crypter, nullptr);
86 size_t nonce_length, tag_length;
87 uint8_t *nonce, *aad, *message;
88 gsec_aead_crypter_nonce_length(crypter, &nonce_length, nullptr);
89 gsec_aead_crypter_tag_length(crypter, &tag_length, nullptr);
90
91 gsec_test_random_array(&nonce, nonce_length);
92 gsec_test_random_array(&aad, aad_length);
93 gsec_test_random_array(&message, message_length);
94
95 /* Test encryption */
96 size_t ciphertext_and_tag_length, ciphertext_bytes_written = 0;
97 gsec_aead_crypter_max_ciphertext_and_tag_length(
98 crypter, message_length, &ciphertext_and_tag_length, nullptr);
99
100 uint8_t* ciphertext_and_tag =
101 static_cast<uint8_t*>(gpr_malloc(ciphertext_and_tag_length));
102
103 char* error_buffer = nullptr;
104 gsec_assert_ok(
105 gsec_aead_crypter_encrypt(crypter, nonce, nonce_length, aad, aad_length,
106 message, message_length, ciphertext_and_tag,
107 ciphertext_and_tag_length,
108 &ciphertext_bytes_written, &error_buffer),
109 error_buffer);
110 ASSERT_EQ(message_length + tag_length, ciphertext_and_tag_length);
111 ASSERT_EQ(ciphertext_bytes_written, ciphertext_and_tag_length);
112
113 /* Test decryption */
114 size_t plaintext_length, plaintext_bytes_written = 0;
115 gsec_aead_crypter_max_plaintext_length(crypter, ciphertext_bytes_written,
116 &plaintext_length, nullptr);
117 uint8_t* plaintext = static_cast<uint8_t*>(gpr_malloc(plaintext_length));
118 grpc_status_code status = gsec_aead_crypter_decrypt(
119 crypter, nonce, nonce_length, aad, aad_length, ciphertext_and_tag,
120 ciphertext_bytes_written, plaintext, plaintext_length,
121 &plaintext_bytes_written, nullptr);
122
123 ASSERT_EQ(status, GRPC_STATUS_OK);
124 ASSERT_EQ(message_length, plaintext_bytes_written);
125 if (message_length != 0) {
126 ASSERT_EQ(memcmp(message, plaintext, message_length), 0);
127 }
128
129 /**
130 * The returned plaintext will be zeroed if there was an authentication error.
131 */
132 uint8_t* zero_message = static_cast<uint8_t*>(gpr_zalloc(plaintext_length));
133 if (tag_length >= kTestMinTagLengthForCorruption) {
134 char* error_message;
135 /* Corrupt nonce */
136 if (nonce_length > 0) {
137 plaintext_bytes_written = 0;
138 uint8_t* corrupt_nonce;
139 gsec_test_copy_and_alter_random_byte(nonce, &corrupt_nonce, nonce_length);
140 status = gsec_aead_crypter_decrypt(
141 crypter, corrupt_nonce, nonce_length, aad, aad_length,
142 ciphertext_and_tag, ciphertext_bytes_written, plaintext,
143 plaintext_length, &plaintext_bytes_written, &error_message);
144
145 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
146 status, GRPC_STATUS_FAILED_PRECONDITION, "Checking tag failed.",
147 error_message));
148 ASSERT_EQ(plaintext_bytes_written, 0);
149 if (plaintext_length != 0) {
150 ASSERT_EQ(memcmp(zero_message, plaintext, plaintext_length), 0);
151 }
152 gpr_free(corrupt_nonce);
153 gpr_free(error_message);
154 }
155
156 /* Corrupt ciphertext_and_tag */
157 plaintext_bytes_written = 0;
158 uint8_t* corrupt_ciphertext_and_tag;
159 gsec_test_copy_and_alter_random_byte(ciphertext_and_tag,
160 &corrupt_ciphertext_and_tag,
161 ciphertext_and_tag_length);
162 status = gsec_aead_crypter_decrypt(
163 crypter, nonce, nonce_length, aad, aad_length,
164 corrupt_ciphertext_and_tag, ciphertext_bytes_written, plaintext,
165 plaintext_length, &plaintext_bytes_written, &error_message);
166
167 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
168 status, GRPC_STATUS_FAILED_PRECONDITION, error_message,
169 "Checking tag failed"));
170 ASSERT_EQ(plaintext_bytes_written, 0);
171 if (plaintext_length != 0) {
172 ASSERT_EQ(memcmp(zero_message, plaintext, plaintext_length), 0);
173 }
174 gpr_free(error_message);
175 gpr_free(corrupt_ciphertext_and_tag);
176
177 /* Corrupt start of ciphertext_and_tag */
178 plaintext_bytes_written = 0;
179 gsec_test_copy(ciphertext_and_tag, &corrupt_ciphertext_and_tag,
180 ciphertext_and_tag_length);
181 (*corrupt_ciphertext_and_tag)++;
182 status = gsec_aead_crypter_decrypt(
183 crypter, nonce, nonce_length, aad, aad_length,
184 corrupt_ciphertext_and_tag, ciphertext_bytes_written, plaintext,
185 plaintext_length, &plaintext_bytes_written, &error_message);
186 ASSERT_EQ(plaintext_bytes_written, 0);
187 if (plaintext_length != 0) {
188 ASSERT_EQ(memcmp(zero_message, plaintext, plaintext_length), 0);
189 }
190 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
191 status, GRPC_STATUS_FAILED_PRECONDITION, error_message,
192 "Checking tag failed"));
193 gpr_free(error_message);
194 gpr_free(corrupt_ciphertext_and_tag);
195
196 /* Corrupt end of ciphertext_and_tag */
197 plaintext_bytes_written = 0;
198 gsec_test_copy(ciphertext_and_tag, &corrupt_ciphertext_and_tag,
199 ciphertext_and_tag_length);
200 (*(corrupt_ciphertext_and_tag + ciphertext_and_tag_length - 1))++;
201
202 status = gsec_aead_crypter_decrypt(
203 crypter, nonce, nonce_length, aad, aad_length,
204 corrupt_ciphertext_and_tag, ciphertext_bytes_written, plaintext,
205 plaintext_length, &plaintext_bytes_written, &error_message);
206
207 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
208 status, GRPC_STATUS_FAILED_PRECONDITION, error_message,
209 "Checking tag failed"));
210 ASSERT_EQ(plaintext_bytes_written, 0);
211 if (plaintext_length != 0) {
212 ASSERT_EQ(memcmp(zero_message, plaintext, plaintext_length), 0);
213 }
214 gpr_free(error_message);
215 gpr_free(corrupt_ciphertext_and_tag);
216 }
217
218 gpr_free(zero_message);
219 gpr_free(nonce);
220 gpr_free(aad);
221 gpr_free(message);
222 gpr_free(plaintext);
223 gpr_free(ciphertext_and_tag);
224 }
225
226 static void gsec_test_encrypt_decrypt(gsec_aead_crypter* crypter) {
227 ASSERT_NE(crypter, nullptr);
228 size_t aad_length, message_length;
229 aad_length = gsec_test_bias_random_uint32(kTestMaxLength);
230 message_length = gsec_test_bias_random_uint32(kTestMaxLength);
231 gsec_test_random_encrypt_decrypt(crypter, aad_length, message_length);
232 gsec_test_random_encrypt_decrypt(crypter, 0, message_length);
233 gsec_test_random_encrypt_decrypt(crypter, aad_length, 0);
234 }
235
236 static void gsec_test_multiple_random_encrypt_decrypt(
237 gsec_aead_crypter* crypter, size_t* aad_lengths, size_t* message_lengths,
238 size_t count) {
239 ASSERT_NE(crypter, nullptr);
240 size_t nonce_length, tag_length;
241 uint8_t **nonces, **aads, **messages;
242 nonces = static_cast<uint8_t**>(gpr_malloc(sizeof(uint8_t*) * count));
243 aads = static_cast<uint8_t**>(gpr_malloc(sizeof(uint8_t*) * count));
244 messages = static_cast<uint8_t**>(gpr_malloc(sizeof(uint8_t*) * count));
245
246 gsec_aead_crypter_nonce_length(crypter, &nonce_length, nullptr);
247 gsec_aead_crypter_tag_length(crypter, &tag_length, nullptr);
248
249 size_t ind;
250 for (ind = 0; ind < count; ind++) {
251 size_t aad_length = (aad_lengths == nullptr) ? 0 : aad_lengths[ind];
252 size_t message_length =
253 (message_lengths == nullptr) ? 0 : message_lengths[ind];
254 gsec_test_random_array(&(nonces[ind]), nonce_length);
255 gsec_test_random_array(&(aads[ind]), aad_length);
256 gsec_test_random_array(&(messages[ind]), message_length);
257 }
258
259 size_t* ciphertext_and_tag_lengths =
260 static_cast<size_t*>(gpr_malloc(sizeof(size_t) * count));
261 size_t* ciphertext_bytes_writtens =
262 static_cast<size_t*>(gpr_malloc(sizeof(size_t) * count));
263 size_t* plaintext_lengths =
264 static_cast<size_t*>(gpr_malloc(sizeof(size_t) * count));
265 size_t* plaintext_bytes_writtens =
266 static_cast<size_t*>(gpr_malloc(sizeof(size_t) * count));
267 uint8_t** ciphertext_and_tags =
268 static_cast<uint8_t**>(gpr_malloc(sizeof(uint8_t*) * count));
269 uint8_t** plaintexts =
270 static_cast<uint8_t**>(gpr_malloc(sizeof(uint8_t*) * count));
271
272 /* Do encryption */
273 for (ind = 0; ind < count; ind++) {
274 size_t aad_length = (aad_lengths == nullptr) ? 0 : aad_lengths[ind];
275 size_t message_length =
276 (message_lengths == nullptr) ? 0 : message_lengths[ind];
277 gsec_aead_crypter_max_ciphertext_and_tag_length(
278 crypter, message_length, &(ciphertext_and_tag_lengths[ind]), nullptr);
279 ciphertext_and_tags[ind] =
280 static_cast<uint8_t*>(gpr_malloc(ciphertext_and_tag_lengths[ind]));
281 grpc_status_code status = gsec_aead_crypter_encrypt(
282 crypter, nonces[ind], nonce_length, aads[ind], aad_length,
283 messages[ind], message_length, ciphertext_and_tags[ind],
284 ciphertext_and_tag_lengths[ind], &(ciphertext_bytes_writtens[ind]),
285 nullptr);
286 ASSERT_EQ(status, GRPC_STATUS_OK);
287 ASSERT_EQ(message_length + tag_length, ciphertext_and_tag_lengths[ind]);
288 ASSERT_EQ(ciphertext_bytes_writtens[ind], ciphertext_and_tag_lengths[ind]);
289 }
290 /* Do Decryption */
291 for (ind = 0; ind < count; ind++) {
292 size_t aad_length = (aad_lengths == nullptr) ? 0 : aad_lengths[ind];
293 size_t message_length =
294 (message_lengths == nullptr) ? 0 : message_lengths[ind];
295 gsec_aead_crypter_max_plaintext_length(crypter,
296 ciphertext_bytes_writtens[ind],
297 &(plaintext_lengths[ind]), nullptr);
298 plaintexts[ind] = static_cast<uint8_t*>(gpr_malloc(plaintext_lengths[ind]));
299 grpc_status_code status = gsec_aead_crypter_decrypt(
300 crypter, nonces[ind], nonce_length, aads[ind], aad_length,
301 ciphertext_and_tags[ind], ciphertext_bytes_writtens[ind],
302 plaintexts[ind], plaintext_lengths[ind],
303 &(plaintext_bytes_writtens[ind]), nullptr);
304 ASSERT_EQ(status, GRPC_STATUS_OK);
305 ASSERT_EQ(message_length, plaintext_bytes_writtens[ind]);
306 if (message_length != 0) {
307 ASSERT_EQ(memcmp(messages[ind], plaintexts[ind], message_length), 0);
308 }
309 }
310
311 /* Slice the plaintext and encrypt with iovecs */
312 for (ind = 0; ind < count; ind++) {
313 size_t aad_length = (aad_lengths == nullptr) ? 0 : aad_lengths[ind];
314 struct iovec* aad_vecs = nullptr;
315 size_t aad_vecs_length = 0;
316 gsec_randomly_slice(aads[ind], aad_length, &aad_vecs, &aad_vecs_length);
317 size_t message_length =
318 (message_lengths == nullptr) ? 0 : message_lengths[ind];
319 struct iovec* message_vecs = nullptr;
320 size_t message_vecs_length = 0;
321 gsec_randomly_slice(messages[ind], message_length, &message_vecs,
322 &message_vecs_length);
323
324 size_t ciphertext_length = ciphertext_and_tag_lengths[ind];
325 uint8_t* another_ciphertext =
326 static_cast<uint8_t*>(malloc(ciphertext_length));
327 struct iovec another_ciphertext_vec = {another_ciphertext,
328 ciphertext_length};
329
330 char* error_details = nullptr;
331 size_t ciphertext_bytes_written = 0;
332 gsec_assert_ok(
333 gsec_aead_crypter_encrypt_iovec(
334 crypter, nonces[ind], nonce_length, aad_vecs, aad_vecs_length,
335 message_vecs, message_vecs_length, another_ciphertext_vec,
336 &ciphertext_bytes_written, &error_details),
337 error_details);
338 ASSERT_EQ(memcmp(ciphertext_and_tags[ind], another_ciphertext_vec.iov_base,
339 ciphertext_length),
340 0);
341 free(another_ciphertext);
342 free(aad_vecs);
343 free(message_vecs);
344 }
345
346 /* Slice the ciphertext and decrypt with iovecs */
347 for (ind = 0; ind < count; ind++) {
348 size_t message_length =
349 (message_lengths == nullptr) ? 0 : message_lengths[ind];
350 message_length = message_length + 0;
351
352 size_t aad_length = (aad_lengths == nullptr) ? 0 : aad_lengths[ind];
353
354 struct iovec* aad_vecs = nullptr;
355 size_t aad_vecs_length = 0;
356 gsec_randomly_slice(aads[ind], aad_length, &aad_vecs, &aad_vecs_length);
357
358 struct iovec* ciphertext_vecs = nullptr;
359 size_t ciphertext_vecs_length = 0;
360 gsec_randomly_slice(ciphertext_and_tags[ind],
361 ciphertext_bytes_writtens[ind], &ciphertext_vecs,
362 &ciphertext_vecs_length);
363
364 size_t decrypted_length = plaintext_lengths[ind];
365 uint8_t* decrypted = static_cast<uint8_t*>(malloc(decrypted_length));
366 struct iovec decrypted_vec = {decrypted, decrypted_length};
367
368 char* error_details = nullptr;
369 gsec_assert_ok(gsec_aead_crypter_decrypt_iovec(
370 crypter, nonces[ind], nonce_length, aad_vecs,
371 aad_vecs_length, ciphertext_vecs, ciphertext_vecs_length,
372 decrypted_vec, &decrypted_length, &error_details),
373 error_details);
374 ASSERT_EQ(decrypted_vec.iov_len, message_length);
375 if (message_length != 0) {
376 ASSERT_EQ(memcmp(decrypted_vec.iov_base, messages[ind], message_length),
377 0);
378 }
379 free(decrypted);
380 free(aad_vecs);
381 free(ciphertext_vecs);
382 }
383
384 for (ind = 0; ind < count; ind++) {
385 gpr_free(nonces[ind]);
386 gpr_free(aads[ind]);
387 gpr_free(messages[ind]);
388 gpr_free(ciphertext_and_tags[ind]);
389 gpr_free(plaintexts[ind]);
390 }
391 gpr_free(nonces);
392 gpr_free(aads);
393 gpr_free(messages);
394 gpr_free(ciphertext_and_tag_lengths);
395 gpr_free(ciphertext_bytes_writtens);
396 gpr_free(plaintext_lengths);
397 gpr_free(plaintext_bytes_writtens);
398 gpr_free(ciphertext_and_tags);
399 gpr_free(plaintexts);
400 }
401
402 static void gsec_test_multiple_encrypt_decrypt(gsec_aead_crypter* crypter) {
403 ASSERT_NE(crypter, nullptr);
404 size_t count = kTestNumEncryptions;
405 size_t* aad_lengths =
406 static_cast<size_t*>(gpr_malloc(sizeof(size_t) * count));
407 size_t* message_lengths =
408 static_cast<size_t*>(gpr_malloc(sizeof(size_t) * count));
409 size_t ind;
410 for (ind = 0; ind < count; ind++) {
411 aad_lengths[ind] = gsec_test_bias_random_uint32(kTestMaxLength);
412 message_lengths[ind] = gsec_test_bias_random_uint32(kTestMaxLength);
413 }
414 gsec_test_multiple_random_encrypt_decrypt(crypter, aad_lengths,
415 message_lengths, count);
416 gsec_test_multiple_random_encrypt_decrypt(crypter, aad_lengths, nullptr,
417 count);
418 gsec_test_multiple_random_encrypt_decrypt(crypter, nullptr, message_lengths,
419 count);
420 gpr_free(aad_lengths);
421 gpr_free(message_lengths);
422 }
423
424 static void gsec_test_encryption_failure(gsec_aead_crypter* crypter) {
425 ASSERT_NE(crypter, nullptr);
426 size_t aad_length = kTestMaxLength;
427 size_t message_length = kTestMaxLength;
428 size_t nonce_length;
429
430 char* error_message;
431 uint8_t *nonce, *aad, *message;
432
433 gsec_aead_crypter_nonce_length(crypter, &nonce_length, nullptr);
434 gsec_test_random_array(&nonce, nonce_length);
435 gsec_test_random_array(&aad, aad_length);
436 gsec_test_random_array(&message, message_length);
437
438 size_t ciphertext_and_tag_length, ciphertext_bytes_written = 0;
439 gsec_aead_crypter_max_ciphertext_and_tag_length(
440 crypter, message_length, &ciphertext_and_tag_length, nullptr);
441 uint8_t* ciphertext_and_tag =
442 static_cast<uint8_t*>(gpr_malloc(ciphertext_and_tag_length));
443
444 /* nullptr nonce */
445 grpc_status_code status = gsec_aead_crypter_encrypt(
446 crypter, nullptr, nonce_length, aad, aad_length, message, message_length,
447 ciphertext_and_tag, ciphertext_and_tag_length, &ciphertext_bytes_written,
448 &error_message);
449 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
450 status, GRPC_STATUS_INVALID_ARGUMENT, error_message,
451 "Nonce buffer is nullptr."));
452 gpr_free(error_message);
453
454 /* Big nonce */
455 status = gsec_aead_crypter_encrypt(
456 crypter, nonce, nonce_length + 1, aad, aad_length, message,
457 message_length, ciphertext_and_tag, ciphertext_and_tag_length,
458 &ciphertext_bytes_written, &error_message);
459 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
460 status, GRPC_STATUS_INVALID_ARGUMENT, error_message,
461 "Nonce buffer has the wrong length."));
462 gpr_free(error_message);
463
464 /* Small nonce */
465 status = gsec_aead_crypter_encrypt(
466 crypter, nonce, nonce_length - 1, aad, aad_length, message,
467 message_length, ciphertext_and_tag, ciphertext_and_tag_length,
468 &ciphertext_bytes_written, &error_message);
469 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
470 status, GRPC_STATUS_INVALID_ARGUMENT, error_message,
471 "Nonce buffer has the wrong length."));
472 gpr_free(error_message);
473
474 /* nullptr aad */
475 status = gsec_aead_crypter_encrypt(
476 crypter, nonce, nonce_length, nullptr, aad_length, message,
477 message_length, ciphertext_and_tag, ciphertext_and_tag_length,
478 &ciphertext_bytes_written, &error_message);
479 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
480 status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "aad is nullptr."));
481 gpr_free(error_message);
482
483 /* nullptr aad with zero length */
484 gsec_assert_ok(
485 gsec_aead_crypter_encrypt(crypter, nonce, nonce_length, nullptr, 0,
486 message, message_length, ciphertext_and_tag,
487 ciphertext_and_tag_length,
488 &ciphertext_bytes_written, &error_message),
489 error_message);
490
491 /* nullptr plaintext */
492 status = gsec_aead_crypter_encrypt(
493 crypter, nonce, nonce_length, aad, aad_length, nullptr, message_length,
494 ciphertext_and_tag, ciphertext_and_tag_length, &ciphertext_bytes_written,
495 &error_message);
496 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
497 status, GRPC_STATUS_INVALID_ARGUMENT, error_message,
498 "plaintext is nullptr."));
499 gpr_free(error_message);
500
501 /* nullptr ciphertext */
502 status = gsec_aead_crypter_encrypt(crypter, nonce, nonce_length, aad,
503 aad_length, message, message_length,
504 nullptr, ciphertext_and_tag_length,
505 &ciphertext_bytes_written, &error_message);
506 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
507 status, GRPC_STATUS_INVALID_ARGUMENT, error_message,
508 "ciphertext is nullptr."));
509 gpr_free(error_message);
510
511 /* Short ciphertext */
512 status = gsec_aead_crypter_encrypt(
513 crypter, nonce, nonce_length, aad, aad_length, message, message_length,
514 ciphertext_and_tag, ciphertext_and_tag_length - 1,
515 &ciphertext_bytes_written, &error_message);
516 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
517 status, GRPC_STATUS_INVALID_ARGUMENT, error_message,
518 "ciphertext is too small to hold a tag."));
519 gpr_free(error_message);
520
521 /* nullptr ciphertext_bytes_written */
522 status = gsec_aead_crypter_encrypt(
523 crypter, nonce, nonce_length, aad, aad_length, message, message_length,
524 ciphertext_and_tag, ciphertext_and_tag_length, nullptr, &error_message);
525 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
526 status, GRPC_STATUS_INVALID_ARGUMENT, error_message,
527 "bytes_written is nullptr."));
528 gpr_free(error_message);
529
530 /* nullptr plaintext/ciphertext encrypt with zero length */
531 gsec_assert_ok(gsec_aead_crypter_encrypt(
532 crypter, nonce, nonce_length, aad, aad_length, nullptr, 0,
533 ciphertext_and_tag, ciphertext_and_tag_length,
534 &ciphertext_bytes_written, &error_message),
535 error_message);
536
537 /* Success */
538 status = gsec_aead_crypter_encrypt(
539 crypter, nonce, nonce_length, aad, aad_length, message, message_length,
540 ciphertext_and_tag, ciphertext_and_tag_length, &ciphertext_bytes_written,
541 &error_message);
542 ASSERT_EQ(status, GRPC_STATUS_OK);
543
544 gpr_free(message);
545 gpr_free(aad);
546 gpr_free(nonce);
547 gpr_free(ciphertext_and_tag);
548 }
549
550 static void gsec_test_decryption_failure(gsec_aead_crypter* crypter) {
551 ASSERT_NE(crypter, nullptr);
552 size_t aad_length = kTestMaxLength;
553 size_t message_length = kTestMaxLength;
554 size_t nonce_length, tag_length;
555 uint8_t *nonce, *aad, *message;
556
557 gsec_aead_crypter_nonce_length(crypter, &nonce_length, nullptr);
558 gsec_aead_crypter_tag_length(crypter, &tag_length, nullptr);
559 gsec_test_random_array(&nonce, nonce_length);
560 gsec_test_random_array(&aad, aad_length);
561 gsec_test_random_array(&message, message_length);
562
563 /* Test encryption */
564 size_t ciphertext_and_tag_length, ciphertext_bytes_written = 0;
565 gsec_aead_crypter_max_ciphertext_and_tag_length(
566 crypter, message_length, &ciphertext_and_tag_length, nullptr);
567 uint8_t* ciphertext_and_tag =
568 static_cast<uint8_t*>(gpr_malloc(ciphertext_and_tag_length));
569
570 grpc_status_code status = gsec_aead_crypter_encrypt(
571 crypter, nonce, nonce_length, aad, aad_length, message, message_length,
572 ciphertext_and_tag, ciphertext_and_tag_length, &ciphertext_bytes_written,
573 nullptr);
574 ASSERT_EQ(status, GRPC_STATUS_OK);
575 ASSERT_EQ(ciphertext_bytes_written, ciphertext_and_tag_length);
576
577 size_t plaintext_length, plaintext_bytes_written = 0;
578 gsec_aead_crypter_max_plaintext_length(crypter, ciphertext_bytes_written,
579 &plaintext_length, nullptr);
580 uint8_t* plaintext = static_cast<uint8_t*>(gpr_malloc(plaintext_length));
581
582 char* error_message;
583 /* nullptr nonce */
584 status = gsec_aead_crypter_decrypt(
585 crypter, nullptr, nonce_length, aad, aad_length, ciphertext_and_tag,
586 ciphertext_and_tag_length, plaintext, plaintext_length,
587 &plaintext_bytes_written, &error_message);
588 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
589 status, GRPC_STATUS_INVALID_ARGUMENT, error_message,
590 "Nonce buffer is nullptr."));
591 gpr_free(error_message);
592
593 /* Big nonce */
594 status = gsec_aead_crypter_decrypt(
595 crypter, nonce, nonce_length + 1, aad, aad_length, ciphertext_and_tag,
596 ciphertext_and_tag_length, plaintext, plaintext_length,
597 &plaintext_bytes_written, &error_message);
598 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
599 status, GRPC_STATUS_INVALID_ARGUMENT, error_message,
600 "Nonce buffer has the wrong length."));
601 gpr_free(error_message);
602
603 /* Small nonce */
604 status = gsec_aead_crypter_decrypt(
605 crypter, nonce, nonce_length - 1, aad, aad_length, ciphertext_and_tag,
606 ciphertext_and_tag_length, plaintext, plaintext_length,
607 &plaintext_bytes_written, &error_message);
608 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
609 status, GRPC_STATUS_INVALID_ARGUMENT, error_message,
610 "Nonce buffer has the wrong length."));
611 gpr_free(error_message);
612
613 /* nullptr aad */
614 status = gsec_aead_crypter_decrypt(
615 crypter, nonce, nonce_length, nullptr, aad_length, ciphertext_and_tag,
616 ciphertext_and_tag_length, plaintext, plaintext_length,
617 &plaintext_bytes_written, &error_message);
618 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
619 status, GRPC_STATUS_INVALID_ARGUMENT, error_message, "aad is nullptr."));
620 gpr_free(error_message);
621
622 /* nullptr aad with zero length */
623 status = gsec_aead_crypter_encrypt(
624 crypter, nonce, nonce_length, nullptr, 0, message, message_length,
625 ciphertext_and_tag, ciphertext_and_tag_length, &ciphertext_bytes_written,
626 &error_message);
627 ASSERT_EQ(status, GRPC_STATUS_OK);
628
629 status = gsec_aead_crypter_decrypt(
630 crypter, nonce, nonce_length, nullptr, 0, ciphertext_and_tag,
631 ciphertext_and_tag_length, plaintext, plaintext_length,
632 &plaintext_bytes_written, &error_message);
633 ASSERT_EQ(status, GRPC_STATUS_OK);
634
635 /* Small ciphertext */
636 if (tag_length > 0) {
637 status = gsec_aead_crypter_decrypt(
638 crypter, nonce, nonce_length, aad, aad_length, ciphertext_and_tag,
639 tag_length - 1, plaintext, plaintext_length, &plaintext_bytes_written,
640 &error_message);
641
642 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
643 status, GRPC_STATUS_INVALID_ARGUMENT, error_message,
644 "ciphertext is too small to hold a tag."));
645 gpr_free(error_message);
646 }
647
648 /* nullptr ciphertext */
649 status = gsec_aead_crypter_decrypt(
650 crypter, nonce, nonce_length, aad, aad_length, nullptr,
651 ciphertext_and_tag_length, plaintext, plaintext_length,
652 &plaintext_bytes_written, &error_message);
653
654 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
655 status, GRPC_STATUS_INVALID_ARGUMENT, error_message,
656 "ciphertext is nullptr."));
657 gpr_free(error_message);
658
659 /* nullptr plaintext */
660 status = gsec_aead_crypter_decrypt(
661 crypter, nonce, nonce_length, aad, aad_length, ciphertext_and_tag,
662 ciphertext_and_tag_length, nullptr, plaintext_length,
663 &plaintext_bytes_written, &error_message);
664
665 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
666 status, GRPC_STATUS_INVALID_ARGUMENT, error_message,
667 "plaintext is nullptr, but plaintext_length is positive."));
668 gpr_free(error_message);
669
670 /* Short plaintext */
671 status = gsec_aead_crypter_decrypt(
672 crypter, nonce, nonce_length, aad, aad_length, ciphertext_and_tag,
673 ciphertext_and_tag_length, plaintext, plaintext_length - 1,
674 &plaintext_bytes_written, &error_message);
675
676 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
677 status, GRPC_STATUS_INVALID_ARGUMENT, error_message,
678 "Not enough plaintext buffer to hold encrypted ciphertext."));
679 gpr_free(error_message);
680
681 /* nullptr plaintext_bytes_written */
682 status = gsec_aead_crypter_decrypt(crypter, nonce, nonce_length, aad,
683 aad_length, ciphertext_and_tag,
684 ciphertext_and_tag_length, plaintext,
685 plaintext_length, nullptr, &error_message);
686
687 ASSERT_TRUE(gsec_test_expect_compare_code_and_substr(
688 status, GRPC_STATUS_INVALID_ARGUMENT, error_message,
689 "bytes_written is nullptr."));
690 gpr_free(error_message);
691
692 gpr_free(message);
693 gpr_free(plaintext);
694 gpr_free(ciphertext_and_tag);
695 gpr_free(aad);
696 gpr_free(nonce);
697 }
698
699 static void gsec_test_encrypt_decrypt_test_vector(
700 gsec_aead_crypter* crypter, gsec_aead_test_vector* test_vector) {
701 ASSERT_NE(crypter, nullptr);
702 /* Test byte-based encryption interface. */
703 size_t ciphertext_and_tag_length, ciphertext_bytes_written = 0;
704 gsec_aead_crypter_max_ciphertext_and_tag_length(
705 crypter, test_vector->plaintext_length, &ciphertext_and_tag_length,
706 nullptr);
707 uint8_t* ciphertext_and_tag_bytes =
708 static_cast<uint8_t*>(gpr_malloc(ciphertext_and_tag_length));
709 grpc_status_code status = gsec_aead_crypter_encrypt(
710 crypter, test_vector->nonce, test_vector->nonce_length, test_vector->aad,
711 test_vector->aad_length, test_vector->plaintext,
712 test_vector->plaintext_length, ciphertext_and_tag_bytes,
713 ciphertext_and_tag_length, &ciphertext_bytes_written, nullptr);
714
715 ASSERT_EQ(status, GRPC_STATUS_OK);
716 ASSERT_EQ(ciphertext_bytes_written, ciphertext_and_tag_length);
717 ASSERT_EQ(memcmp(test_vector->ciphertext_and_tag, ciphertext_and_tag_bytes,
718 ciphertext_and_tag_length),
719 0);
720
721 /* Test byte-based decryption interface */
722 size_t plaintext_length, plaintext_bytes_written = 0;
723 gsec_aead_crypter_max_plaintext_length(crypter, ciphertext_and_tag_length,
724 &plaintext_length, nullptr);
725 uint8_t* plaintext_bytes =
726 static_cast<uint8_t*>(gpr_malloc(plaintext_length));
727 status = gsec_aead_crypter_decrypt(
728 crypter, test_vector->nonce, test_vector->nonce_length, test_vector->aad,
729 test_vector->aad_length, test_vector->ciphertext_and_tag,
730 test_vector->ciphertext_and_tag_length, plaintext_bytes, plaintext_length,
731 &plaintext_bytes_written, nullptr);
732 ASSERT_EQ(status, GRPC_STATUS_OK);
733 if (plaintext_bytes_written != 0) {
734 ASSERT_EQ(memcmp(test_vector->plaintext, plaintext_bytes,
735 plaintext_bytes_written),
736 0);
737 }
738
739 gpr_free(ciphertext_and_tag_bytes);
740 gpr_free(plaintext_bytes);
741 }
742
743 static void gsec_test_get_crypter_from_test_vector(
744 gsec_aead_crypter** crypter, gsec_aead_test_vector* test_vector,
745 bool rekey = false) {
746 size_t key_length = test_vector->key_length;
747 ASSERT_TRUE(key_length == kAes128GcmKeyLength ||
748 key_length == kAes256GcmKeyLength ||
749 key_length == kAes128GcmRekeyKeyLength);
750 size_t nonce_length = test_vector->nonce_length;
751 ASSERT_EQ(nonce_length, kAesGcmNonceLength);
752 size_t plaintext_length = test_vector->plaintext_length;
753 size_t ciphertext_and_tag_length = test_vector->ciphertext_and_tag_length;
754 ASSERT_EQ(ciphertext_and_tag_length, plaintext_length + kAesGcmTagLength);
755 size_t tag_length = ciphertext_and_tag_length - plaintext_length;
756 gsec_aes_gcm_aead_crypter_create(test_vector->key, key_length, nonce_length,
757 tag_length, rekey, crypter, nullptr);
758 }
759
760 static void gsec_test_verify_crypter_on_test_vector(
761 gsec_aead_test_vector* test_vector, bool rekey = false) {
762 gsec_aead_crypter* crypter;
763 gsec_test_get_crypter_from_test_vector(&crypter, test_vector, rekey);
764 gsec_test_encrypt_decrypt_test_vector(crypter, test_vector);
765 gsec_aead_crypter_destroy(crypter);
766 }
767
768 static void gsec_aead_malloc_test_vector(
769 gsec_aead_test_vector** test_vector, const uint8_t* key, size_t key_length,
770 const uint8_t* nonce, size_t nonce_length, const uint8_t* aad,
771 size_t aad_length, const uint8_t* plaintext, size_t plaintext_length,
772 const uint8_t* ciphertext_and_tag, size_t ciphertext_and_tag_length) {
773 *test_vector = static_cast<gsec_aead_test_vector*>(
774 gpr_malloc(sizeof(gsec_aead_test_vector)));
775 (*test_vector)->key_length = key_length;
776 (*test_vector)->nonce_length = nonce_length;
777 (*test_vector)->aad_length = aad_length;
778 (*test_vector)->plaintext_length = plaintext_length;
779 (*test_vector)->ciphertext_and_tag_length = ciphertext_and_tag_length;
780 gsec_test_copy(key, &((*test_vector)->key), key_length);
781 gsec_test_copy(nonce, &((*test_vector)->nonce), nonce_length);
782 gsec_test_copy(aad, &((*test_vector)->aad), aad_length);
783 gsec_test_copy(plaintext, &((*test_vector)->plaintext), plaintext_length);
784 gsec_test_copy(ciphertext_and_tag, &((*test_vector)->ciphertext_and_tag),
785 ciphertext_and_tag_length);
786 }
787
788 static void gsec_aead_free_test_vector(gsec_aead_test_vector* test_vector) {
789 gpr_free(test_vector->key);
790 gpr_free(test_vector->nonce);
791 gpr_free(test_vector->aad);
792 gpr_free(test_vector->plaintext);
793 gpr_free(test_vector->ciphertext_and_tag);
794 gpr_free(test_vector);
795 }
796
797 static void gsec_test_create_random_aes_gcm_crypter(gsec_aead_crypter** crypter,
798 size_t key_length,
799 size_t nonce_length,
800 size_t tag_length,
801 bool rekey) {
802 uint8_t* key;
803 gsec_test_random_array(&key, key_length);
804 gsec_aes_gcm_aead_crypter_create(key, key_length, nonce_length, tag_length,
805 rekey, crypter, nullptr);
806 gpr_free(key);
807 }
808
809 static void gsec_test_get_random_aes_gcm_crypters(
810 gsec_aead_crypter*** crypters) {
811 *crypters = static_cast<gsec_aead_crypter**>(
812 gpr_malloc(sizeof(gsec_aead_crypter*) * kTestNumCrypters));
813 gsec_test_create_random_aes_gcm_crypter(
814 &((*crypters)[0]), kAes128GcmKeyLength, kAesGcmNonceLength,
815 kAesGcmTagLength, /*rekey=*/false);
816 gsec_test_create_random_aes_gcm_crypter(
817 &((*crypters)[1]), kAes256GcmKeyLength, kAesGcmNonceLength,
818 kAesGcmTagLength, /*rekey=*/false);
819 gsec_test_create_random_aes_gcm_crypter(
820 &((*crypters)[2]), kAes128GcmRekeyKeyLength, kAesGcmNonceLength,
821 kAesGcmTagLength, /*rekey=*/true);
822 }
823
824 TEST(AltsCryptTest, GsecTestDoGenericCrypterTests) {
825 gsec_aead_crypter** crypters;
826 gsec_test_get_random_aes_gcm_crypters(&crypters);
827 size_t ind;
828 for (ind = 0; ind < kTestNumCrypters; ind++) {
829 gsec_test_encrypt_decrypt(crypters[ind]);
830 gsec_test_multiple_encrypt_decrypt(crypters[ind]);
831 gsec_test_encryption_failure(crypters[ind]);
832 gsec_test_decryption_failure(crypters[ind]);
833 }
834 for (ind = 0; ind < kTestNumCrypters; ind++) {
835 gsec_aead_crypter_destroy(crypters[ind]);
836 }
837 gpr_free(crypters);
838 }
839
840 TEST(AltsCryptTest, GsecTestDoVectorTestsRekeyNist) {
841 // NIST vectors from:
842 // http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf
843 //
844 // IEEE vectors from:
845 // http://www.ieee802.org/1/files/public/docs2011/bn-randall-test-vectors-0511-v1.pdf
846 //
847 // Key expanded by setting expandedKey = (key||(key ^ {0x01, .., 0x01})||key ^
848 // {0x02,..,0x02}))[0:44].
849
850 gsec_aead_test_vector vec;
851
852 // Derived from NIST test vector 1
853 uint8_t nonce_0[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
854 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
855 uint8_t aad_0[1] = {};
856 uint8_t key_0[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
857 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1,
858 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x2,
859 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2};
860 uint8_t plaintext_0[1] = {};
861 uint8_t ciphertext_0[] = {0x85, 0xE8, 0x73, 0xE0, 0x2, 0xF6, 0xEB, 0xDC,
862 0x40, 0x60, 0x95, 0x4E, 0xB8, 0x67, 0x55, 0x8};
863 vec = {nonce_0, aad_0, key_0, plaintext_0, ciphertext_0, 12, 0, 44, 0, 16};
864 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
865
866 // Derived from NIST test vector 2
867 uint8_t nonce_1[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
868 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
869 uint8_t aad_1[1] = {};
870 uint8_t key_1[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
871 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1,
872 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x2,
873 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2};
874 uint8_t plaintext_1[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
875 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
876 uint8_t ciphertext_1[] = {0x51, 0xE9, 0xA8, 0xCB, 0x23, 0xCA, 0x25, 0x12,
877 0xC8, 0x25, 0x6A, 0xFF, 0xF8, 0xE7, 0x2D, 0x68,
878 0x1A, 0xCA, 0x19, 0xA1, 0x14, 0x8A, 0xC1, 0x15,
879 0xE8, 0x3D, 0xF4, 0x88, 0x8C, 0xC0, 0xD, 0x11};
880 vec = {nonce_1, aad_1, key_1, plaintext_1, ciphertext_1, 12, 0, 44, 16, 32};
881 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
882
883 // Derived from NIST test vector 3
884 uint8_t nonce_2[] = {0xCA, 0xFE, 0xBA, 0xBE, 0xFA, 0xCE,
885 0xDB, 0xAD, 0xDE, 0xCA, 0xF8, 0x88};
886 uint8_t aad_2[1] = {};
887 uint8_t key_2[] = {0xFE, 0xFF, 0xE9, 0x92, 0x86, 0x65, 0x73, 0x1C, 0x6D,
888 0x6A, 0x8F, 0x94, 0x67, 0x30, 0x83, 0x8, 0xFF, 0xFE,
889 0xE8, 0x93, 0x87, 0x64, 0x72, 0x1D, 0x6C, 0x6B, 0x8E,
890 0x95, 0x66, 0x31, 0x82, 0x9, 0xFC, 0xFD, 0xEB, 0x90,
891 0x84, 0x67, 0x71, 0x1E, 0x6F, 0x68, 0x8D, 0x96};
892 uint8_t plaintext_2[] = {
893 0xD9, 0x31, 0x32, 0x25, 0xF8, 0x84, 0x6, 0xE5, 0xA5, 0x59, 0x9,
894 0xC5, 0xAF, 0xF5, 0x26, 0x9A, 0x86, 0xA7, 0xA9, 0x53, 0x15, 0x34,
895 0xF7, 0xDA, 0x2E, 0x4C, 0x30, 0x3D, 0x8A, 0x31, 0x8A, 0x72, 0x1C,
896 0x3C, 0xC, 0x95, 0x95, 0x68, 0x9, 0x53, 0x2F, 0xCF, 0xE, 0x24,
897 0x49, 0xA6, 0xB5, 0x25, 0xB1, 0x6A, 0xED, 0xF5, 0xAA, 0xD, 0xE6,
898 0x57, 0xBA, 0x63, 0x7B, 0x39, 0x1A, 0xAF, 0xD2, 0x55};
899 uint8_t ciphertext_2[] = {
900 0x10, 0x18, 0xED, 0x5A, 0x14, 0x2, 0xA8, 0x65, 0x16, 0xD6, 0x57, 0x6D,
901 0x70, 0xB2, 0xFF, 0xCC, 0xCA, 0x26, 0x1B, 0x94, 0xDF, 0x88, 0xB5, 0x8F,
902 0x53, 0xB6, 0x4D, 0xFB, 0xA4, 0x35, 0xD1, 0x8B, 0x2F, 0x6E, 0x3B, 0x78,
903 0x69, 0xF9, 0x35, 0x3D, 0x4A, 0xC8, 0xCF, 0x9, 0xAF, 0xB1, 0x66, 0x3D,
904 0xAA, 0x7B, 0x40, 0x17, 0xE6, 0xFC, 0x2C, 0x17, 0x7C, 0xC, 0x8, 0x7C,
905 0xD, 0xF1, 0x16, 0x21, 0x29, 0x95, 0x22, 0x13, 0xCE, 0xE1, 0xBC, 0x6E,
906 0x9C, 0x84, 0x95, 0xDD, 0x70, 0x5E, 0x1F, 0x3D};
907 vec = {nonce_2, aad_2, key_2, plaintext_2, ciphertext_2, 12, 0, 44, 64, 80};
908 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
909
910 // Derived from NIST test vector 4
911 uint8_t nonce_3[] = {0xCA, 0xFE, 0xBA, 0xBE, 0xFA, 0xCE,
912 0xDB, 0xAD, 0xDE, 0xCA, 0xF8, 0x88};
913 uint8_t aad_3[] = {0xFE, 0xED, 0xFA, 0xCE, 0xDE, 0xAD, 0xBE,
914 0xEF, 0xFE, 0xED, 0xFA, 0xCE, 0xDE, 0xAD,
915 0xBE, 0xEF, 0xAB, 0xAD, 0xDA, 0xD2};
916 uint8_t key_3[] = {0xFE, 0xFF, 0xE9, 0x92, 0x86, 0x65, 0x73, 0x1C, 0x6D,
917 0x6A, 0x8F, 0x94, 0x67, 0x30, 0x83, 0x8, 0xFF, 0xFE,
918 0xE8, 0x93, 0x87, 0x64, 0x72, 0x1D, 0x6C, 0x6B, 0x8E,
919 0x95, 0x66, 0x31, 0x82, 0x9, 0xFC, 0xFD, 0xEB, 0x90,
920 0x84, 0x67, 0x71, 0x1E, 0x6F, 0x68, 0x8D, 0x96};
921 uint8_t plaintext_3[] = {
922 0xD9, 0x31, 0x32, 0x25, 0xF8, 0x84, 0x6, 0xE5, 0xA5, 0x59, 0x9, 0xC5,
923 0xAF, 0xF5, 0x26, 0x9A, 0x86, 0xA7, 0xA9, 0x53, 0x15, 0x34, 0xF7, 0xDA,
924 0x2E, 0x4C, 0x30, 0x3D, 0x8A, 0x31, 0x8A, 0x72, 0x1C, 0x3C, 0xC, 0x95,
925 0x95, 0x68, 0x9, 0x53, 0x2F, 0xCF, 0xE, 0x24, 0x49, 0xA6, 0xB5, 0x25,
926 0xB1, 0x6A, 0xED, 0xF5, 0xAA, 0xD, 0xE6, 0x57, 0xBA, 0x63, 0x7B, 0x39};
927 uint8_t ciphertext_3[] = {
928 0x10, 0x18, 0xED, 0x5A, 0x14, 0x2, 0xA8, 0x65, 0x16, 0xD6, 0x57,
929 0x6D, 0x70, 0xB2, 0xFF, 0xCC, 0xCA, 0x26, 0x1B, 0x94, 0xDF, 0x88,
930 0xB5, 0x8F, 0x53, 0xB6, 0x4D, 0xFB, 0xA4, 0x35, 0xD1, 0x8B, 0x2F,
931 0x6E, 0x3B, 0x78, 0x69, 0xF9, 0x35, 0x3D, 0x4A, 0xC8, 0xCF, 0x9,
932 0xAF, 0xB1, 0x66, 0x3D, 0xAA, 0x7B, 0x40, 0x17, 0xE6, 0xFC, 0x2C,
933 0x17, 0x7C, 0xC, 0x8, 0x7C, 0x47, 0x64, 0x56, 0x5D, 0x7, 0x7E,
934 0x91, 0x24, 0x0, 0x1D, 0xDB, 0x27, 0xFC, 0x8, 0x48, 0xC5};
935 vec = {nonce_3, aad_3, key_3, plaintext_3, ciphertext_3, 12, 20, 44, 60, 76};
936 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
937
938 // Derived from adapted NIST test vector 4 for KDF counter boundary (flip
939 // nonce bit 15)
940 uint8_t nonce_4[] = {0xCA, 0x7E, 0xBA, 0xBE, 0xFA, 0xCE,
941 0xDB, 0xAD, 0xDE, 0xCA, 0xF8, 0x88};
942 uint8_t aad_4[] = {0xFE, 0xED, 0xFA, 0xCE, 0xDE, 0xAD, 0xBE,
943 0xEF, 0xFE, 0xED, 0xFA, 0xCE, 0xDE, 0xAD,
944 0xBE, 0xEF, 0xAB, 0xAD, 0xDA, 0xD2};
945 uint8_t key_4[] = {0xFE, 0xFF, 0xE9, 0x92, 0x86, 0x65, 0x73, 0x1C, 0x6D,
946 0x6A, 0x8F, 0x94, 0x67, 0x30, 0x83, 0x8, 0xFF, 0xFE,
947 0xE8, 0x93, 0x87, 0x64, 0x72, 0x1D, 0x6C, 0x6B, 0x8E,
948 0x95, 0x66, 0x31, 0x82, 0x9, 0xFC, 0xFD, 0xEB, 0x90,
949 0x84, 0x67, 0x71, 0x1E, 0x6F, 0x68, 0x8D, 0x96};
950 uint8_t plaintext_4[] = {
951 0xD9, 0x31, 0x32, 0x25, 0xF8, 0x84, 0x6, 0xE5, 0xA5, 0x59, 0x9, 0xC5,
952 0xAF, 0xF5, 0x26, 0x9A, 0x86, 0xA7, 0xA9, 0x53, 0x15, 0x34, 0xF7, 0xDA,
953 0x2E, 0x4C, 0x30, 0x3D, 0x8A, 0x31, 0x8A, 0x72, 0x1C, 0x3C, 0xC, 0x95,
954 0x95, 0x68, 0x9, 0x53, 0x2F, 0xCF, 0xE, 0x24, 0x49, 0xA6, 0xB5, 0x25,
955 0xB1, 0x6A, 0xED, 0xF5, 0xAA, 0xD, 0xE6, 0x57, 0xBA, 0x63, 0x7B, 0x39};
956 uint8_t ciphertext_4[] = {
957 0xE6, 0x50, 0xD3, 0xC0, 0xFB, 0x87, 0x93, 0x27, 0xF2, 0xD0, 0x32,
958 0x87, 0xFA, 0x93, 0xCD, 0x7, 0x34, 0x2B, 0x13, 0x62, 0x15, 0xAD,
959 0xBC, 0xA0, 0xC, 0x3B, 0xD5, 0x9, 0x9E, 0xC4, 0x18, 0x32, 0xB1,
960 0xD1, 0x8E, 0x4, 0x23, 0xED, 0x26, 0xBB, 0x12, 0xC6, 0xCD, 0x9,
961 0xDE, 0xBB, 0x29, 0x23, 0xA, 0x94, 0xC0, 0xCE, 0xE1, 0x59, 0x3,
962 0x65, 0x6F, 0x85, 0xED, 0xB6, 0xFC, 0x50, 0x9B, 0x1B, 0x28, 0x21,
963 0x63, 0x82, 0x17, 0x2E, 0xCB, 0xCC, 0x31, 0xE1, 0xE9, 0xB1};
964 vec = {nonce_4, aad_4, key_4, plaintext_4, ciphertext_4, 12, 20, 44, 60, 76};
965 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
966
967 // Derived from adapted NIST test vector 4 for KDF counter boundary (flip
968 // nonce bit 16)
969 uint8_t nonce_5[] = {0xCA, 0xFE, 0xBB, 0xBE, 0xFA, 0xCE,
970 0xDB, 0xAD, 0xDE, 0xCA, 0xF8, 0x88};
971 uint8_t aad_5[] = {0xFE, 0xED, 0xFA, 0xCE, 0xDE, 0xAD, 0xBE,
972 0xEF, 0xFE, 0xED, 0xFA, 0xCE, 0xDE, 0xAD,
973 0xBE, 0xEF, 0xAB, 0xAD, 0xDA, 0xD2};
974 uint8_t key_5[] = {0xFE, 0xFF, 0xE9, 0x92, 0x86, 0x65, 0x73, 0x1C, 0x6D,
975 0x6A, 0x8F, 0x94, 0x67, 0x30, 0x83, 0x8, 0xFF, 0xFE,
976 0xE8, 0x93, 0x87, 0x64, 0x72, 0x1D, 0x6C, 0x6B, 0x8E,
977 0x95, 0x66, 0x31, 0x82, 0x9, 0xFC, 0xFD, 0xEB, 0x90,
978 0x84, 0x67, 0x71, 0x1E, 0x6F, 0x68, 0x8D, 0x96};
979 uint8_t plaintext_5[] = {
980 0xD9, 0x31, 0x32, 0x25, 0xF8, 0x84, 0x6, 0xE5, 0xA5, 0x59, 0x9, 0xC5,
981 0xAF, 0xF5, 0x26, 0x9A, 0x86, 0xA7, 0xA9, 0x53, 0x15, 0x34, 0xF7, 0xDA,
982 0x2E, 0x4C, 0x30, 0x3D, 0x8A, 0x31, 0x8A, 0x72, 0x1C, 0x3C, 0xC, 0x95,
983 0x95, 0x68, 0x9, 0x53, 0x2F, 0xCF, 0xE, 0x24, 0x49, 0xA6, 0xB5, 0x25,
984 0xB1, 0x6A, 0xED, 0xF5, 0xAA, 0xD, 0xE6, 0x57, 0xBA, 0x63, 0x7B, 0x39};
985 uint8_t ciphertext_5[] = {
986 0xC0, 0x12, 0x1E, 0x6C, 0x95, 0x4D, 0x7, 0x67, 0xF9, 0x66, 0x30,
987 0xC3, 0x34, 0x50, 0x99, 0x97, 0x91, 0xB2, 0xDA, 0x2A, 0xD0, 0x5C,
988 0x41, 0x90, 0x16, 0x9C, 0xCA, 0xD9, 0xAC, 0x86, 0xFF, 0x1C, 0x72,
989 0x1E, 0x3D, 0x82, 0xF2, 0xAD, 0x22, 0xAB, 0x46, 0x3B, 0xAB, 0x4A,
990 0x7, 0x54, 0xB7, 0xDD, 0x68, 0xCA, 0x4D, 0xE7, 0xEA, 0x25, 0x31,
991 0xB6, 0x25, 0xED, 0xA0, 0x1F, 0x89, 0x31, 0x2B, 0x2A, 0xB9, 0x57,
992 0xD5, 0xC7, 0xF8, 0x56, 0x8D, 0xD9, 0x5F, 0xCD, 0xCD, 0x1F};
993 vec = {nonce_5, aad_5, key_5, plaintext_5, ciphertext_5, 12, 20, 44, 60, 76};
994 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
995
996 // Derived from adapted NIST test vector 4 for KDF counter boundary (flip
997 // nonce bit 63)
998 uint8_t nonce_6[] = {0xCA, 0xFE, 0xBA, 0xBE, 0xFA, 0xCE,
999 0xDB, 0x2D, 0xDE, 0xCA, 0xF8, 0x88};
1000 uint8_t aad_6[] = {0xFE, 0xED, 0xFA, 0xCE, 0xDE, 0xAD, 0xBE,
1001 0xEF, 0xFE, 0xED, 0xFA, 0xCE, 0xDE, 0xAD,
1002 0xBE, 0xEF, 0xAB, 0xAD, 0xDA, 0xD2};
1003 uint8_t key_6[] = {0xFE, 0xFF, 0xE9, 0x92, 0x86, 0x65, 0x73, 0x1C, 0x6D,
1004 0x6A, 0x8F, 0x94, 0x67, 0x30, 0x83, 0x8, 0xFF, 0xFE,
1005 0xE8, 0x93, 0x87, 0x64, 0x72, 0x1D, 0x6C, 0x6B, 0x8E,
1006 0x95, 0x66, 0x31, 0x82, 0x9, 0xFC, 0xFD, 0xEB, 0x90,
1007 0x84, 0x67, 0x71, 0x1E, 0x6F, 0x68, 0x8D, 0x96};
1008 uint8_t plaintext_6[] = {
1009 0xD9, 0x31, 0x32, 0x25, 0xF8, 0x84, 0x6, 0xE5, 0xA5, 0x59, 0x9, 0xC5,
1010 0xAF, 0xF5, 0x26, 0x9A, 0x86, 0xA7, 0xA9, 0x53, 0x15, 0x34, 0xF7, 0xDA,
1011 0x2E, 0x4C, 0x30, 0x3D, 0x8A, 0x31, 0x8A, 0x72, 0x1C, 0x3C, 0xC, 0x95,
1012 0x95, 0x68, 0x9, 0x53, 0x2F, 0xCF, 0xE, 0x24, 0x49, 0xA6, 0xB5, 0x25,
1013 0xB1, 0x6A, 0xED, 0xF5, 0xAA, 0xD, 0xE6, 0x57, 0xBA, 0x63, 0x7B, 0x39};
1014 uint8_t ciphertext_6[] = {
1015 0x8A, 0xF3, 0x7E, 0xA5, 0x68, 0x4A, 0x4D, 0x81, 0xD4, 0xFD, 0x81,
1016 0x72, 0x61, 0xFD, 0x97, 0x43, 0x9, 0x9E, 0x7E, 0x6A, 0x2, 0x5E,
1017 0xAA, 0xCF, 0x8E, 0x54, 0xB1, 0x24, 0xFB, 0x57, 0x43, 0x14, 0x9E,
1018 0x5, 0xCB, 0x89, 0xF4, 0xA4, 0x94, 0x67, 0xFE, 0x2E, 0x5E, 0x59,
1019 0x65, 0xF2, 0x9A, 0x19, 0xF9, 0x94, 0x16, 0xB0, 0x1, 0x6B, 0x54,
1020 0x58, 0x5D, 0x12, 0x55, 0x37, 0x83, 0xBA, 0x59, 0xE9, 0xF7, 0x82,
1021 0xE8, 0x2E, 0x9, 0x7C, 0x33, 0x6B, 0xF7, 0x98, 0x9F, 0x8};
1022 vec = {nonce_6, aad_6, key_6, plaintext_6, ciphertext_6, 12, 20, 44, 60, 76};
1023 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1024
1025 // Derived from adapted NIST test vector 4 for KDF counter boundary (flip
1026 // nonce bit 64)
1027 uint8_t nonce_7[] = {0xCA, 0xFE, 0xBA, 0xBE, 0xFA, 0xCE,
1028 0xDB, 0xAD, 0xDF, 0xCA, 0xF8, 0x88};
1029 uint8_t aad_7[] = {0xFE, 0xED, 0xFA, 0xCE, 0xDE, 0xAD, 0xBE,
1030 0xEF, 0xFE, 0xED, 0xFA, 0xCE, 0xDE, 0xAD,
1031 0xBE, 0xEF, 0xAB, 0xAD, 0xDA, 0xD2};
1032 uint8_t key_7[] = {0xFE, 0xFF, 0xE9, 0x92, 0x86, 0x65, 0x73, 0x1C, 0x6D,
1033 0x6A, 0x8F, 0x94, 0x67, 0x30, 0x83, 0x8, 0xFF, 0xFE,
1034 0xE8, 0x93, 0x87, 0x64, 0x72, 0x1D, 0x6C, 0x6B, 0x8E,
1035 0x95, 0x66, 0x31, 0x82, 0x9, 0xFC, 0xFD, 0xEB, 0x90,
1036 0x84, 0x67, 0x71, 0x1E, 0x6F, 0x68, 0x8D, 0x96};
1037 uint8_t plaintext_7[] = {
1038 0xD9, 0x31, 0x32, 0x25, 0xF8, 0x84, 0x6, 0xE5, 0xA5, 0x59, 0x9, 0xC5,
1039 0xAF, 0xF5, 0x26, 0x9A, 0x86, 0xA7, 0xA9, 0x53, 0x15, 0x34, 0xF7, 0xDA,
1040 0x2E, 0x4C, 0x30, 0x3D, 0x8A, 0x31, 0x8A, 0x72, 0x1C, 0x3C, 0xC, 0x95,
1041 0x95, 0x68, 0x9, 0x53, 0x2F, 0xCF, 0xE, 0x24, 0x49, 0xA6, 0xB5, 0x25,
1042 0xB1, 0x6A, 0xED, 0xF5, 0xAA, 0xD, 0xE6, 0x57, 0xBA, 0x63, 0x7B, 0x39};
1043 uint8_t ciphertext_7[] = {
1044 0xFB, 0xD5, 0x28, 0x44, 0x8D, 0x3, 0x46, 0xBF, 0xA8, 0x78, 0x63,
1045 0x48, 0x64, 0xD4, 0x7, 0xA3, 0x5A, 0x3, 0x9D, 0xE9, 0xDB, 0x2F,
1046 0x1F, 0xEB, 0x8E, 0x96, 0x5B, 0x3A, 0xE9, 0x35, 0x6C, 0xE6, 0x28,
1047 0x94, 0x41, 0xD7, 0x7F, 0x8F, 0xD, 0xF2, 0x94, 0x89, 0x1F, 0x37,
1048 0xEA, 0x43, 0x8B, 0x22, 0x3E, 0x3B, 0xF2, 0xBD, 0xC5, 0x3D, 0x4C,
1049 0x5A, 0x74, 0xFB, 0x68, 0xB, 0xB3, 0x12, 0xA8, 0xDE, 0xC6, 0xF7,
1050 0x25, 0x2C, 0xBC, 0xD7, 0xF5, 0x79, 0x97, 0x50, 0xAD, 0x78};
1051 vec = {nonce_7, aad_7, key_7, plaintext_7, ciphertext_7, 12, 20, 44, 60, 76};
1052 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1053 }
1054
1055 TEST(AltsCryptTest, GsecTestDoVectorTestsRekeyIeee) {
1056 // IEEE vectors from:
1057 // http://www.ieee802.org/1/files/public/docs2011/bn-randall-test-vectors-0511-v1.pdf
1058 //
1059 // Key expanded by setting expandedKey = (key||(key ^ {0x01, .., 0x01})||key ^
1060 // {0x02,..,0x02}))[0:44].
1061
1062 gsec_aead_test_vector vec;
1063
1064 // Derived from IEEE 2.1.1 54-byte auth
1065 uint8_t nonce_8[] = {0x12, 0x15, 0x35, 0x24, 0xC0, 0x89,
1066 0x5E, 0x81, 0xB2, 0xC2, 0x84, 0x65};
1067 uint8_t aad_8[] = {0xD6, 0x9, 0xB1, 0xF0, 0x56, 0x63, 0x7A, 0xD, 0x46, 0xDF,
1068 0x99, 0x8D, 0x88, 0xE5, 0x22, 0x2A, 0xB2, 0xC2, 0x84, 0x65,
1069 0x12, 0x15, 0x35, 0x24, 0xC0, 0x89, 0x5E, 0x81, 0x8, 0x0,
1070 0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
1071 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22,
1072 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C,
1073 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x0, 0x1};
1074 uint8_t key_8[] = {0xAD, 0x7A, 0x2B, 0xD0, 0x3E, 0xAC, 0x83, 0x5A, 0x6F,
1075 0x62, 0xF, 0xDC, 0xB5, 0x6, 0xB3, 0x45, 0xAC, 0x7B,
1076 0x2A, 0xD1, 0x3F, 0xAD, 0x82, 0x5B, 0x6E, 0x63, 0xE,
1077 0xDD, 0xB4, 0x7, 0xB2, 0x44, 0xAF, 0x78, 0x29, 0xD2,
1078 0x3C, 0xAE, 0x81, 0x58, 0x6D, 0x60, 0xD, 0xDE};
1079 uint8_t plaintext_8[1] = {};
1080 uint8_t ciphertext_8[] = {0x3E, 0xA0, 0xB5, 0x84, 0xF3, 0xC8, 0x5E, 0x93,
1081 0xF9, 0x32, 0xE, 0xA5, 0x91, 0x69, 0x9E, 0xFB};
1082 vec = {nonce_8, aad_8, key_8, plaintext_8, ciphertext_8, 12, 70, 44, 0, 16};
1083 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1084
1085 // Derived from IEEE 2.1.2 54-byte auth
1086 uint8_t nonce_9[] = {0x12, 0x15, 0x35, 0x24, 0xC0, 0x89,
1087 0x5E, 0x81, 0xB2, 0xC2, 0x84, 0x65};
1088 uint8_t aad_9[] = {0xD6, 0x9, 0xB1, 0xF0, 0x56, 0x63, 0x7A, 0xD, 0x46, 0xDF,
1089 0x99, 0x8D, 0x88, 0xE5, 0x22, 0x2A, 0xB2, 0xC2, 0x84, 0x65,
1090 0x12, 0x15, 0x35, 0x24, 0xC0, 0x89, 0x5E, 0x81, 0x8, 0x0,
1091 0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
1092 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22,
1093 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C,
1094 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x0, 0x1};
1095 uint8_t key_9[] = {0xE3, 0xC0, 0x8A, 0x8F, 0x6, 0xC6, 0xE3, 0xAD, 0x95,
1096 0xA7, 0x5, 0x57, 0xB2, 0x3F, 0x75, 0x48, 0x3C, 0xE3,
1097 0x30, 0x21, 0xA9, 0xC7, 0x2B, 0x70, 0x25, 0x66, 0x62,
1098 0x4, 0xC6, 0x9C, 0xB, 0x72, 0xE1, 0xC2, 0x88, 0x8D,
1099 0x4, 0xC4, 0xE1, 0xAF, 0x97, 0xA5, 0x7, 0x55};
1100 uint8_t plaintext_9[1] = {};
1101 uint8_t ciphertext_9[] = {0x29, 0x4E, 0x2, 0x8B, 0xF1, 0xFE, 0x6F, 0x14,
1102 0xC4, 0xE8, 0xF7, 0x30, 0x5C, 0x93, 0x3E, 0xB5};
1103 vec = {nonce_9, aad_9, key_9, plaintext_9, ciphertext_9, 12, 70, 44, 0, 16};
1104 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1105
1106 // Derived from IEEE 2.2.1 60-byte crypt
1107 uint8_t nonce_10[] = {0x12, 0x15, 0x35, 0x24, 0xC0, 0x89,
1108 0x5E, 0x81, 0xB2, 0xC2, 0x84, 0x65};
1109 uint8_t aad_10[] = {0xD6, 0x9, 0xB1, 0xF0, 0x56, 0x63, 0x7A,
1110 0xD, 0x46, 0xDF, 0x99, 0x8D, 0x88, 0xE5,
1111 0x2E, 0x0, 0xB2, 0xC2, 0x84, 0x65, 0x12,
1112 0x15, 0x35, 0x24, 0xC0, 0x89, 0x5E, 0x81};
1113 uint8_t key_10[] = {0xAD, 0x7A, 0x2B, 0xD0, 0x3E, 0xAC, 0x83, 0x5A, 0x6F,
1114 0x62, 0xF, 0xDC, 0xB5, 0x6, 0xB3, 0x45, 0xAC, 0x7B,
1115 0x2A, 0xD1, 0x3F, 0xAD, 0x82, 0x5B, 0x6E, 0x63, 0xE,
1116 0xDD, 0xB4, 0x7, 0xB2, 0x44, 0xAF, 0x78, 0x29, 0xD2,
1117 0x3C, 0xAE, 0x81, 0x58, 0x6D, 0x60, 0xD, 0xDE};
1118 uint8_t plaintext_10[] = {
1119 0x8, 0x0, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
1120 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24,
1121 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
1122 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x0, 0x2};
1123 uint8_t ciphertext_10[] = {
1124 0xDB, 0x3D, 0x25, 0x71, 0x9C, 0x6B, 0xA, 0x3C, 0xA6, 0x14, 0x5C,
1125 0x15, 0x9D, 0x5C, 0x6E, 0xD9, 0xAF, 0xF9, 0xC6, 0xE0, 0xB7, 0x9F,
1126 0x17, 0x1, 0x9E, 0xA9, 0x23, 0xB8, 0x66, 0x5D, 0xDF, 0x52, 0x13,
1127 0x7A, 0xD6, 0x11, 0xF0, 0xD1, 0xBF, 0x41, 0x7A, 0x7C, 0xA8, 0x5E,
1128 0x45, 0xAF, 0xE1, 0x6, 0xFF, 0x9C, 0x75, 0x69, 0xD3, 0x35, 0xD0,
1129 0x86, 0xAE, 0x6C, 0x3, 0xF0, 0x9, 0x87, 0xCC, 0xD6};
1130 vec = {nonce_10, aad_10, key_10, plaintext_10, ciphertext_10,
1131 12, 28, 44, 48, 64};
1132 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1133
1134 // Derived from IEEE 2.2.2 60-byte crypt
1135 uint8_t nonce_11[] = {0x12, 0x15, 0x35, 0x24, 0xC0, 0x89,
1136 0x5E, 0x81, 0xB2, 0xC2, 0x84, 0x65};
1137 uint8_t aad_11[] = {0xD6, 0x9, 0xB1, 0xF0, 0x56, 0x63, 0x7A,
1138 0xD, 0x46, 0xDF, 0x99, 0x8D, 0x88, 0xE5,
1139 0x2E, 0x0, 0xB2, 0xC2, 0x84, 0x65, 0x12,
1140 0x15, 0x35, 0x24, 0xC0, 0x89, 0x5E, 0x81};
1141 uint8_t key_11[] = {0xE3, 0xC0, 0x8A, 0x8F, 0x6, 0xC6, 0xE3, 0xAD, 0x95,
1142 0xA7, 0x5, 0x57, 0xB2, 0x3F, 0x75, 0x48, 0x3C, 0xE3,
1143 0x30, 0x21, 0xA9, 0xC7, 0x2B, 0x70, 0x25, 0x66, 0x62,
1144 0x4, 0xC6, 0x9C, 0xB, 0x72, 0xE1, 0xC2, 0x88, 0x8D,
1145 0x4, 0xC4, 0xE1, 0xAF, 0x97, 0xA5, 0x7, 0x55};
1146 uint8_t plaintext_11[] = {
1147 0x8, 0x0, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
1148 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24,
1149 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
1150 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x0, 0x2};
1151 uint8_t ciphertext_11[] = {
1152 0x16, 0x41, 0xF2, 0x8E, 0xC1, 0x3A, 0xFC, 0xC8, 0xF7, 0x90, 0x33,
1153 0x89, 0x78, 0x72, 0x1, 0x5, 0x16, 0x44, 0x91, 0x49, 0x33, 0xE9,
1154 0x20, 0x2B, 0xB9, 0xD0, 0x6A, 0xA0, 0x20, 0xC2, 0xA6, 0x7E, 0xF5,
1155 0x1D, 0xFE, 0x7B, 0xC0, 0xA, 0x85, 0x6C, 0x55, 0xB8, 0xF8, 0x13,
1156 0x3E, 0x77, 0xF6, 0x59, 0x13, 0x25, 0x2, 0xBA, 0xD6, 0x3F, 0x57,
1157 0x13, 0xD5, 0x7D, 0xC, 0x11, 0xE0, 0xF8, 0x71, 0xED};
1158 vec = {nonce_11, aad_11, key_11, plaintext_11, ciphertext_11,
1159 12, 28, 44, 48, 64};
1160 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1161
1162 // Derived from IEEE 2.3.1 60-byte auth
1163 uint8_t nonce_12[] = {0xF0, 0x76, 0x1E, 0x8D, 0xCD, 0x3D,
1164 0x0, 0x1, 0x76, 0xD4, 0x57, 0xED};
1165 uint8_t aad_12[] = {
1166 0xE2, 0x1, 0x6, 0xD7, 0xCD, 0xD, 0xF0, 0x76, 0x1E, 0x8D, 0xCD, 0x3D,
1167 0x88, 0xE5, 0x40, 0x0, 0x76, 0xD4, 0x57, 0xED, 0x8, 0x0, 0xF, 0x10,
1168 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C,
1169 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
1170 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34,
1171 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x0, 0x3};
1172 uint8_t key_12[] = {0x7, 0x1B, 0x11, 0x3B, 0xC, 0xA7, 0x43, 0xFE, 0xCC,
1173 0xCF, 0x3D, 0x5, 0x1F, 0x73, 0x73, 0x82, 0x6, 0x1A,
1174 0x10, 0x3A, 0xD, 0xA6, 0x42, 0xFF, 0xCD, 0xCE, 0x3C,
1175 0x4, 0x1E, 0x72, 0x72, 0x83, 0x5, 0x19, 0x13, 0x39,
1176 0xE, 0xA5, 0x41, 0xFC, 0xCE, 0xCD, 0x3F, 0x7};
1177 uint8_t plaintext_12[1] = {};
1178 uint8_t ciphertext_12[] = {0x58, 0x83, 0x7A, 0x10, 0x56, 0x2B, 0xF, 0x1F,
1179 0x8E, 0xDB, 0xE5, 0x8C, 0xA5, 0x58, 0x11, 0xD3};
1180 vec = {nonce_12, aad_12, key_12, plaintext_12, ciphertext_12, 12, 68,
1181 44, 0, 16};
1182 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1183
1184 // Derived from IEEE 2.3.2 60-byte auth
1185 uint8_t nonce_13[] = {0xF0, 0x76, 0x1E, 0x8D, 0xCD, 0x3D,
1186 0x0, 0x1, 0x76, 0xD4, 0x57, 0xED};
1187 uint8_t aad_13[] = {
1188 0xE2, 0x1, 0x6, 0xD7, 0xCD, 0xD, 0xF0, 0x76, 0x1E, 0x8D, 0xCD, 0x3D,
1189 0x88, 0xE5, 0x40, 0x0, 0x76, 0xD4, 0x57, 0xED, 0x8, 0x0, 0xF, 0x10,
1190 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C,
1191 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
1192 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34,
1193 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x0, 0x3};
1194 uint8_t key_13[] = {0x69, 0x1D, 0x3E, 0xE9, 0x9, 0xD7, 0xF5, 0x41, 0x67,
1195 0xFD, 0x1C, 0xA0, 0xB5, 0xD7, 0x69, 0x8, 0x1F, 0x2B,
1196 0xDE, 0x1A, 0xEE, 0x65, 0x5F, 0xDB, 0xAB, 0x80, 0xBD,
1197 0x52, 0x95, 0xAE, 0x6B, 0xE7, 0x6B, 0x1F, 0x3C, 0xEB,
1198 0xB, 0xD5, 0xF7, 0x43, 0x65, 0xFF, 0x1E, 0xA2};
1199 uint8_t plaintext_13[1] = {};
1200 uint8_t ciphertext_13[] = {0xC2, 0x72, 0x2F, 0xF6, 0xCA, 0x29, 0xA2, 0x57,
1201 0x71, 0x8A, 0x52, 0x9D, 0x1F, 0xC, 0x6A, 0x3B};
1202 vec = {nonce_13, aad_13, key_13, plaintext_13, ciphertext_13, 12, 68,
1203 44, 0, 16};
1204 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1205
1206 // Derived from IEEE 2.4.1 54-byte crypt
1207 uint8_t nonce_14[] = {0xF0, 0x76, 0x1E, 0x8D, 0xCD, 0x3D,
1208 0x0, 0x1, 0x76, 0xD4, 0x57, 0xED};
1209 uint8_t aad_14[] = {0xE2, 0x1, 0x6, 0xD7, 0xCD, 0xD, 0xF0,
1210 0x76, 0x1E, 0x8D, 0xCD, 0x3D, 0x88, 0xE5,
1211 0x4C, 0x2A, 0x76, 0xD4, 0x57, 0xED};
1212 uint8_t key_14[] = {0x7, 0x1B, 0x11, 0x3B, 0xC, 0xA7, 0x43, 0xFE, 0xCC,
1213 0xCF, 0x3D, 0x5, 0x1F, 0x73, 0x73, 0x82, 0x6, 0x1A,
1214 0x10, 0x3A, 0xD, 0xA6, 0x42, 0xFF, 0xCD, 0xCE, 0x3C,
1215 0x4, 0x1E, 0x72, 0x72, 0x83, 0x5, 0x19, 0x13, 0x39,
1216 0xE, 0xA5, 0x41, 0xFC, 0xCE, 0xCD, 0x3F, 0x7};
1217 uint8_t plaintext_14[] = {
1218 0x8, 0x0, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1219 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22,
1220 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D,
1221 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x0, 0x4};
1222 uint8_t ciphertext_14[] = {
1223 0xFD, 0x96, 0xB7, 0x15, 0xB9, 0x3A, 0x13, 0x34, 0x6A, 0xF5, 0x1E, 0x8A,
1224 0xCD, 0xF7, 0x92, 0xCD, 0xC7, 0xB2, 0x68, 0x6F, 0x85, 0x74, 0xC7, 0xE,
1225 0x6B, 0xC, 0xBF, 0x16, 0x29, 0x1D, 0xED, 0x42, 0x7A, 0xD7, 0x3F, 0xEC,
1226 0x48, 0xCD, 0x29, 0x8E, 0x5, 0x28, 0xA1, 0xF4, 0xC6, 0x44, 0xA9, 0x49,
1227 0xFC, 0x31, 0xDC, 0x92, 0x79, 0x70, 0x6D, 0xDB, 0xA3, 0x3F};
1228 vec = {nonce_14, aad_14, key_14, plaintext_14, ciphertext_14,
1229 12, 20, 44, 42, 58};
1230 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1231
1232 // Derived from IEEE 2.4.2 54-byte crypt
1233 uint8_t nonce_15[] = {0xF0, 0x76, 0x1E, 0x8D, 0xCD, 0x3D,
1234 0x0, 0x1, 0x76, 0xD4, 0x57, 0xED};
1235 uint8_t aad_15[] = {0xE2, 0x1, 0x6, 0xD7, 0xCD, 0xD, 0xF0,
1236 0x76, 0x1E, 0x8D, 0xCD, 0x3D, 0x88, 0xE5,
1237 0x4C, 0x2A, 0x76, 0xD4, 0x57, 0xED};
1238 uint8_t key_15[] = {0x69, 0x1D, 0x3E, 0xE9, 0x9, 0xD7, 0xF5, 0x41, 0x67,
1239 0xFD, 0x1C, 0xA0, 0xB5, 0xD7, 0x69, 0x8, 0x1F, 0x2B,
1240 0xDE, 0x1A, 0xEE, 0x65, 0x5F, 0xDB, 0xAB, 0x80, 0xBD,
1241 0x52, 0x95, 0xAE, 0x6B, 0xE7, 0x6B, 0x1F, 0x3C, 0xEB,
1242 0xB, 0xD5, 0xF7, 0x43, 0x65, 0xFF, 0x1E, 0xA2};
1243 uint8_t plaintext_15[] = {
1244 0x8, 0x0, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1245 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22,
1246 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D,
1247 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x0, 0x4};
1248 uint8_t ciphertext_15[] = {
1249 0xB6, 0x8F, 0x63, 0x0, 0xC2, 0xE9, 0xAE, 0x83, 0x3B, 0xDC, 0x7, 0xE,
1250 0x24, 0x2, 0x1A, 0x34, 0x77, 0x11, 0x8E, 0x78, 0xCC, 0xF8, 0x4E, 0x11,
1251 0xA4, 0x85, 0xD8, 0x61, 0x47, 0x6C, 0x30, 0xF, 0x17, 0x53, 0x53, 0xD5,
1252 0xCD, 0xF9, 0x20, 0x8, 0xA4, 0xF8, 0x78, 0xE6, 0xCC, 0x35, 0x77, 0x76,
1253 0x80, 0x85, 0xC5, 0xA, 0xE, 0x98, 0xFD, 0xA6, 0xCB, 0xB8};
1254 vec = {nonce_15, aad_15, key_15, plaintext_15, ciphertext_15,
1255 12, 20, 44, 42, 58};
1256 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1257
1258 // Derived from IEEE 2.5.1 65-byte auth
1259 uint8_t nonce_16[] = {0x7C, 0xFD, 0xE9, 0xF9, 0xE3, 0x37,
1260 0x24, 0xC6, 0x89, 0x32, 0xD6, 0x12};
1261 uint8_t aad_16[] = {
1262 0x84, 0xC5, 0xD5, 0x13, 0xD2, 0xAA, 0xF6, 0xE5, 0xBB, 0xD2, 0x72, 0x77,
1263 0x88, 0xE5, 0x23, 0x0, 0x89, 0x32, 0xD6, 0x12, 0x7C, 0xFD, 0xE9, 0xF9,
1264 0xE3, 0x37, 0x24, 0xC6, 0x8, 0x0, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14,
1265 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
1266 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C,
1267 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
1268 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x0, 0x5};
1269 uint8_t key_16[] = {0x1, 0x3F, 0xE0, 0xB, 0x5F, 0x11, 0xBE, 0x7F, 0x86,
1270 0x6D, 0xC, 0xBB, 0xC5, 0x5A, 0x7A, 0x90, 0x0, 0x3E,
1271 0xE1, 0xA, 0x5E, 0x10, 0xBF, 0x7E, 0x87, 0x6C, 0xD,
1272 0xBA, 0xC4, 0x5B, 0x7B, 0x91, 0x3, 0x3D, 0xE2, 0x9,
1273 0x5D, 0x13, 0xBC, 0x7D, 0x84, 0x6F, 0xE, 0xB9};
1274 uint8_t plaintext_16[1] = {};
1275 uint8_t ciphertext_16[] = {0xCC, 0xA2, 0xE, 0xEC, 0xDA, 0x62, 0x83, 0xF0,
1276 0x9B, 0xB3, 0x54, 0x3D, 0xD9, 0x9E, 0xDB, 0x9B};
1277 vec = {nonce_16, aad_16, key_16, plaintext_16, ciphertext_16, 12, 81,
1278 44, 0, 16};
1279 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1280
1281 // Derived from IEEE 2.5.2 65-byte auth
1282 uint8_t nonce_17[] = {0x7C, 0xFD, 0xE9, 0xF9, 0xE3, 0x37,
1283 0x24, 0xC6, 0x89, 0x32, 0xD6, 0x12};
1284 uint8_t aad_17[] = {
1285 0x84, 0xC5, 0xD5, 0x13, 0xD2, 0xAA, 0xF6, 0xE5, 0xBB, 0xD2, 0x72, 0x77,
1286 0x88, 0xE5, 0x23, 0x0, 0x89, 0x32, 0xD6, 0x12, 0x7C, 0xFD, 0xE9, 0xF9,
1287 0xE3, 0x37, 0x24, 0xC6, 0x8, 0x0, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14,
1288 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
1289 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C,
1290 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
1291 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x0, 0x5};
1292 uint8_t key_17[] = {0x83, 0xC0, 0x93, 0xB5, 0x8D, 0xE7, 0xFF, 0xE1, 0xC0,
1293 0xDA, 0x92, 0x6A, 0xC4, 0x3F, 0xB3, 0x60, 0x9A, 0xC1,
1294 0xC8, 0xF, 0xEE, 0x1B, 0x62, 0x44, 0x97, 0xEF, 0x94,
1295 0x2E, 0x2F, 0x79, 0xA8, 0x23, 0x81, 0xC2, 0x91, 0xB7,
1296 0x8F, 0xE5, 0xFD, 0xE3, 0xC2, 0xD8, 0x90, 0x68};
1297 uint8_t plaintext_17[1] = {};
1298 uint8_t ciphertext_17[] = {0xB2, 0x32, 0xCC, 0x1D, 0xA5, 0x11, 0x7B, 0xF1,
1299 0x50, 0x3, 0x73, 0x4F, 0xA5, 0x99, 0xD2, 0x71};
1300 vec = {nonce_17, aad_17, key_17, plaintext_17, ciphertext_17, 12, 81,
1301 44, 0, 16};
1302 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1303
1304 // Derived from IEEE 2.6.1 61-byte crypt
1305 uint8_t nonce_18[] = {0x7C, 0xFD, 0xE9, 0xF9, 0xE3, 0x37,
1306 0x24, 0xC6, 0x89, 0x32, 0xD6, 0x12};
1307 uint8_t aad_18[] = {0x84, 0xC5, 0xD5, 0x13, 0xD2, 0xAA, 0xF6,
1308 0xE5, 0xBB, 0xD2, 0x72, 0x77, 0x88, 0xE5,
1309 0x2F, 0x0, 0x89, 0x32, 0xD6, 0x12, 0x7C,
1310 0xFD, 0xE9, 0xF9, 0xE3, 0x37, 0x24, 0xC6};
1311 uint8_t key_18[] = {0x1, 0x3F, 0xE0, 0xB, 0x5F, 0x11, 0xBE, 0x7F, 0x86,
1312 0x6D, 0xC, 0xBB, 0xC5, 0x5A, 0x7A, 0x90, 0x0, 0x3E,
1313 0xE1, 0xA, 0x5E, 0x10, 0xBF, 0x7E, 0x87, 0x6C, 0xD,
1314 0xBA, 0xC4, 0x5B, 0x7B, 0x91, 0x3, 0x3D, 0xE2, 0x9,
1315 0x5D, 0x13, 0xBC, 0x7D, 0x84, 0x6F, 0xE, 0xB9};
1316 uint8_t plaintext_18[] = {
1317 0x8, 0x0, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
1318 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
1319 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A,
1320 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34,
1321 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x0, 0x6};
1322 uint8_t ciphertext_18[] = {
1323 0xFF, 0x19, 0x10, 0xD3, 0x5A, 0xD7, 0xE5, 0x65, 0x78, 0x90, 0xC7,
1324 0xC5, 0x60, 0x14, 0x6F, 0xD0, 0x38, 0x70, 0x7F, 0x20, 0x4B, 0x66,
1325 0xED, 0xBC, 0x3D, 0x16, 0x1F, 0x8A, 0xCE, 0x24, 0x4B, 0x98, 0x59,
1326 0x21, 0x2, 0x3C, 0x43, 0x6E, 0x3A, 0x1C, 0x35, 0x32, 0xEC, 0xD5,
1327 0xD0, 0x9A, 0x5, 0x6D, 0x70, 0xBE, 0x58, 0x3F, 0xD, 0x10, 0x82,
1328 0x9D, 0x93, 0x87, 0xD0, 0x7D, 0x33, 0xD8, 0x72, 0xE4, 0x90};
1329 vec = {nonce_18, aad_18, key_18, plaintext_18, ciphertext_18,
1330 12, 28, 44, 49, 65};
1331 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1332
1333 // Derived from IEEE 2.6.2 61-byte crypt
1334 uint8_t nonce_19[] = {0x7C, 0xFD, 0xE9, 0xF9, 0xE3, 0x37,
1335 0x24, 0xC6, 0x89, 0x32, 0xD6, 0x12};
1336 uint8_t aad_19[] = {0x84, 0xC5, 0xD5, 0x13, 0xD2, 0xAA, 0xF6,
1337 0xE5, 0xBB, 0xD2, 0x72, 0x77, 0x88, 0xE5,
1338 0x2F, 0x0, 0x89, 0x32, 0xD6, 0x12, 0x7C,
1339 0xFD, 0xE9, 0xF9, 0xE3, 0x37, 0x24, 0xC6};
1340 uint8_t key_19[] = {0x83, 0xC0, 0x93, 0xB5, 0x8D, 0xE7, 0xFF, 0xE1, 0xC0,
1341 0xDA, 0x92, 0x6A, 0xC4, 0x3F, 0xB3, 0x60, 0x9A, 0xC1,
1342 0xC8, 0xF, 0xEE, 0x1B, 0x62, 0x44, 0x97, 0xEF, 0x94,
1343 0x2E, 0x2F, 0x79, 0xA8, 0x23, 0x81, 0xC2, 0x91, 0xB7,
1344 0x8F, 0xE5, 0xFD, 0xE3, 0xC2, 0xD8, 0x90, 0x68};
1345 uint8_t plaintext_19[] = {
1346 0x8, 0x0, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
1347 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
1348 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A,
1349 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34,
1350 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x0, 0x6};
1351 uint8_t ciphertext_19[] = {
1352 0xD, 0xB4, 0xCF, 0x95, 0x6B, 0x5F, 0x97, 0xEC, 0xA4, 0xEA, 0xB8,
1353 0x2A, 0x69, 0x55, 0x30, 0x7F, 0x9A, 0xE0, 0x2A, 0x32, 0xDD, 0x7D,
1354 0x93, 0xF8, 0x3D, 0x66, 0xAD, 0x4, 0xE1, 0xCF, 0xDC, 0x51, 0x82,
1355 0xAD, 0x12, 0xAB, 0xDE, 0xA5, 0xBB, 0xB6, 0x19, 0xA1, 0xBD, 0x5F,
1356 0xB9, 0xA5, 0x73, 0x59, 0xF, 0xBA, 0x90, 0x8E, 0x9C, 0x7A, 0x46,
1357 0xC1, 0xF7, 0xBA, 0x9, 0x5, 0xD1, 0xB5, 0x5F, 0xFD, 0xA4};
1358 vec = {nonce_19, aad_19, key_19, plaintext_19, ciphertext_19,
1359 12, 28, 44, 49, 65};
1360 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1361
1362 // Derived from IEEE 2.7.1 79-byte crypt
1363 uint8_t nonce_20[] = {0x7A, 0xE8, 0xE2, 0xCA, 0x4E, 0xC5,
1364 0x0, 0x1, 0x2E, 0x58, 0x49, 0x5C};
1365 uint8_t aad_20[] = {
1366 0x68, 0xF2, 0xE7, 0x76, 0x96, 0xCE, 0x7A, 0xE8, 0xE2, 0xCA, 0x4E,
1367 0xC5, 0x88, 0xE5, 0x41, 0x0, 0x2E, 0x58, 0x49, 0x5C, 0x8, 0x0,
1368 0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
1369 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24,
1370 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
1371 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A,
1372 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
1373 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x0, 0x7};
1374 uint8_t key_20[] = {0x88, 0xEE, 0x8, 0x7F, 0xD9, 0x5D, 0xA9, 0xFB, 0xF6,
1375 0x72, 0x5A, 0xA9, 0xD7, 0x57, 0xB0, 0xCD, 0x89, 0xEF,
1376 0x9, 0x7E, 0xD8, 0x5C, 0xA8, 0xFA, 0xF7, 0x73, 0x5B,
1377 0xA8, 0xD6, 0x56, 0xB1, 0xCC, 0x8A, 0xEC, 0xA, 0x7D,
1378 0xDB, 0x5F, 0xAB, 0xF9, 0xF4, 0x70, 0x58, 0xAB};
1379 uint8_t plaintext_20[1] = {};
1380 uint8_t ciphertext_20[] = {0x81, 0x3F, 0xE, 0x63, 0xF, 0x96, 0xFB, 0x2D,
1381 0x3, 0xF, 0x58, 0xD8, 0x3F, 0x5C, 0xDF, 0xD0};
1382 vec = {nonce_20, aad_20, key_20, plaintext_20, ciphertext_20, 12, 87,
1383 44, 0, 16};
1384 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1385
1386 // Derived from IEEE 2.7.2 79-byte crypt
1387 uint8_t nonce_21[] = {0x7A, 0xE8, 0xE2, 0xCA, 0x4E, 0xC5,
1388 0x0, 0x1, 0x2E, 0x58, 0x49, 0x5C};
1389 uint8_t aad_21[] = {
1390 0x68, 0xF2, 0xE7, 0x76, 0x96, 0xCE, 0x7A, 0xE8, 0xE2, 0xCA, 0x4E,
1391 0xC5, 0x88, 0xE5, 0x41, 0x0, 0x2E, 0x58, 0x49, 0x5C, 0x8, 0x0,
1392 0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
1393 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24,
1394 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
1395 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A,
1396 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
1397 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x0, 0x7};
1398 uint8_t key_21[] = {0x4C, 0x97, 0x3D, 0xBC, 0x73, 0x64, 0x62, 0x16, 0x74,
1399 0xF8, 0xB5, 0xB8, 0x9E, 0x5C, 0x15, 0x51, 0x1F, 0xCE,
1400 0xD9, 0x21, 0x64, 0x90, 0xFB, 0x1C, 0x1A, 0x2C, 0xAA,
1401 0xF, 0xFE, 0x4, 0x7, 0xE5, 0x4E, 0x95, 0x3F, 0xBE,
1402 0x71, 0x66, 0x60, 0x14, 0x76, 0xFA, 0xB7, 0xBA};
1403 uint8_t plaintext_21[1] = {};
1404 uint8_t ciphertext_21[] = {0x77, 0xE5, 0xA4, 0x4C, 0x21, 0xEB, 0x7, 0x18,
1405 0x8A, 0xAC, 0xBD, 0x74, 0xD1, 0x98, 0xE, 0x97};
1406 vec = {nonce_21, aad_21, key_21, plaintext_21, ciphertext_21, 12, 87,
1407 44, 0, 16};
1408 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1409
1410 // Derived from IEEE 2.8.1 61-byte crypt
1411 uint8_t nonce_22[] = {0x7A, 0xE8, 0xE2, 0xCA, 0x4E, 0xC5,
1412 0x0, 0x1, 0x2E, 0x58, 0x49, 0x5C};
1413 uint8_t aad_22[] = {0x68, 0xF2, 0xE7, 0x76, 0x96, 0xCE, 0x7A,
1414 0xE8, 0xE2, 0xCA, 0x4E, 0xC5, 0x88, 0xE5,
1415 0x4D, 0x0, 0x2E, 0x58, 0x49, 0x5C};
1416 uint8_t key_22[] = {0x88, 0xEE, 0x8, 0x7F, 0xD9, 0x5D, 0xA9, 0xFB, 0xF6,
1417 0x72, 0x5A, 0xA9, 0xD7, 0x57, 0xB0, 0xCD, 0x89, 0xEF,
1418 0x9, 0x7E, 0xD8, 0x5C, 0xA8, 0xFA, 0xF7, 0x73, 0x5B,
1419 0xA8, 0xD6, 0x56, 0xB1, 0xCC, 0x8A, 0xEC, 0xA, 0x7D,
1420 0xDB, 0x5F, 0xAB, 0xF9, 0xF4, 0x70, 0x58, 0xAB};
1421 uint8_t plaintext_22[] = {
1422 0x8, 0x0, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1423 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22,
1424 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D,
1425 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
1426 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43,
1427 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x0, 0x8};
1428 uint8_t ciphertext_22[] = {
1429 0x95, 0x8E, 0xC3, 0xF6, 0xD6, 0xA, 0xFE, 0xDA, 0x99, 0xEF, 0xD8, 0x88,
1430 0xF1, 0x75, 0xE5, 0xFC, 0xD4, 0xC8, 0x7B, 0x9B, 0xCC, 0x5C, 0x2F, 0x54,
1431 0x26, 0x25, 0x3A, 0x8B, 0x50, 0x62, 0x96, 0xC8, 0xC4, 0x33, 0x9, 0xAB,
1432 0x2A, 0xDB, 0x59, 0x39, 0x46, 0x25, 0x41, 0xD9, 0x5E, 0x80, 0x81, 0x1E,
1433 0x4, 0xE7, 0x6, 0xB1, 0x49, 0x8F, 0x2C, 0x40, 0x7C, 0x7F, 0xB2, 0x34,
1434 0xF8, 0xCC, 0x1, 0xA6, 0x47, 0x55, 0xE, 0xE6, 0xB5, 0x57, 0xB3, 0x5A,
1435 0x7E, 0x39, 0x45, 0x38, 0x18, 0x21, 0xF4};
1436 vec = {nonce_22, aad_22, key_22, plaintext_22, ciphertext_22,
1437 12, 20, 44, 63, 79};
1438 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1439
1440 // Derived from IEEE 2.8.2 61-byte crypt
1441 uint8_t nonce_23[] = {0x7A, 0xE8, 0xE2, 0xCA, 0x4E, 0xC5,
1442 0x0, 0x1, 0x2E, 0x58, 0x49, 0x5C};
1443 uint8_t aad_23[] = {0x68, 0xF2, 0xE7, 0x76, 0x96, 0xCE, 0x7A,
1444 0xE8, 0xE2, 0xCA, 0x4E, 0xC5, 0x88, 0xE5,
1445 0x4D, 0x0, 0x2E, 0x58, 0x49, 0x5C};
1446 uint8_t key_23[] = {0x4C, 0x97, 0x3D, 0xBC, 0x73, 0x64, 0x62, 0x16, 0x74,
1447 0xF8, 0xB5, 0xB8, 0x9E, 0x5C, 0x15, 0x51, 0x1F, 0xCE,
1448 0xD9, 0x21, 0x64, 0x90, 0xFB, 0x1C, 0x1A, 0x2C, 0xAA,
1449 0xF, 0xFE, 0x4, 0x7, 0xE5, 0x4E, 0x95, 0x3F, 0xBE,
1450 0x71, 0x66, 0x60, 0x14, 0x76, 0xFA, 0xB7, 0xBA};
1451 uint8_t plaintext_23[] = {
1452 0x8, 0x0, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1453 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22,
1454 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D,
1455 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
1456 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43,
1457 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x0, 0x8};
1458 uint8_t ciphertext_23[] = {
1459 0xB4, 0x4D, 0x7, 0x20, 0x11, 0xCD, 0x36, 0xD2, 0x72, 0xA9, 0xB7, 0xA9,
1460 0x8D, 0xB9, 0xAA, 0x90, 0xCB, 0xC5, 0xC6, 0x7B, 0x93, 0xDD, 0xCE, 0x67,
1461 0xC8, 0x54, 0x50, 0x32, 0x14, 0xE2, 0xE8, 0x96, 0xEC, 0x7E, 0x9D, 0xB6,
1462 0x49, 0xED, 0x4B, 0xCF, 0x6F, 0x85, 0xA, 0xAC, 0x2, 0x23, 0xD0, 0xCF,
1463 0x92, 0xC8, 0x3D, 0xB8, 0x7, 0x95, 0xC3, 0xA1, 0x7E, 0xCC, 0x12, 0x48,
1464 0xBB, 0x0, 0x59, 0x17, 0x12, 0xB1, 0xAE, 0x71, 0xE2, 0x68, 0x16, 0x41,
1465 0x96, 0x25, 0x21, 0x62, 0x81, 0xB, 0x0};
1466 vec = {nonce_23, aad_23, key_23, plaintext_23, ciphertext_23,
1467 12, 20, 44, 63, 79};
1468 gsec_test_verify_crypter_on_test_vector(&vec, /*rekey=*/true);
1469 }
1470
1471 TEST(AltsCryptTest, GsecTestDoVectorTestsNist) {
1472 /**
1473 * From:
1474 * http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/
1475 * gcm-revised-spec.pdf
1476 */
1477
1478 /* Test vector 1 */
1479 gsec_aead_test_vector* test_vector_1;
1480 const uint8_t test_vector_1_key[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1481 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1482 0x00, 0x00, 0x00, 0x00};
1483 const uint8_t test_vector_1_nonce[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1484 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1485 const uint8_t test_vector_1_aad[1] = {};
1486 const uint8_t test_vector_1_plaintext[1] = {};
1487 const uint8_t test_vector_1_ciphertext_and_tag[] = {
1488 0x58, 0xe2, 0xfc, 0xce, 0xfa, 0x7e, 0x30, 0x61,
1489 0x36, 0x7f, 0x1d, 0x57, 0xa4, 0xe7, 0x45, 0x5a};
1490 gsec_aead_malloc_test_vector(
1491 &test_vector_1, test_vector_1_key,
1492 sizeof(test_vector_1_key) / sizeof(uint8_t), test_vector_1_nonce,
1493 sizeof(test_vector_1_nonce) / sizeof(uint8_t), test_vector_1_aad, 0,
1494 test_vector_1_plaintext, 0, test_vector_1_ciphertext_and_tag,
1495 sizeof(test_vector_1_ciphertext_and_tag) / sizeof(uint8_t));
1496 gsec_test_verify_crypter_on_test_vector(test_vector_1);
1497 gsec_aead_free_test_vector(test_vector_1);
1498
1499 /* Test vector 2 */
1500 gsec_aead_test_vector* test_vector_2;
1501 const uint8_t test_vector_2_key[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1502 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1503 0x00, 0x00, 0x00, 0x00};
1504 const uint8_t test_vector_2_nonce[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1505 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1506 const uint8_t test_vector_2_aad[1] = {};
1507 const uint8_t test_vector_2_plaintext[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1508 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1509 0x00, 0x00, 0x00, 0x00};
1510 const uint8_t test_vector_2_ciphertext_and_tag[] = {
1511 0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92, 0xf3, 0x28, 0xc2,
1512 0xb9, 0x71, 0xb2, 0xfe, 0x78, 0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec,
1513 0x13, 0xbd, 0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf};
1514 gsec_aead_malloc_test_vector(
1515 &test_vector_2, test_vector_2_key,
1516 sizeof(test_vector_2_key) / sizeof(uint8_t), test_vector_2_nonce,
1517 sizeof(test_vector_2_nonce) / sizeof(uint8_t), test_vector_2_aad, 0,
1518 test_vector_2_plaintext,
1519 sizeof(test_vector_2_plaintext) / sizeof(uint8_t),
1520 test_vector_2_ciphertext_and_tag,
1521 sizeof(test_vector_2_ciphertext_and_tag) / sizeof(uint8_t));
1522 gsec_test_verify_crypter_on_test_vector(test_vector_2);
1523 gsec_aead_free_test_vector(test_vector_2);
1524
1525 /* Test vector 3 */
1526 gsec_aead_test_vector* test_vector_3;
1527 const uint8_t test_vector_3_key[] = {0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65,
1528 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94,
1529 0x67, 0x30, 0x83, 0x08};
1530 const uint8_t test_vector_3_nonce[] = {0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce,
1531 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88};
1532 const uint8_t test_vector_3_aad[1] = {};
1533 const uint8_t test_vector_3_plaintext[] = {
1534 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, 0x09,
1535 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34,
1536 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 0x1c,
1537 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 0x2f, 0xcf, 0x0e, 0x24,
1538 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6,
1539 0x57, 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55};
1540 const uint8_t test_vector_3_ciphertext_and_tag[] = {
1541 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, 0x4b, 0x72, 0x21, 0xb7,
1542 0x84, 0xd0, 0xd4, 0x9c, 0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0,
1543 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e, 0x21, 0xd5, 0x14, 0xb2,
1544 0x54, 0x66, 0x93, 0x1c, 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05,
1545 0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97, 0x3d, 0x58, 0xe0, 0x91,
1546 0x47, 0x3f, 0x59, 0x85, 0x4d, 0x5c, 0x2a, 0xf3, 0x27, 0xcd, 0x64, 0xa6,
1547 0x2c, 0xf3, 0x5a, 0xbd, 0x2b, 0xa6, 0xfa, 0xb4};
1548 gsec_aead_malloc_test_vector(
1549 &test_vector_3, test_vector_3_key,
1550 sizeof(test_vector_3_key) / sizeof(uint8_t), test_vector_3_nonce,
1551 sizeof(test_vector_3_nonce) / sizeof(uint8_t), test_vector_3_aad, 0,
1552 test_vector_3_plaintext,
1553 sizeof(test_vector_3_plaintext) / sizeof(uint8_t),
1554 test_vector_3_ciphertext_and_tag,
1555 sizeof(test_vector_3_ciphertext_and_tag) / sizeof(uint8_t));
1556 gsec_test_verify_crypter_on_test_vector(test_vector_3);
1557 gsec_aead_free_test_vector(test_vector_3);
1558
1559 /* Test vector 4 */
1560 gsec_aead_test_vector* test_vector_4;
1561 const uint8_t test_vector_4_key[] = {0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65,
1562 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94,
1563 0x67, 0x30, 0x83, 0x08};
1564 const uint8_t test_vector_4_nonce[] = {0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce,
1565 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88};
1566 const uint8_t test_vector_4_aad[] = {0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe,
1567 0xef, 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad,
1568 0xbe, 0xef, 0xab, 0xad, 0xda, 0xd2};
1569 const uint8_t test_vector_4_plaintext[] = {
1570 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, 0x09, 0xc5,
1571 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
1572 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95,
1573 0x95, 0x68, 0x09, 0x53, 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
1574 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39};
1575 const uint8_t test_vector_4_ciphertext_and_tag[] = {
1576 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, 0x4b, 0x72, 0x21,
1577 0xb7, 0x84, 0xd0, 0xd4, 0x9c, 0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02,
1578 0xa4, 0xe0, 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e, 0x21,
1579 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c, 0x7d, 0x8f, 0x6a, 0x5a,
1580 0xac, 0x84, 0xaa, 0x05, 0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac,
1581 0x97, 0x3d, 0x58, 0xe0, 0x91, 0x5b, 0xc9, 0x4f, 0xbc, 0x32, 0x21,
1582 0xa5, 0xdb, 0x94, 0xfa, 0xe9, 0x5a, 0xe7, 0x12, 0x1a, 0x47};
1583 gsec_aead_malloc_test_vector(
1584 &test_vector_4, test_vector_4_key,
1585 sizeof(test_vector_4_key) / sizeof(uint8_t), test_vector_4_nonce,
1586 sizeof(test_vector_4_nonce) / sizeof(uint8_t), test_vector_4_aad,
1587 sizeof(test_vector_4_aad) / sizeof(uint8_t), test_vector_4_plaintext,
1588 sizeof(test_vector_4_plaintext) / sizeof(uint8_t),
1589 test_vector_4_ciphertext_and_tag,
1590 sizeof(test_vector_4_ciphertext_and_tag) / sizeof(uint8_t));
1591 gsec_test_verify_crypter_on_test_vector(test_vector_4);
1592 gsec_aead_free_test_vector(test_vector_4);
1593 }
1594
1595 TEST(AltsCryptTest, GsecTestDoVectorTestsIeee) {
1596 /**
1597 * From:
1598 * http://www.ieee802.org/1/files/public/docs2011/
1599 * bn-randall-test-vectors-0511-v1.pdf
1600 */
1601
1602 /* 2.1.1 54-byte auth */
1603 gsec_aead_test_vector* test_vector_5;
1604 const uint8_t test_vector_5_key[] = {0xad, 0x7a, 0x2b, 0xd0, 0x3e, 0xac,
1605 0x83, 0x5a, 0x6f, 0x62, 0x0f, 0xdc,
1606 0xb5, 0x06, 0xb3, 0x45};
1607 const uint8_t test_vector_5_nonce[] = {0x12, 0x15, 0x35, 0x24, 0xc0, 0x89,
1608 0x5e, 0x81, 0xb2, 0xc2, 0x84, 0x65};
1609 const uint8_t test_vector_5_aad[] = {
1610 0xd6, 0x09, 0xb1, 0xf0, 0x56, 0x63, 0x7a, 0x0d, 0x46, 0xdf, 0x99, 0x8d,
1611 0x88, 0xe5, 0x22, 0x2a, 0xb2, 0xc2, 0x84, 0x65, 0x12, 0x15, 0x35, 0x24,
1612 0xc0, 0x89, 0x5e, 0x81, 0x08, 0x00, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14,
1613 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
1614 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c,
1615 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x00, 0x01};
1616 const uint8_t test_vector_5_plaintext[1] = {};
1617 const uint8_t test_vector_5_ciphertext_and_tag[] = {
1618 0xf0, 0x94, 0x78, 0xa9, 0xb0, 0x90, 0x07, 0xd0,
1619 0x6f, 0x46, 0xe9, 0xb6, 0xa1, 0xda, 0x25, 0xdd};
1620 gsec_aead_malloc_test_vector(
1621 &test_vector_5, test_vector_5_key,
1622 sizeof(test_vector_5_key) / sizeof(uint8_t), test_vector_5_nonce,
1623 sizeof(test_vector_5_nonce) / sizeof(uint8_t), test_vector_5_aad,
1624 sizeof(test_vector_5_aad) / sizeof(uint8_t), test_vector_5_plaintext, 0,
1625 test_vector_5_ciphertext_and_tag,
1626 sizeof(test_vector_5_ciphertext_and_tag) / sizeof(uint8_t));
1627 gsec_test_verify_crypter_on_test_vector(test_vector_5);
1628 gsec_aead_free_test_vector(test_vector_5);
1629
1630 /* 2.1.2 54-byte auth */
1631 gsec_aead_test_vector* test_vector_6;
1632 const uint8_t test_vector_6_key[] = {
1633 0xe3, 0xc0, 0x8a, 0x8f, 0x06, 0xc6, 0xe3, 0xad, 0x95, 0xa7, 0x05,
1634 0x57, 0xb2, 0x3f, 0x75, 0x48, 0x3c, 0xe3, 0x30, 0x21, 0xa9, 0xc7,
1635 0x2b, 0x70, 0x25, 0x66, 0x62, 0x04, 0xc6, 0x9c, 0x0b, 0x72};
1636
1637 const uint8_t test_vector_6_nonce[] = {0x12, 0x15, 0x35, 0x24, 0xc0, 0x89,
1638 0x5e, 0x81, 0xb2, 0xc2, 0x84, 0x65};
1639 const uint8_t test_vector_6_aad[] = {
1640 0xd6, 0x09, 0xb1, 0xf0, 0x56, 0x63, 0x7a, 0x0d, 0x46, 0xdf, 0x99, 0x8d,
1641 0x88, 0xe5, 0x22, 0x2a, 0xb2, 0xc2, 0x84, 0x65, 0x12, 0x15, 0x35, 0x24,
1642 0xc0, 0x89, 0x5e, 0x81, 0x08, 0x00, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14,
1643 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
1644 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c,
1645 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x00, 0x01};
1646 const uint8_t test_vector_6_plaintext[1] = {};
1647 const uint8_t test_vector_6_ciphertext_and_tag[] = {
1648 0x2f, 0x0b, 0xc5, 0xaf, 0x40, 0x9e, 0x06, 0xd6,
1649 0x09, 0xea, 0x8b, 0x7d, 0x0f, 0xa5, 0xea, 0x50};
1650 gsec_aead_malloc_test_vector(
1651 &test_vector_6, test_vector_6_key,
1652 sizeof(test_vector_6_key) / sizeof(uint8_t), test_vector_6_nonce,
1653 sizeof(test_vector_6_nonce) / sizeof(uint8_t), test_vector_6_aad,
1654 sizeof(test_vector_6_aad) / sizeof(uint8_t), test_vector_6_plaintext, 0,
1655 test_vector_6_ciphertext_and_tag,
1656 sizeof(test_vector_6_ciphertext_and_tag) / sizeof(uint8_t));
1657 gsec_test_verify_crypter_on_test_vector(test_vector_6);
1658 gsec_aead_free_test_vector(test_vector_6);
1659
1660 /* 2.2.1 60-byte crypt */
1661 gsec_aead_test_vector* test_vector_7;
1662 const uint8_t test_vector_7_key[] = {0xad, 0x7a, 0x2b, 0xd0, 0x3e, 0xac,
1663 0x83, 0x5a, 0x6f, 0x62, 0x0f, 0xdc,
1664 0xb5, 0x06, 0xb3, 0x45};
1665
1666 const uint8_t test_vector_7_nonce[] = {0x12, 0x15, 0x35, 0x24, 0xc0, 0x89,
1667 0x5e, 0x81, 0xb2, 0xc2, 0x84, 0x65};
1668 const uint8_t test_vector_7_aad[] = {
1669 0xd6, 0x09, 0xb1, 0xf0, 0x56, 0x63, 0x7a, 0x0d, 0x46, 0xdf,
1670 0x99, 0x8d, 0x88, 0xe5, 0x2e, 0x00, 0xb2, 0xc2, 0x84, 0x65,
1671 0x12, 0x15, 0x35, 0x24, 0xc0, 0x89, 0x5e, 0x81};
1672 const uint8_t test_vector_7_plaintext[] = {
1673 0x08, 0x00, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
1674 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24,
1675 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
1676 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x00, 0x02};
1677 const uint8_t test_vector_7_ciphertext_and_tag[] = {
1678 0x70, 0x1a, 0xfa, 0x1c, 0xc0, 0x39, 0xc0, 0xd7, 0x65, 0x12, 0x8a,
1679 0x66, 0x5d, 0xab, 0x69, 0x24, 0x38, 0x99, 0xbf, 0x73, 0x18, 0xcc,
1680 0xdc, 0x81, 0xc9, 0x93, 0x1d, 0xa1, 0x7f, 0xbe, 0x8e, 0xdd, 0x7d,
1681 0x17, 0xcb, 0x8b, 0x4c, 0x26, 0xfc, 0x81, 0xe3, 0x28, 0x4f, 0x2b,
1682 0x7f, 0xba, 0x71, 0x3d, 0x4f, 0x8d, 0x55, 0xe7, 0xd3, 0xf0, 0x6f,
1683 0xd5, 0xa1, 0x3c, 0x0c, 0x29, 0xb9, 0xd5, 0xb8, 0x80};
1684 gsec_aead_malloc_test_vector(
1685 &test_vector_7, test_vector_7_key,
1686 sizeof(test_vector_7_key) / sizeof(uint8_t), test_vector_7_nonce,
1687 sizeof(test_vector_7_nonce) / sizeof(uint8_t), test_vector_7_aad,
1688 sizeof(test_vector_7_aad) / sizeof(uint8_t), test_vector_7_plaintext,
1689 sizeof(test_vector_7_plaintext) / sizeof(uint8_t),
1690 test_vector_7_ciphertext_and_tag,
1691 sizeof(test_vector_7_ciphertext_and_tag) / sizeof(uint8_t));
1692 gsec_test_verify_crypter_on_test_vector(test_vector_7);
1693 gsec_aead_free_test_vector(test_vector_7);
1694
1695 /* 2.2.2 60-byte crypt */
1696 gsec_aead_test_vector* test_vector_8;
1697 const uint8_t test_vector_8_key[] = {
1698 0xe3, 0xc0, 0x8a, 0x8f, 0x06, 0xc6, 0xe3, 0xad, 0x95, 0xa7, 0x05,
1699 0x57, 0xb2, 0x3f, 0x75, 0x48, 0x3c, 0xe3, 0x30, 0x21, 0xa9, 0xc7,
1700 0x2b, 0x70, 0x25, 0x66, 0x62, 0x04, 0xc6, 0x9c, 0x0b, 0x72};
1701 const uint8_t test_vector_8_nonce[] = {0x12, 0x15, 0x35, 0x24, 0xc0, 0x89,
1702 0x5e, 0x81, 0xb2, 0xc2, 0x84, 0x65};
1703 const uint8_t test_vector_8_aad[] = {
1704 0xd6, 0x09, 0xb1, 0xf0, 0x56, 0x63, 0x7a, 0x0d, 0x46, 0xdf,
1705 0x99, 0x8d, 0x88, 0xe5, 0x2e, 0x00, 0xb2, 0xc2, 0x84, 0x65,
1706 0x12, 0x15, 0x35, 0x24, 0xc0, 0x89, 0x5e, 0x81};
1707 const uint8_t test_vector_8_plaintext[] = {
1708 0x08, 0x00, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
1709 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24,
1710 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
1711 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x00, 0x02};
1712 const uint8_t test_vector_8_ciphertext_and_tag[] = {
1713 0xe2, 0x00, 0x6e, 0xb4, 0x2f, 0x52, 0x77, 0x02, 0x2d, 0x9b, 0x19,
1714 0x92, 0x5b, 0xc4, 0x19, 0xd7, 0xa5, 0x92, 0x66, 0x6c, 0x92, 0x5f,
1715 0xe2, 0xef, 0x71, 0x8e, 0xb4, 0xe3, 0x08, 0xef, 0xea, 0xa7, 0xc5,
1716 0x27, 0x3b, 0x39, 0x41, 0x18, 0x86, 0x0a, 0x5b, 0xe2, 0xa9, 0x7f,
1717 0x56, 0xab, 0x78, 0x36, 0x5c, 0xa5, 0x97, 0xcd, 0xbb, 0x3e, 0xdb,
1718 0x8d, 0x1a, 0x11, 0x51, 0xea, 0x0a, 0xf7, 0xb4, 0x36};
1719 gsec_aead_malloc_test_vector(
1720 &test_vector_8, test_vector_8_key,
1721 sizeof(test_vector_8_key) / sizeof(uint8_t), test_vector_8_nonce,
1722 sizeof(test_vector_8_nonce) / sizeof(uint8_t), test_vector_8_aad,
1723 sizeof(test_vector_8_aad) / sizeof(uint8_t), test_vector_8_plaintext,
1724 sizeof(test_vector_8_plaintext) / sizeof(uint8_t),
1725 test_vector_8_ciphertext_and_tag,
1726 sizeof(test_vector_8_ciphertext_and_tag) / sizeof(uint8_t));
1727 gsec_test_verify_crypter_on_test_vector(test_vector_8);
1728 gsec_aead_free_test_vector(test_vector_8);
1729
1730 /* 2.3.1 60-byte auth */
1731 gsec_aead_test_vector* test_vector_9;
1732 const uint8_t test_vector_9_key[] = {0x07, 0x1b, 0x11, 0x3b, 0x0c, 0xa7,
1733 0x43, 0xfe, 0xcc, 0xcf, 0x3d, 0x05,
1734 0x1f, 0x73, 0x73, 0x82};
1735 const uint8_t test_vector_9_nonce[] = {0xf0, 0x76, 0x1e, 0x8d, 0xcd, 0x3d,
1736 0x00, 0x01, 0x76, 0xd4, 0x57, 0xed};
1737 const uint8_t test_vector_9_aad[] = {
1738 0xe2, 0x01, 0x06, 0xd7, 0xcd, 0x0d, 0xf0, 0x76, 0x1e, 0x8d, 0xcd, 0x3d,
1739 0x88, 0xe5, 0x40, 0x00, 0x76, 0xd4, 0x57, 0xed, 0x08, 0x00, 0x0f, 0x10,
1740 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c,
1741 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
1742 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34,
1743 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x00, 0x03};
1744 const uint8_t test_vector_9_plaintext[1] = {};
1745 const uint8_t test_vector_9_ciphertext_and_tag[] = {
1746 0x0c, 0x01, 0x7b, 0xc7, 0x3b, 0x22, 0x7d, 0xfc,
1747 0xc9, 0xba, 0xfa, 0x1c, 0x41, 0xac, 0xc3, 0x53};
1748 gsec_aead_malloc_test_vector(
1749 &test_vector_9, test_vector_9_key,
1750 sizeof(test_vector_9_key) / sizeof(uint8_t), test_vector_9_nonce,
1751 sizeof(test_vector_9_nonce) / sizeof(uint8_t), test_vector_9_aad,
1752 sizeof(test_vector_9_aad) / sizeof(uint8_t), test_vector_9_plaintext, 0,
1753 test_vector_9_ciphertext_and_tag,
1754 sizeof(test_vector_9_ciphertext_and_tag) / sizeof(uint8_t));
1755 gsec_test_verify_crypter_on_test_vector(test_vector_9);
1756 gsec_aead_free_test_vector(test_vector_9);
1757
1758 /* 2.3.2 60-byte auth */
1759 gsec_aead_test_vector* test_vector_10;
1760 const uint8_t test_vector_10_key[] = {
1761 0x69, 0x1d, 0x3e, 0xe9, 0x09, 0xd7, 0xf5, 0x41, 0x67, 0xfd, 0x1c,
1762 0xa0, 0xb5, 0xd7, 0x69, 0x08, 0x1f, 0x2b, 0xde, 0x1a, 0xee, 0x65,
1763 0x5f, 0xdb, 0xab, 0x80, 0xbd, 0x52, 0x95, 0xae, 0x6b, 0xe7};
1764 const uint8_t test_vector_10_nonce[] = {0xf0, 0x76, 0x1e, 0x8d, 0xcd, 0x3d,
1765 0x00, 0x01, 0x76, 0xd4, 0x57, 0xed};
1766 const uint8_t test_vector_10_aad[] = {
1767 0xe2, 0x01, 0x06, 0xd7, 0xcd, 0x0d, 0xf0, 0x76, 0x1e, 0x8d, 0xcd, 0x3d,
1768 0x88, 0xe5, 0x40, 0x00, 0x76, 0xd4, 0x57, 0xed, 0x08, 0x00, 0x0f, 0x10,
1769 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c,
1770 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
1771 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34,
1772 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x00, 0x03};
1773 const uint8_t test_vector_10_plaintext[1] = {};
1774 const uint8_t test_vector_10_ciphertext_and_tag[] = {
1775 0x35, 0x21, 0x7c, 0x77, 0x4b, 0xbc, 0x31, 0xb6,
1776 0x31, 0x66, 0xbc, 0xf9, 0xd4, 0xab, 0xed, 0x07};
1777 gsec_aead_malloc_test_vector(
1778 &test_vector_10, test_vector_10_key,
1779 sizeof(test_vector_10_key) / sizeof(uint8_t), test_vector_10_nonce,
1780 sizeof(test_vector_10_nonce) / sizeof(uint8_t), test_vector_10_aad,
1781 sizeof(test_vector_10_aad) / sizeof(uint8_t), test_vector_10_plaintext, 0,
1782 test_vector_10_ciphertext_and_tag,
1783 sizeof(test_vector_10_ciphertext_and_tag) / sizeof(uint8_t));
1784 gsec_test_verify_crypter_on_test_vector(test_vector_10);
1785 gsec_aead_free_test_vector(test_vector_10);
1786
1787 /* 2.4.1 54-byte crypt */
1788 gsec_aead_test_vector* test_vector_11;
1789 const uint8_t test_vector_11_key[] = {0x07, 0x1b, 0x11, 0x3b, 0x0c, 0xa7,
1790 0x43, 0xfe, 0xcc, 0xcf, 0x3d, 0x05,
1791 0x1f, 0x73, 0x73, 0x82};
1792 const uint8_t test_vector_11_nonce[] = {0xf0, 0x76, 0x1e, 0x8d, 0xcd, 0x3d,
1793 0x00, 0x01, 0x76, 0xd4, 0x57, 0xed};
1794 const uint8_t test_vector_11_aad[] = {
1795 0xe2, 0x01, 0x06, 0xd7, 0xcd, 0x0d, 0xf0, 0x76, 0x1e, 0x8d,
1796 0xcd, 0x3d, 0x88, 0xe5, 0x4c, 0x2a, 0x76, 0xd4, 0x57, 0xed};
1797 const uint8_t test_vector_11_plaintext[] = {
1798 0x08, 0x00, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1799 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22,
1800 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
1801 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x00, 0x04};
1802 const uint8_t test_vector_11_ciphertext_and_tag[] = {
1803 0x13, 0xb4, 0xc7, 0x2b, 0x38, 0x9d, 0xc5, 0x01, 0x8e, 0x72, 0xa1, 0x71,
1804 0xdd, 0x85, 0xa5, 0xd3, 0x75, 0x22, 0x74, 0xd3, 0xa0, 0x19, 0xfb, 0xca,
1805 0xed, 0x09, 0xa4, 0x25, 0xcd, 0x9b, 0x2e, 0x1c, 0x9b, 0x72, 0xee, 0xe7,
1806 0xc9, 0xde, 0x7d, 0x52, 0xb3, 0xf3, 0xd6, 0xa5, 0x28, 0x4f, 0x4a, 0x6d,
1807 0x3f, 0xe2, 0x2a, 0x5d, 0x6c, 0x2b, 0x96, 0x04, 0x94, 0xc3};
1808 gsec_aead_malloc_test_vector(
1809 &test_vector_11, test_vector_11_key,
1810 sizeof(test_vector_11_key) / sizeof(uint8_t), test_vector_11_nonce,
1811 sizeof(test_vector_11_nonce) / sizeof(uint8_t), test_vector_11_aad,
1812 sizeof(test_vector_11_aad) / sizeof(uint8_t), test_vector_11_plaintext,
1813 sizeof(test_vector_11_plaintext) / sizeof(uint8_t),
1814 test_vector_11_ciphertext_and_tag,
1815 sizeof(test_vector_11_ciphertext_and_tag) / sizeof(uint8_t));
1816 gsec_test_verify_crypter_on_test_vector(test_vector_11);
1817 gsec_aead_free_test_vector(test_vector_11);
1818
1819 /* 2.4.2 54-byte crypt */
1820 gsec_aead_test_vector* test_vector_12;
1821 const uint8_t test_vector_12_key[] = {
1822 0x69, 0x1d, 0x3e, 0xe9, 0x09, 0xd7, 0xf5, 0x41, 0x67, 0xfd, 0x1c,
1823 0xa0, 0xb5, 0xd7, 0x69, 0x08, 0x1f, 0x2b, 0xde, 0x1a, 0xee, 0x65,
1824 0x5f, 0xdb, 0xab, 0x80, 0xbd, 0x52, 0x95, 0xae, 0x6b, 0xe7};
1825 const uint8_t test_vector_12_nonce[] = {0xf0, 0x76, 0x1e, 0x8d, 0xcd, 0x3d,
1826 0x00, 0x01, 0x76, 0xd4, 0x57, 0xed};
1827 const uint8_t test_vector_12_aad[] = {
1828 0xe2, 0x01, 0x06, 0xd7, 0xcd, 0x0d, 0xf0, 0x76, 0x1e, 0x8d,
1829 0xcd, 0x3d, 0x88, 0xe5, 0x4c, 0x2a, 0x76, 0xd4, 0x57, 0xed};
1830 const uint8_t test_vector_12_plaintext[] = {
1831 0x08, 0x00, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1832 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22,
1833 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
1834 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x00, 0x04};
1835 const uint8_t test_vector_12_ciphertext_and_tag[] = {
1836 0xc1, 0x62, 0x3f, 0x55, 0x73, 0x0c, 0x93, 0x53, 0x30, 0x97, 0xad, 0xda,
1837 0xd2, 0x56, 0x64, 0x96, 0x61, 0x25, 0x35, 0x2b, 0x43, 0xad, 0xac, 0xbd,
1838 0x61, 0xc5, 0xef, 0x3a, 0xc9, 0x0b, 0x5b, 0xee, 0x92, 0x9c, 0xe4, 0x63,
1839 0x0e, 0xa7, 0x9f, 0x6c, 0xe5, 0x19, 0x12, 0xaf, 0x39, 0xc2, 0xd1, 0xfd,
1840 0xc2, 0x05, 0x1f, 0x8b, 0x7b, 0x3c, 0x9d, 0x39, 0x7e, 0xf2};
1841 gsec_aead_malloc_test_vector(
1842 &test_vector_12, test_vector_12_key,
1843 sizeof(test_vector_12_key) / sizeof(uint8_t), test_vector_12_nonce,
1844 sizeof(test_vector_12_nonce) / sizeof(uint8_t), test_vector_12_aad,
1845 sizeof(test_vector_12_aad) / sizeof(uint8_t), test_vector_12_plaintext,
1846 sizeof(test_vector_12_plaintext) / sizeof(uint8_t),
1847 test_vector_12_ciphertext_and_tag,
1848 sizeof(test_vector_12_ciphertext_and_tag) / sizeof(uint8_t));
1849 gsec_test_verify_crypter_on_test_vector(test_vector_12);
1850 gsec_aead_free_test_vector(test_vector_12);
1851
1852 /* 2.5.1 65-byte auth */
1853 gsec_aead_test_vector* test_vector_13;
1854 const uint8_t test_vector_13_key[] = {0x01, 0x3f, 0xe0, 0x0b, 0x5f, 0x11,
1855 0xbe, 0x7f, 0x86, 0x6d, 0x0c, 0xbb,
1856 0xc5, 0x5a, 0x7a, 0x90};
1857 const uint8_t test_vector_13_nonce[] = {0x7c, 0xfd, 0xe9, 0xf9, 0xe3, 0x37,
1858 0x24, 0xc6, 0x89, 0x32, 0xd6, 0x12};
1859 const uint8_t test_vector_13_aad[] = {
1860 0x84, 0xc5, 0xd5, 0x13, 0xd2, 0xaa, 0xf6, 0xe5, 0xbb, 0xd2, 0x72, 0x77,
1861 0x88, 0xe5, 0x23, 0x00, 0x89, 0x32, 0xd6, 0x12, 0x7c, 0xfd, 0xe9, 0xf9,
1862 0xe3, 0x37, 0x24, 0xc6, 0x08, 0x00, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14,
1863 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
1864 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c,
1865 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
1866 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x00, 0x05};
1867 const uint8_t test_vector_13_plaintext[1] = {};
1868 const uint8_t test_vector_13_ciphertext_and_tag[] = {
1869 0x21, 0x78, 0x67, 0xe5, 0x0c, 0x2d, 0xad, 0x74,
1870 0xc2, 0x8c, 0x3b, 0x50, 0xab, 0xdf, 0x69, 0x5a};
1871 gsec_aead_malloc_test_vector(
1872 &test_vector_13, test_vector_13_key,
1873 sizeof(test_vector_13_key) / sizeof(uint8_t), test_vector_13_nonce,
1874 sizeof(test_vector_13_nonce) / sizeof(uint8_t), test_vector_13_aad,
1875 sizeof(test_vector_13_aad) / sizeof(uint8_t), test_vector_13_plaintext, 0,
1876 test_vector_13_ciphertext_and_tag,
1877 sizeof(test_vector_13_ciphertext_and_tag) / sizeof(uint8_t));
1878 gsec_test_verify_crypter_on_test_vector(test_vector_13);
1879 gsec_aead_free_test_vector(test_vector_13);
1880
1881 /* 2.5.2 65-byte auth */
1882 gsec_aead_test_vector* test_vector_14;
1883 const uint8_t test_vector_14_key[] = {
1884 0x83, 0xc0, 0x93, 0xb5, 0x8d, 0xe7, 0xff, 0xe1, 0xc0, 0xda, 0x92,
1885 0x6a, 0xc4, 0x3f, 0xb3, 0x60, 0x9a, 0xc1, 0xc8, 0x0f, 0xee, 0x1b,
1886 0x62, 0x44, 0x97, 0xef, 0x94, 0x2e, 0x2f, 0x79, 0xa8, 0x23};
1887 const uint8_t test_vector_14_nonce[] = {0x7c, 0xfd, 0xe9, 0xf9, 0xe3, 0x37,
1888 0x24, 0xc6, 0x89, 0x32, 0xd6, 0x12};
1889 const uint8_t test_vector_14_aad[] = {
1890 0x84, 0xc5, 0xd5, 0x13, 0xd2, 0xaa, 0xf6, 0xe5, 0xbb, 0xd2, 0x72, 0x77,
1891 0x88, 0xe5, 0x23, 0x00, 0x89, 0x32, 0xd6, 0x12, 0x7c, 0xfd, 0xe9, 0xf9,
1892 0xe3, 0x37, 0x24, 0xc6, 0x08, 0x00, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14,
1893 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
1894 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c,
1895 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
1896 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x00, 0x05};
1897 const uint8_t test_vector_14_plaintext[1] = {};
1898 const uint8_t test_vector_14_ciphertext_and_tag[] = {
1899 0x6e, 0xe1, 0x60, 0xe8, 0xfa, 0xec, 0xa4, 0xb3,
1900 0x6c, 0x86, 0xb2, 0x34, 0x92, 0x0c, 0xa9, 0x75};
1901 gsec_aead_malloc_test_vector(
1902 &test_vector_14, test_vector_14_key,
1903 sizeof(test_vector_14_key) / sizeof(uint8_t), test_vector_14_nonce,
1904 sizeof(test_vector_14_nonce) / sizeof(uint8_t), test_vector_14_aad,
1905 sizeof(test_vector_14_aad) / sizeof(uint8_t), test_vector_14_plaintext, 0,
1906 test_vector_14_ciphertext_and_tag,
1907 sizeof(test_vector_14_ciphertext_and_tag) / sizeof(uint8_t));
1908 gsec_test_verify_crypter_on_test_vector(test_vector_14);
1909 gsec_aead_free_test_vector(test_vector_14);
1910
1911 /* 2.6.1 61-byte crypt */
1912 gsec_aead_test_vector* test_vector_15;
1913 const uint8_t test_vector_15_key[] = {0x01, 0x3f, 0xe0, 0x0b, 0x5f, 0x11,
1914 0xbe, 0x7f, 0x86, 0x6d, 0x0c, 0xbb,
1915 0xc5, 0x5a, 0x7a, 0x90};
1916 const uint8_t test_vector_15_nonce[] = {0x7c, 0xfd, 0xe9, 0xf9, 0xe3, 0x37,
1917 0x24, 0xc6, 0x89, 0x32, 0xd6, 0x12};
1918 const uint8_t test_vector_15_aad[] = {
1919 0x84, 0xc5, 0xd5, 0x13, 0xd2, 0xaa, 0xf6, 0xe5, 0xbb, 0xd2,
1920 0x72, 0x77, 0x88, 0xe5, 0x2f, 0x00, 0x89, 0x32, 0xd6, 0x12,
1921 0x7c, 0xfd, 0xe9, 0xf9, 0xe3, 0x37, 0x24, 0xc6};
1922 const uint8_t test_vector_15_plaintext[] = {
1923 0x08, 0x00, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
1924 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
1925 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
1926 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34,
1927 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x00, 0x06};
1928 const uint8_t test_vector_15_ciphertext_and_tag[] = {
1929 0x3a, 0x4d, 0xe6, 0xfa, 0x32, 0x19, 0x10, 0x14, 0xdb, 0xb3, 0x03,
1930 0xd9, 0x2e, 0xe3, 0xa9, 0xe8, 0xa1, 0xb5, 0x99, 0xc1, 0x4d, 0x22,
1931 0xfb, 0x08, 0x00, 0x96, 0xe1, 0x38, 0x11, 0x81, 0x6a, 0x3c, 0x9c,
1932 0x9b, 0xcf, 0x7c, 0x1b, 0x9b, 0x96, 0xda, 0x80, 0x92, 0x04, 0xe2,
1933 0x9d, 0x0e, 0x2a, 0x76, 0x42, 0xbf, 0xd3, 0x10, 0xa4, 0x83, 0x7c,
1934 0x81, 0x6c, 0xcf, 0xa5, 0xac, 0x23, 0xab, 0x00, 0x39, 0x88};
1935 gsec_aead_malloc_test_vector(
1936 &test_vector_15, test_vector_15_key,
1937 sizeof(test_vector_15_key) / sizeof(uint8_t), test_vector_15_nonce,
1938 sizeof(test_vector_15_nonce) / sizeof(uint8_t), test_vector_15_aad,
1939 sizeof(test_vector_15_aad) / sizeof(uint8_t), test_vector_15_plaintext,
1940 sizeof(test_vector_15_plaintext) / sizeof(uint8_t),
1941 test_vector_15_ciphertext_and_tag,
1942 sizeof(test_vector_15_ciphertext_and_tag) / sizeof(uint8_t));
1943 gsec_test_verify_crypter_on_test_vector(test_vector_15);
1944 gsec_aead_free_test_vector(test_vector_15);
1945
1946 /* 2.6.2 61-byte crypt */
1947 gsec_aead_test_vector* test_vector_16;
1948 const uint8_t test_vector_16_key[] = {
1949 0x83, 0xc0, 0x93, 0xb5, 0x8d, 0xe7, 0xff, 0xe1, 0xc0, 0xda, 0x92,
1950 0x6a, 0xc4, 0x3f, 0xb3, 0x60, 0x9a, 0xc1, 0xc8, 0x0f, 0xee, 0x1b,
1951 0x62, 0x44, 0x97, 0xef, 0x94, 0x2e, 0x2f, 0x79, 0xa8, 0x23};
1952 const uint8_t test_vector_16_nonce[] = {0x7c, 0xfd, 0xe9, 0xf9, 0xe3, 0x37,
1953 0x24, 0xc6, 0x89, 0x32, 0xd6, 0x12};
1954 const uint8_t test_vector_16_aad[] = {
1955 0x84, 0xc5, 0xd5, 0x13, 0xd2, 0xaa, 0xf6, 0xe5, 0xbb, 0xd2,
1956 0x72, 0x77, 0x88, 0xe5, 0x2f, 0x00, 0x89, 0x32, 0xd6, 0x12,
1957 0x7c, 0xfd, 0xe9, 0xf9, 0xe3, 0x37, 0x24, 0xc6};
1958 const uint8_t test_vector_16_plaintext[] = {
1959 0x08, 0x00, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
1960 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
1961 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
1962 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34,
1963 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x00, 0x06};
1964 const uint8_t test_vector_16_ciphertext_and_tag[] = {
1965 0x11, 0x02, 0x22, 0xff, 0x80, 0x50, 0xcb, 0xec, 0xe6, 0x6a, 0x81,
1966 0x3a, 0xd0, 0x9a, 0x73, 0xed, 0x7a, 0x9a, 0x08, 0x9c, 0x10, 0x6b,
1967 0x95, 0x93, 0x89, 0x16, 0x8e, 0xd6, 0xe8, 0x69, 0x8e, 0xa9, 0x02,
1968 0xeb, 0x12, 0x77, 0xdb, 0xec, 0x2e, 0x68, 0xe4, 0x73, 0x15, 0x5a,
1969 0x15, 0xa7, 0xda, 0xee, 0xd4, 0xa1, 0x0f, 0x4e, 0x05, 0x13, 0x9c,
1970 0x23, 0xdf, 0x00, 0xb3, 0xaa, 0xdc, 0x71, 0xf0, 0x59, 0x6a};
1971 gsec_aead_malloc_test_vector(
1972 &test_vector_16, test_vector_16_key,
1973 sizeof(test_vector_16_key) / sizeof(uint8_t), test_vector_16_nonce,
1974 sizeof(test_vector_16_nonce) / sizeof(uint8_t), test_vector_16_aad,
1975 sizeof(test_vector_16_aad) / sizeof(uint8_t), test_vector_16_plaintext,
1976 sizeof(test_vector_16_plaintext) / sizeof(uint8_t),
1977 test_vector_16_ciphertext_and_tag,
1978 sizeof(test_vector_16_ciphertext_and_tag) / sizeof(uint8_t));
1979 gsec_test_verify_crypter_on_test_vector(test_vector_16);
1980 gsec_aead_free_test_vector(test_vector_16);
1981
1982 /* 2.7.1 79-byte crypt */
1983 gsec_aead_test_vector* test_vector_17;
1984 const uint8_t test_vector_17_key[] = {0x88, 0xee, 0x08, 0x7f, 0xd9, 0x5d,
1985 0xa9, 0xfb, 0xf6, 0x72, 0x5a, 0xa9,
1986 0xd7, 0x57, 0xb0, 0xcd};
1987 const uint8_t test_vector_17_nonce[] = {0x7a, 0xe8, 0xe2, 0xca, 0x4e, 0xc5,
1988 0x00, 0x01, 0x2e, 0x58, 0x49, 0x5c};
1989 const uint8_t test_vector_17_aad[] = {
1990 0x68, 0xf2, 0xe7, 0x76, 0x96, 0xce, 0x7a, 0xe8, 0xe2, 0xca, 0x4e,
1991 0xc5, 0x88, 0xe5, 0x41, 0x00, 0x2e, 0x58, 0x49, 0x5c, 0x08, 0x00,
1992 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
1993 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24,
1994 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
1995 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a,
1996 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
1997 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x00, 0x07};
1998 const uint8_t test_vector_17_plaintext[1] = {};
1999 const uint8_t test_vector_17_ciphertext_and_tag[] = {
2000 0x07, 0x92, 0x2b, 0x8e, 0xbc, 0xf1, 0x0b, 0xb2,
2001 0x29, 0x75, 0x88, 0xca, 0x4c, 0x61, 0x45, 0x23};
2002 gsec_aead_malloc_test_vector(
2003 &test_vector_17, test_vector_17_key,
2004 sizeof(test_vector_17_key) / sizeof(uint8_t), test_vector_17_nonce,
2005 sizeof(test_vector_17_nonce) / sizeof(uint8_t), test_vector_17_aad,
2006 sizeof(test_vector_17_aad) / sizeof(uint8_t), test_vector_17_plaintext, 0,
2007 test_vector_17_ciphertext_and_tag,
2008 sizeof(test_vector_17_ciphertext_and_tag) / sizeof(uint8_t));
2009 gsec_test_verify_crypter_on_test_vector(test_vector_17);
2010 gsec_aead_free_test_vector(test_vector_17);
2011
2012 /* 2.7.2 79-byte crypt */
2013 gsec_aead_test_vector* test_vector_18;
2014 const uint8_t test_vector_18_key[] = {
2015 0x4c, 0x97, 0x3d, 0xbc, 0x73, 0x64, 0x62, 0x16, 0x74, 0xf8, 0xb5,
2016 0xb8, 0x9e, 0x5c, 0x15, 0x51, 0x1f, 0xce, 0xd9, 0x21, 0x64, 0x90,
2017 0xfb, 0x1c, 0x1a, 0x2c, 0xaa, 0x0f, 0xfe, 0x04, 0x07, 0xe5};
2018 const uint8_t test_vector_18_nonce[] = {0x7a, 0xe8, 0xe2, 0xca, 0x4e, 0xc5,
2019 0x00, 0x01, 0x2e, 0x58, 0x49, 0x5c};
2020 const uint8_t test_vector_18_aad[] = {
2021 0x68, 0xf2, 0xe7, 0x76, 0x96, 0xce, 0x7a, 0xe8, 0xe2, 0xca, 0x4e,
2022 0xc5, 0x88, 0xe5, 0x41, 0x00, 0x2e, 0x58, 0x49, 0x5c, 0x08, 0x00,
2023 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
2024 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24,
2025 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
2026 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a,
2027 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
2028 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x00, 0x07};
2029 const uint8_t test_vector_18_plaintext[1] = {};
2030 const uint8_t test_vector_18_ciphertext_and_tag[] = {
2031 0x00, 0xbd, 0xa1, 0xb7, 0xe8, 0x76, 0x08, 0xbc,
2032 0xbf, 0x47, 0x0f, 0x12, 0x15, 0x7f, 0x4c, 0x07};
2033 gsec_aead_malloc_test_vector(
2034 &test_vector_18, test_vector_18_key,
2035 sizeof(test_vector_18_key) / sizeof(uint8_t), test_vector_18_nonce,
2036 sizeof(test_vector_18_nonce) / sizeof(uint8_t), test_vector_18_aad,
2037 sizeof(test_vector_18_aad) / sizeof(uint8_t), test_vector_18_plaintext, 0,
2038 test_vector_18_ciphertext_and_tag,
2039 sizeof(test_vector_18_ciphertext_and_tag) / sizeof(uint8_t));
2040 gsec_test_verify_crypter_on_test_vector(test_vector_18);
2041 gsec_aead_free_test_vector(test_vector_18);
2042
2043 /* 2.8.1 61-byte crypt */
2044 gsec_aead_test_vector* test_vector_19;
2045 const uint8_t test_vector_19_key[] = {0x88, 0xee, 0x08, 0x7f, 0xd9, 0x5d,
2046 0xa9, 0xfb, 0xf6, 0x72, 0x5a, 0xa9,
2047 0xd7, 0x57, 0xb0, 0xcd};
2048 const uint8_t test_vector_19_nonce[] = {0x7a, 0xe8, 0xe2, 0xca, 0x4e, 0xc5,
2049 0x00, 0x01, 0x2e, 0x58, 0x49, 0x5c};
2050 const uint8_t test_vector_19_aad[] = {
2051 0x68, 0xf2, 0xe7, 0x76, 0x96, 0xce, 0x7a, 0xe8, 0xe2, 0xca,
2052 0x4e, 0xc5, 0x88, 0xe5, 0x4d, 0x00, 0x2e, 0x58, 0x49, 0x5c};
2053 const uint8_t test_vector_19_plaintext[] = {
2054 0x08, 0x00, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2055 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22,
2056 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
2057 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
2058 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43,
2059 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x00, 0x08};
2060 const uint8_t test_vector_19_ciphertext_and_tag[] = {
2061 0xc3, 0x1f, 0x53, 0xd9, 0x9e, 0x56, 0x87, 0xf7, 0x36, 0x51, 0x19, 0xb8,
2062 0x32, 0xd2, 0xaa, 0xe7, 0x07, 0x41, 0xd5, 0x93, 0xf1, 0xf9, 0xe2, 0xab,
2063 0x34, 0x55, 0x77, 0x9b, 0x07, 0x8e, 0xb8, 0xfe, 0xac, 0xdf, 0xec, 0x1f,
2064 0x8e, 0x3e, 0x52, 0x77, 0xf8, 0x18, 0x0b, 0x43, 0x36, 0x1f, 0x65, 0x12,
2065 0xad, 0xb1, 0x6d, 0x2e, 0x38, 0x54, 0x8a, 0x2c, 0x71, 0x9d, 0xba, 0x72,
2066 0x28, 0xd8, 0x40, 0x88, 0xf8, 0x75, 0x7a, 0xdb, 0x8a, 0xa7, 0x88, 0xd8,
2067 0xf6, 0x5a, 0xd6, 0x68, 0xbe, 0x70, 0xe7};
2068 gsec_aead_malloc_test_vector(
2069 &test_vector_19, test_vector_19_key,
2070 sizeof(test_vector_19_key) / sizeof(uint8_t), test_vector_19_nonce,
2071 sizeof(test_vector_19_nonce) / sizeof(uint8_t), test_vector_19_aad,
2072 sizeof(test_vector_19_aad) / sizeof(uint8_t), test_vector_19_plaintext,
2073 sizeof(test_vector_19_plaintext) / sizeof(uint8_t),
2074 test_vector_19_ciphertext_and_tag,
2075 sizeof(test_vector_19_ciphertext_and_tag) / sizeof(uint8_t));
2076 gsec_test_verify_crypter_on_test_vector(test_vector_19);
2077 gsec_aead_free_test_vector(test_vector_19);
2078
2079 /* 2.8.2 61-byte crypt */
2080 gsec_aead_test_vector* test_vector_20;
2081 const uint8_t test_vector_20_key[] = {
2082 0x4c, 0x97, 0x3d, 0xbc, 0x73, 0x64, 0x62, 0x16, 0x74, 0xf8, 0xb5,
2083 0xb8, 0x9e, 0x5c, 0x15, 0x51, 0x1f, 0xce, 0xd9, 0x21, 0x64, 0x90,
2084 0xfb, 0x1c, 0x1a, 0x2c, 0xaa, 0x0f, 0xfe, 0x04, 0x07, 0xe5};
2085 const uint8_t test_vector_20_nonce[] = {0x7a, 0xe8, 0xe2, 0xca, 0x4e, 0xc5,
2086 0x00, 0x01, 0x2e, 0x58, 0x49, 0x5c};
2087 const uint8_t test_vector_20_aad[] = {
2088 0x68, 0xf2, 0xe7, 0x76, 0x96, 0xce, 0x7a, 0xe8, 0xe2, 0xca,
2089 0x4e, 0xc5, 0x88, 0xe5, 0x4d, 0x00, 0x2e, 0x58, 0x49, 0x5c};
2090 const uint8_t test_vector_20_plaintext[] = {
2091 0x08, 0x00, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2092 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22,
2093 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
2094 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
2095 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43,
2096 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x00, 0x08};
2097 const uint8_t test_vector_20_ciphertext_and_tag[] = {
2098 0xba, 0x8a, 0xe3, 0x1b, 0xc5, 0x06, 0x48, 0x6d, 0x68, 0x73, 0xe4, 0xfc,
2099 0xe4, 0x60, 0xe7, 0xdc, 0x57, 0x59, 0x1f, 0xf0, 0x06, 0x11, 0xf3, 0x1c,
2100 0x38, 0x34, 0xfe, 0x1c, 0x04, 0xad, 0x80, 0xb6, 0x68, 0x03, 0xaf, 0xcf,
2101 0x5b, 0x27, 0xe6, 0x33, 0x3f, 0xa6, 0x7c, 0x99, 0xda, 0x47, 0xc2, 0xf0,
2102 0xce, 0xd6, 0x8d, 0x53, 0x1b, 0xd7, 0x41, 0xa9, 0x43, 0xcf, 0xf7, 0xa6,
2103 0x71, 0x3b, 0xd0, 0x26, 0x11, 0xcd, 0x7d, 0xaa, 0x01, 0xd6, 0x1c, 0x5c,
2104 0x88, 0x6d, 0xc1, 0xa8, 0x17, 0x01, 0x07};
2105 gsec_aead_malloc_test_vector(
2106 &test_vector_20, test_vector_20_key,
2107 sizeof(test_vector_20_key) / sizeof(uint8_t), test_vector_20_nonce,
2108 sizeof(test_vector_20_nonce) / sizeof(uint8_t), test_vector_20_aad,
2109 sizeof(test_vector_20_aad) / sizeof(uint8_t), test_vector_20_plaintext,
2110 sizeof(test_vector_20_plaintext) / sizeof(uint8_t),
2111 test_vector_20_ciphertext_and_tag,
2112 sizeof(test_vector_20_ciphertext_and_tag) / sizeof(uint8_t));
2113 gsec_test_verify_crypter_on_test_vector(test_vector_20);
2114 gsec_aead_free_test_vector(test_vector_20);
2115 }
2116
2117 int main(int argc, char** argv) {
2118 grpc::testing::TestEnvironment env(&argc, argv);
2119 ::testing::InitGoogleTest(&argc, argv);
2120 grpc::testing::TestGrpcScope grpc_scope;
2121 return RUN_ALL_TESTS();
2122 }