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


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:40