Go to the documentation of this file.
41 if (
dst !=
nullptr && src !=
nullptr) {
49 if (
dst !=
nullptr && appendix !=
nullptr) {
50 int dst_len =
static_cast<int>(strlen(*
dst));
51 *
dst =
static_cast<char*
>(realloc(*
dst, dst_len + strlen(appendix) + 1));
52 assert(*
dst !=
nullptr);
53 memcpy(*
dst + dst_len, appendix, strlen(appendix) + 1);
67 buffer[3] =
static_cast<unsigned char>(
value >> 24) & 0xFF;
68 buffer[2] =
static_cast<unsigned char>(
value >> 16) & 0xFF;
69 buffer[1] =
static_cast<unsigned char>(
value >> 8) & 0xFF;
70 buffer[0] =
static_cast<unsigned char>(
value) & 0xFF;
76 char** error_details) {
80 if (
header.iov_base ==
nullptr) {
88 if (
tag.iov_base ==
nullptr) {
101 char** error_details) {
105 bool is_overflow =
false;
120 size_t total_length = 0;
121 for (
size_t i = 0;
i < vec_length; ++
i) {
130 char** error_details) {
145 char** error_details) {
182 size_t overhead_bytes_size =
184 if (max_protected_frame_size <= overhead_bytes_size)
return 0;
185 return max_protected_frame_size - overhead_bytes_size;
191 char** error_details) {
200 "Integrity-only operations are not allowed for this object.",
219 static_cast<unsigned char*
>(
header.iov_base),
246 char** error_details) {
255 "Integrity-only operations are not allowed for this object.",
261 "Unprotect operations are not allowed for this object.", error_details);
271 static_cast<unsigned char*
>(
header.iov_base),
293 size_t unprotected_vec_length,
iovec_t protected_frame,
294 char** error_details) {
303 "Privacy-integrity operations are not allowed for this object.",
316 if (protected_frame.
iov_base ==
nullptr) {
329 static_cast<unsigned char*
>(protected_frame.
iov_base), error_details);
334 unsigned char* ciphertext_buffer =
335 static_cast<unsigned char*
>(protected_frame.
iov_base) +
342 0, unprotected_vec, unprotected_vec_length,
349 "Bytes written expects to be data length plus tag length.",
359 const iovec_t* protected_vec,
size_t protected_vec_length,
360 iovec_t unprotected_data,
char** error_details) {
369 "Privacy-integrity operations are not allowed for this object.",
375 "Unprotect operations are not allowed for this object.", error_details);
379 size_t protected_data_length =
381 if (protected_data_length < rp->tag_length) {
383 "Protected data length should be more than the tag length.",
388 if (
header.iov_base ==
nullptr) {
403 protected_data_length,
static_cast<unsigned char*
>(
header.iov_base),
413 0, protected_vec, protected_vec_length,
421 "Bytes written expects to be protected data length minus tag length.",
432 char** error_details) {
433 if (crypter ==
nullptr || rp ==
nullptr) {
435 "Invalid nullptr arguments to alts_iovec_record_protocol create.",
442 size_t counter_length = 0;
451 overflow_size, &impl->
ctr, error_details);
unsigned char * alts_counter_get_counter(alts_counter *crypter_counter)
static void maybe_append_error_msg(const char *appendix, char **dst)
constexpr size_t kZeroCopyFrameMessageType
GPRAPI void gpr_free(void *ptr)
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)
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)
grpc_status_code alts_counter_increment(alts_counter *crypter_counter, bool *is_overflow, char **error_details)
@ GRPC_STATUS_INVALID_ARGUMENT
static size_t get_total_length(const iovec_t *vec, size_t vec_length)
static grpc_status_code increment_counter(alts_counter *counter, char **error_details)
grpc_status_code gsec_aead_crypter_tag_length(const gsec_aead_crypter *crypter, size_t *tag_length_to_return, char **error_details)
size_t alts_counter_get_size(alts_counter *crypter_counter)
GPRAPI void * gpr_zalloc(size_t size)
static size_t frame_length(size_t payload_length)
constexpr size_t kZeroCopyFrameMessageTypeFieldSize
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
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 * tag(intptr_t t)
static grpc_status_code write_frame_header(size_t data_length, unsigned char *header, char **error_details)
struct absl::base_internal::@2940::AllocList::Header header
size_t alts_iovec_record_protocol_get_header_length()
constexpr size_t kZeroCopyFrameHeaderSize
gsec_aead_crypter * crypter
static uint32_t load_32_le(const unsigned char *buffer)
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)
static void store_32_le(uint32_t value, unsigned char *buffer)
size_t alts_iovec_record_protocol_get_tag_length(const alts_iovec_record_protocol *rp)
grpc_status_code gsec_aead_crypter_nonce_length(const gsec_aead_crypter *crypter, size_t *nonce_length_to_return, char **error_details)
size_t alts_iovec_record_protocol_max_unprotected_data_size(const alts_iovec_record_protocol *rp, size_t max_protected_frame_size)
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 grpc_status_code ensure_header_and_tag_length(const alts_iovec_record_protocol *rp, iovec_t header, iovec_t tag, char **error_details)
static grpc_status_code verify_frame_header(size_t data_length, unsigned char *header, char **error_details)
@ GRPC_STATUS_FAILED_PRECONDITION
static size_t bytes_written
void gsec_aead_crypter_destroy(gsec_aead_crypter *crypter)
constexpr size_t kZeroCopyFrameLengthFieldSize
grpc_status_code alts_counter_create(bool is_client, size_t counter_size, size_t overflow_size, alts_counter **crypter_counter, char **error_details)
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)
static void maybe_copy_error_msg(const char *src, char **dst)
void alts_counter_destroy(alts_counter *crypter_counter)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:41