Go to the documentation of this file.
61 if (input_length == 0) {
68 for (
size_t i = 0;
i < *output_length - 1;
i++) {
73 input += slice_length;
74 input_length -= slice_length;
77 (*output)[*output_length - 1] =
slice;
95 bool integrity_only) {
99 size_t overflow_size = 8;
109 crypter, overflow_size,
true, integrity_only,
110 true, &
fixture->client_protect,
117 crypter, overflow_size,
true, integrity_only,
118 false, &
fixture->client_unprotect,
125 crypter, overflow_size,
false, integrity_only,
126 true, &
fixture->server_protect,
133 crypter, overflow_size,
false, integrity_only,
134 false, &
fixture->server_unprotect,
160 var->header_iovec.iov_base = var->header_buf;
161 var->header_iovec.iov_len = var->header_length;
165 var->tag_iovec.iov_base = var->tag_buf;
166 var->tag_iovec.iov_len = var->tag_length;
172 var->data_iovec =
nullptr;
173 var->data_iovec_length = 0;
175 &var->data_iovec_length);
177 size_t protected_buf_length =
178 var->header_length + var->data_length + var->tag_length;
180 var->protected_iovec.iov_base = var->protected_buf;
181 var->protected_iovec.iov_len = protected_buf_length;
183 var->unprotected_iovec.iov_base = var->data_buf;
184 var->unprotected_iovec.iov_len = var->data_length;
190 if (var ==
nullptr) {
262 char* error_message =
nullptr;
268 "Frame tag verification failed."));
283 char* error_message =
nullptr;
301 "Unsupported message type."));
311 "Frame tag verification failed."));
321 "Frame tag verification failed."));
336 char* error_message =
nullptr;
344 "Header is nullptr."));
354 "Header length is incorrect."));
372 "Tag length is incorrect."));
381 char* error_message =
nullptr;
389 "Header is nullptr."));
399 "Header length is incorrect."));
417 "Tag length is incorrect."));
456 auto* protected_buf =
459 iovec_t protected_iovec = {protected_buf, empty_payload_frame_size};
460 iovec_t unprotected_iovec = {
nullptr, 0};
465 sender,
nullptr, 0, protected_iovec,
nullptr);
469 receiver, header_iovec, &data_iovec, 1, unprotected_iovec,
nullptr);
494 char* error_message =
nullptr;
517 char* error_message =
nullptr;
520 iovec_t header_iovec = {header_buf, header_length};
524 iovec_t protected_iovec = {protected_buf, protected_length};
542 "Unsupported message type."));
567 char* error_message =
nullptr;
576 "Protected frame is nullptr."));
586 "Protected frame size is incorrect."));
595 char* error_message =
nullptr;
607 "Header is nullptr."));
617 "Header length is incorrect."));
623 rp, header_iovec, &protected_iovec, 1, unprotected_iovec, &error_message);
626 "Unprotected data size is incorrect."));
641 char* error_message =
nullptr;
648 "Integrity-only operations are not allowed for this object."));
656 "Integrity-only operations are not allowed for this object."));
664 "Privacy-integrity operations are not allowed for this object."));
672 "Privacy-integrity operations are not allowed for this object."));
683 char* error_message =
nullptr;
695 privacy_integrity_receiver, var->
header_iovec, &protected_iovec, 1,
709 char* error_message =
nullptr;
723 integrity_only_receiver, &data_iovec, 1, header_iovec, tag_iovec,
727 "Frame tag verification failed."));
static void record_protocol_wrong_mode(alts_iovec_record_protocol *integrity_only_protect_rp, alts_iovec_record_protocol *integrity_only_unprotect_rp, alts_iovec_record_protocol *privacy_integrity_protect_rp, alts_iovec_record_protocol *privacy_integrity_unprotect_rp)
static void integrity_only_corrupted_data(alts_iovec_record_protocol *sender, alts_iovec_record_protocol *receiver)
uint32_t gsec_test_bias_random_uint32(uint32_t max_length)
static void integrity_only_random_seal_unseal(alts_iovec_record_protocol *sender, alts_iovec_record_protocol *receiver)
iovec_t unprotected_iovec
static void integrity_seal_privacy_unseal(alts_iovec_record_protocol *integrity_only_sender, alts_iovec_record_protocol *privacy_integrity_receiver)
static void integrity_only_unsync_seal_unseal(alts_iovec_record_protocol *sender, alts_iovec_record_protocol *receiver)
alts_iovec_record_protocol * server_unprotect
static void alts_iovec_record_protocol_test_fixture_destroy(alts_iovec_record_protocol_test_fixture *fixture)
GPRAPI void gpr_free(void *ptr)
static void alts_iovec_record_protocol_empty_seal_unseal_tests()
static void privacy_integrity_empty_seal_unseal(alts_iovec_record_protocol *sender, alts_iovec_record_protocol *receiver)
grpc_status_code alts_iovec_record_protocol_integrity_only_protect(alts_iovec_record_protocol *rp, const iovec_t *unprotected_vec, size_t unprotected_vec_length, iovec_t header, iovec_t tag, char **error_details)
GPRAPI void * gpr_malloc(size_t size)
void alts_iovec_record_protocol_destroy(alts_iovec_record_protocol *rp)
static void alts_iovec_record_protocol_corrupted_data_tests()
void gsec_test_random_array(uint8_t **bytes, size_t length)
alts_iovec_record_protocol * server_protect
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)
@ GRPC_STATUS_INVALID_ARGUMENT
void gsec_test_copy(const uint8_t *src, uint8_t **des, size_t source_len)
constexpr size_t kTagLength
static void privacy_integrity_protect_input_check(alts_iovec_record_protocol *rp)
GPRAPI void * gpr_zalloc(size_t size)
static void privacy_integrity_unsync_seal_unseal(alts_iovec_record_protocol *sender, alts_iovec_record_protocol *receiver)
static size_t alter_random_byte(uint8_t *buf, size_t buf_length)
constexpr size_t kZeroCopyFrameMessageTypeFieldSize
static void revert_back_alter(uint8_t *buf, size_t offset)
static void privacy_integrity_corrupted_data(alts_iovec_record_protocol *sender, alts_iovec_record_protocol *receiver)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static void integrity_only_unprotect_input_check(alts_iovec_record_protocol *rp)
constexpr size_t kMaxDataSize
const size_t kAesGcmNonceLength
grpc_status_code alts_iovec_record_protocol_privacy_integrity_protect(alts_iovec_record_protocol *rp, const iovec_t *unprotected_vec, size_t unprotected_vec_length, iovec_t protected_frame, char **error_details)
grpc_status_code alts_iovec_record_protocol_privacy_integrity_unprotect(alts_iovec_record_protocol *rp, iovec_t header, const iovec_t *protected_vec, size_t protected_vec_length, iovec_t unprotected_data, char **error_details)
static void alts_iovec_record_protocol_unsync_seal_unseal_tests()
static void integrity_only_empty_seal_unseal(alts_iovec_record_protocol *sender, alts_iovec_record_protocol *receiver)
static const char fixture[]
static void alts_iovec_record_protocol_random_seal_unseal_tests()
const size_t kAes128GcmRekeyKeyLength
static void randomly_slice(uint8_t *input, size_t input_length, iovec_t **output, size_t *output_length)
constexpr size_t kMaxSlices
static void privacy_integrity_unprotect_input_check(alts_iovec_record_protocol *rp)
size_t alts_iovec_record_protocol_get_header_length()
alts_iovec_record_protocol * client_unprotect
grpc_status_code alts_iovec_record_protocol_integrity_only_unprotect(alts_iovec_record_protocol *rp, const iovec_t *protected_vec, size_t protected_vec_length, iovec_t header, iovec_t tag, char **error_details)
constexpr size_t kSealRepeatTimes
static alts_iovec_record_protocol_test_fixture * alts_iovec_record_protocol_test_fixture_create(bool rekey, bool integrity_only)
static alts_iovec_record_protocol_test_var * alts_iovec_record_protocol_test_var_create()
static void alts_iovec_record_protocol_mix_operations_tests()
grpc_status_code alts_iovec_record_protocol_create(gsec_aead_crypter *crypter, size_t overflow_size, bool is_client, bool is_integrity_only, bool is_protect, alts_iovec_record_protocol **rp, char **error_details)
static void alts_iovec_record_protocol_input_check_tests()
static void privacy_seal_integrity_unseal(alts_iovec_record_protocol *privacy_integrity_sender, alts_iovec_record_protocol *integrity_only_receiver)
alts_iovec_record_protocol * client_protect
int gsec_test_expect_compare_code_and_substr(grpc_status_code status1, grpc_status_code status2, const char *msg1, const char *msg2)
@ GRPC_STATUS_FAILED_PRECONDITION
static void privacy_integrity_random_seal_unseal(alts_iovec_record_protocol *sender, alts_iovec_record_protocol *receiver)
void gsec_test_random_bytes(uint8_t *bytes, size_t length)
constexpr size_t kZeroCopyFrameLengthFieldSize
const size_t kAes128GcmKeyLength
static void alts_iovec_record_protocol_test_var_destroy(alts_iovec_record_protocol_test_var *var)
const size_t kAesGcmTagLength
static void integrity_only_protect_input_check(alts_iovec_record_protocol *rp)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:41