#include <grpc/support/port_platform.h>
#include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h"
#include <string.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/slice/slice_internal.h"
Go to the source code of this file.
Variables | |
const size_t | kInitialIovecBufferSize = 8 |
void alts_grpc_record_protocol_convert_slice_buffer_to_iovec | ( | alts_grpc_record_protocol * | rp, |
const grpc_slice_buffer * | sb | ||
) |
Converts the slices of input sb into iovec_t's and puts the result into rp->iovec_buf. Note that the actual data are not copied, only pointers and lengths are copied.
Definition at line 50 of file alts_grpc_record_protocol_common.cc.
void alts_grpc_record_protocol_copy_slice_buffer | ( | const grpc_slice_buffer * | src, |
unsigned char * | dst | ||
) |
Copies bytes from slice buffer to destination buffer. Caller is responsible for allocating enough memory of destination buffer. This method is used for copying frame header and tag in case they are stored in multiple slices.
Definition at line 60 of file alts_grpc_record_protocol_common.cc.
void alts_grpc_record_protocol_destroy | ( | alts_grpc_record_protocol * | self | ) |
This method destroys an alts_grpc_record_protocol instance by de-allocating all of its occupied memory.
Definition at line 151 of file alts_grpc_record_protocol_common.cc.
iovec_t alts_grpc_record_protocol_get_header_iovec | ( | alts_grpc_record_protocol * | rp | ) |
This method returns an iovec object pointing to the frame header stored in rp->header_sb. If the frame header is stored in multiple slices, this method will copy the bytes in rp->header_sb to rp->header_buf, and return an iovec object pointing to rp->header_buf.
Definition at line 70 of file alts_grpc_record_protocol_common.cc.
tsi_result alts_grpc_record_protocol_init | ( | alts_grpc_record_protocol * | rp, |
gsec_aead_crypter * | crypter, | ||
size_t | overflow_size, | ||
bool | is_client, | ||
bool | is_integrity_only, | ||
bool | is_protect | ||
) |
Initializes an alts_grpc_record_protocol object, given a gsec_aead_crypter instance, the overflow size of the counter in bytes, a flag indicating if the object is used for client or server side, a flag indicating if it is used for integrity-only or privacy-integrity mode, and a flag indicating if it is for protect or unprotect. The ownership of gsec_aead_crypter object is transferred to the alts_grpc_record_protocol object.
Definition at line 88 of file alts_grpc_record_protocol_common.cc.
size_t alts_grpc_record_protocol_max_unprotected_data_size | ( | const alts_grpc_record_protocol * | self, |
size_t | max_protected_frame_size | ||
) |
This method returns maximum allowed unprotected data size, given maximum protected frame size.
On success, the method returns the maximum allowed unprotected data size. Otherwise, it returns zero.
Definition at line 167 of file alts_grpc_record_protocol_common.cc.
tsi_result alts_grpc_record_protocol_protect | ( | alts_grpc_record_protocol * | self, |
grpc_slice_buffer * | unprotected_slices, | ||
grpc_slice_buffer * | protected_slices | ||
) |
This methods performs protect operation on unprotected data and appends the protected frame to protected_slices. The caller needs to ensure the length of unprotected data plus the frame overhead is less than or equal to the maximum frame length. The input unprotected data slice buffer will be cleared, although the actual unprotected data bytes are not modified.
This method returns TSI_OK in case of success or a specific error code in case of failure.
Definition at line 123 of file alts_grpc_record_protocol_common.cc.
tsi_result alts_grpc_record_protocol_unprotect | ( | alts_grpc_record_protocol * | self, |
grpc_slice_buffer * | protected_slices, | ||
grpc_slice_buffer * | unprotected_slices | ||
) |
This methods performs unprotect operation on a full frame of protected data and appends unprotected data to unprotected_slices. It is the caller's responsibility to prepare a full frame of data before calling this method. The input protected frame slice buffer will be cleared, although the actual protected data bytes are not modified.
This method returns TSI_OK in case of success or a specific error code in case of failure.
Definition at line 137 of file alts_grpc_record_protocol_common.cc.
|
static |
Definition at line 35 of file alts_grpc_record_protocol_common.cc.
const size_t kInitialIovecBufferSize = 8 |
Definition at line 32 of file alts_grpc_record_protocol_common.cc.