#include <grpc/support/port_platform.h>
#include "src/core/tsi/fake_transport_security.h"
#include <stdlib.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/gprpp/crash.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/tsi/transport_security_grpc.h"
#define TSI_FAKE_FRAME_HEADER_SIZE …
#define TSI_FAKE_FRAME_INITIAL_ALLOCATED_SIZE …
#define TSI_FAKE_DEFAULT_FRAME_SIZE …
#define TSI_FAKE_HANDSHAKER_OUTGOING_BUFFER_INITIAL_SIZE …
struct tsi_fake_frame { … };
tsi_fake_handshake_message;
struct tsi_fake_handshaker { … };
struct tsi_fake_frame_protector { … };
struct tsi_fake_zero_copy_grpc_protector { … };
static const char* tsi_fake_handshake_message_strings[] = …;
static const char* tsi_fake_handshake_message_to_string(int msg) { … }
static tsi_result tsi_fake_handshake_message_from_string(
const char* msg_string, tsi_fake_handshake_message* msg,
std::string* error) { … }
static uint32_t load32_little_endian(const unsigned char* buf) { … }
static void store32_little_endian(uint32_t value, unsigned char* buf) { … }
static uint32_t read_frame_size(const grpc_slice_buffer* sb) { … }
uint32_t tsi_fake_zero_copy_grpc_protector_next_frame_size(
const grpc_slice_buffer* protected_slices) { … }
static void tsi_fake_frame_reset(tsi_fake_frame* frame, int needs_draining) { … }
static void tsi_fake_frame_ensure_size(tsi_fake_frame* frame) { … }
static tsi_result tsi_fake_frame_decode(const unsigned char* incoming_bytes,
size_t* incoming_bytes_size,
tsi_fake_frame* frame,
std::string* error) { … }
static tsi_result tsi_fake_frame_encode(unsigned char* outgoing_bytes,
size_t* outgoing_bytes_size,
tsi_fake_frame* frame,
std::string* error) { … }
static void tsi_fake_frame_set_data(unsigned char* data, size_t data_size,
tsi_fake_frame* frame) { … }
static void tsi_fake_frame_destruct(tsi_fake_frame* frame) { … }
static tsi_result fake_protector_protect(tsi_frame_protector* self,
const unsigned char* unprotected_bytes,
size_t* unprotected_bytes_size,
unsigned char* protected_output_frames,
size_t* protected_output_frames_size) { … }
static tsi_result fake_protector_protect_flush(
tsi_frame_protector* self, unsigned char* protected_output_frames,
size_t* protected_output_frames_size, size_t* still_pending_size) { … }
static tsi_result fake_protector_unprotect(
tsi_frame_protector* self, const unsigned char* protected_frames_bytes,
size_t* protected_frames_bytes_size, unsigned char* unprotected_bytes,
size_t* unprotected_bytes_size) { … }
static void fake_protector_destroy(tsi_frame_protector* self) { … }
static const tsi_frame_protector_vtable frame_protector_vtable = …;
static tsi_result fake_zero_copy_grpc_protector_protect(
tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* unprotected_slices,
grpc_slice_buffer* protected_slices) { … }
static tsi_result fake_zero_copy_grpc_protector_unprotect(
tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* protected_slices,
grpc_slice_buffer* unprotected_slices, int* min_progress_size) { … }
static void fake_zero_copy_grpc_protector_destroy(
tsi_zero_copy_grpc_protector* self) { … }
static tsi_result fake_zero_copy_grpc_protector_max_frame_size(
tsi_zero_copy_grpc_protector* self, size_t* max_frame_size) { … }
static const tsi_zero_copy_grpc_protector_vtable
zero_copy_grpc_protector_vtable = …;
struct fake_handshaker_result { … };
static tsi_result fake_handshaker_result_extract_peer(
const tsi_handshaker_result* , tsi_peer* peer) { … }
static tsi_result fake_handshaker_result_get_frame_protector_type(
const tsi_handshaker_result* ,
tsi_frame_protector_type* frame_protector_type) { … }
static tsi_result fake_handshaker_result_create_zero_copy_grpc_protector(
const tsi_handshaker_result* ,
size_t* max_output_protected_frame_size,
tsi_zero_copy_grpc_protector** protector) { … }
static tsi_result fake_handshaker_result_create_frame_protector(
const tsi_handshaker_result* ,
size_t* max_output_protected_frame_size, tsi_frame_protector** protector) { … }
static tsi_result fake_handshaker_result_get_unused_bytes(
const tsi_handshaker_result* self, const unsigned char** bytes,
size_t* bytes_size) { … }
static void fake_handshaker_result_destroy(tsi_handshaker_result* self) { … }
static const tsi_handshaker_result_vtable handshaker_result_vtable = …;
static tsi_result fake_handshaker_result_create(
const unsigned char* unused_bytes, size_t unused_bytes_size,
tsi_handshaker_result** handshaker_result, std::string* error) { … }
static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
tsi_handshaker* self, unsigned char* bytes, size_t* bytes_size,
std::string* error) { … }
static tsi_result fake_handshaker_process_bytes_from_peer(
tsi_handshaker* self, const unsigned char* bytes, size_t* bytes_size,
std::string* error) { … }
static tsi_result fake_handshaker_get_result(tsi_handshaker* self) { … }
static void fake_handshaker_destroy(tsi_handshaker* self) { … }
static tsi_result fake_handshaker_next(
tsi_handshaker* self, const unsigned char* received_bytes,
size_t received_bytes_size, const unsigned char** bytes_to_send,
size_t* bytes_to_send_size, tsi_handshaker_result** handshaker_result,
tsi_handshaker_on_next_done_cb , void* ,
std::string* error) { … }
static const tsi_handshaker_vtable handshaker_vtable = …;
tsi_handshaker* tsi_create_fake_handshaker(int is_client) { … }
tsi_frame_protector* tsi_create_fake_frame_protector(
size_t* max_protected_frame_size) { … }
tsi_zero_copy_grpc_protector* tsi_create_fake_zero_copy_grpc_protector(
size_t* max_protected_frame_size) { … }