Classes | Macros | Enumerations | Functions | Variables
fake_transport_security.cc File Reference
#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/memory.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/tsi/transport_security_grpc.h"
Include dependency graph for fake_transport_security.cc:

Go to the source code of this file.

Classes

struct  fake_handshaker_result
 
struct  tsi_fake_frame
 
struct  tsi_fake_frame_protector
 
struct  tsi_fake_handshaker
 
struct  tsi_fake_zero_copy_grpc_protector
 

Macros

#define TSI_FAKE_DEFAULT_FRAME_SIZE   16384
 
#define TSI_FAKE_FRAME_HEADER_SIZE   4
 
#define TSI_FAKE_FRAME_INITIAL_ALLOCATED_SIZE   64
 
#define TSI_FAKE_HANDSHAKER_OUTGOING_BUFFER_INITIAL_SIZE   256
 

Enumerations

enum  tsi_fake_handshake_message {
  TSI_FAKE_CLIENT_INIT = 0, TSI_FAKE_SERVER_INIT = 1, TSI_FAKE_CLIENT_FINISHED = 2, TSI_FAKE_SERVER_FINISHED = 3,
  TSI_FAKE_HANDSHAKE_MESSAGE_MAX = 4
}
 

Functions

static void fake_handshaker_destroy (tsi_handshaker *self)
 
static tsi_result fake_handshaker_get_bytes_to_send_to_peer (tsi_handshaker *self, unsigned char *bytes, size_t *bytes_size)
 
static tsi_result fake_handshaker_get_result (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 *)
 
static tsi_result fake_handshaker_process_bytes_from_peer (tsi_handshaker *self, const unsigned char *bytes, size_t *bytes_size)
 
static tsi_result fake_handshaker_result_create (const unsigned char *unused_bytes, size_t unused_bytes_size, tsi_handshaker_result **handshaker_result)
 
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_create_zero_copy_grpc_protector (const tsi_handshaker_result *, size_t *max_output_protected_frame_size, tsi_zero_copy_grpc_protector **protector)
 
static void fake_handshaker_result_destroy (tsi_handshaker_result *self)
 
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_get_unused_bytes (const tsi_handshaker_result *self, const unsigned char **bytes, size_t *bytes_size)
 
static void fake_protector_destroy (tsi_frame_protector *self)
 
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_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 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 uint32_t load32_little_endian (const unsigned char *buf)
 
static uint32_t read_frame_size (const grpc_slice_buffer *sb)
 
static void store32_little_endian (uint32_t value, unsigned char *buf)
 
tsi_frame_protectortsi_create_fake_frame_protector (size_t *max_protected_frame_size)
 
tsi_handshakertsi_create_fake_handshaker (int is_client)
 
tsi_zero_copy_grpc_protectortsi_create_fake_zero_copy_grpc_protector (size_t *max_protected_frame_size)
 
static tsi_result tsi_fake_frame_decode (const unsigned char *incoming_bytes, size_t *incoming_bytes_size, tsi_fake_frame *frame)
 
static void tsi_fake_frame_destruct (tsi_fake_frame *frame)
 
static tsi_result tsi_fake_frame_encode (unsigned char *outgoing_bytes, size_t *outgoing_bytes_size, tsi_fake_frame *frame)
 
static void tsi_fake_frame_ensure_size (tsi_fake_frame *frame)
 
static void tsi_fake_frame_reset (tsi_fake_frame *frame, int needs_draining)
 
static tsi_result tsi_fake_frame_set_data (unsigned char *data, size_t data_size, tsi_fake_frame *frame)
 
static tsi_result tsi_fake_handshake_message_from_string (const char *msg_string, tsi_fake_handshake_message *msg)
 
static const char * tsi_fake_handshake_message_to_string (int msg)
 
uint32_t tsi_fake_zero_copy_grpc_protector_next_frame_size (const grpc_slice_buffer *protected_slices)
 

Variables

static const tsi_frame_protector_vtable frame_protector_vtable
 
static const tsi_handshaker_result_vtable handshaker_result_vtable
 
static const tsi_handshaker_vtable handshaker_vtable
 
static const char * tsi_fake_handshake_message_strings []
 
static const tsi_zero_copy_grpc_protector_vtable zero_copy_grpc_protector_vtable
 

Macro Definition Documentation

◆ TSI_FAKE_DEFAULT_FRAME_SIZE

#define TSI_FAKE_DEFAULT_FRAME_SIZE   16384

Definition at line 37 of file fake_transport_security.cc.

◆ TSI_FAKE_FRAME_HEADER_SIZE

#define TSI_FAKE_FRAME_HEADER_SIZE   4

Definition at line 35 of file fake_transport_security.cc.

◆ TSI_FAKE_FRAME_INITIAL_ALLOCATED_SIZE

#define TSI_FAKE_FRAME_INITIAL_ALLOCATED_SIZE   64

Definition at line 36 of file fake_transport_security.cc.

◆ TSI_FAKE_HANDSHAKER_OUTGOING_BUFFER_INITIAL_SIZE

#define TSI_FAKE_HANDSHAKER_OUTGOING_BUFFER_INITIAL_SIZE   256

Definition at line 38 of file fake_transport_security.cc.

Enumeration Type Documentation

◆ tsi_fake_handshake_message

Enumerator
TSI_FAKE_CLIENT_INIT 
TSI_FAKE_SERVER_INIT 
TSI_FAKE_CLIENT_FINISHED 
TSI_FAKE_SERVER_FINISHED 
TSI_FAKE_HANDSHAKE_MESSAGE_MAX 

Definition at line 53 of file fake_transport_security.cc.

Function Documentation

◆ fake_handshaker_destroy()

static void fake_handshaker_destroy ( tsi_handshaker self)
static

Definition at line 694 of file fake_transport_security.cc.

◆ fake_handshaker_get_bytes_to_send_to_peer()

static tsi_result fake_handshaker_get_bytes_to_send_to_peer ( tsi_handshaker self,
unsigned char *  bytes,
size_t *  bytes_size 
)
static

Definition at line 601 of file fake_transport_security.cc.

◆ fake_handshaker_get_result()

static tsi_result fake_handshaker_get_result ( tsi_handshaker self)
static

Definition at line 689 of file fake_transport_security.cc.

◆ fake_handshaker_next()

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 *   
)
static

Definition at line 702 of file fake_transport_security.cc.

◆ fake_handshaker_process_bytes_from_peer()

static tsi_result fake_handshaker_process_bytes_from_peer ( tsi_handshaker self,
const unsigned char *  bytes,
size_t *  bytes_size 
)
static

Definition at line 644 of file fake_transport_security.cc.

◆ fake_handshaker_result_create()

static tsi_result fake_handshaker_result_create ( const unsigned char *  unused_bytes,
size_t  unused_bytes_size,
tsi_handshaker_result **  handshaker_result 
)
static

Definition at line 580 of file fake_transport_security.cc.

◆ fake_handshaker_result_create_frame_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

Definition at line 547 of file fake_transport_security.cc.

◆ fake_handshaker_result_create_zero_copy_grpc_protector()

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

Definition at line 538 of file fake_transport_security.cc.

◆ fake_handshaker_result_destroy()

static void fake_handshaker_result_destroy ( tsi_handshaker_result self)
static

Definition at line 564 of file fake_transport_security.cc.

◆ fake_handshaker_result_extract_peer()

static tsi_result fake_handshaker_result_extract_peer ( const tsi_handshaker_result ,
tsi_peer peer 
)
static

Definition at line 515 of file fake_transport_security.cc.

◆ fake_handshaker_result_get_frame_protector_type()

static tsi_result fake_handshaker_result_get_frame_protector_type ( const tsi_handshaker_result ,
tsi_frame_protector_type frame_protector_type 
)
static

Definition at line 531 of file fake_transport_security.cc.

◆ fake_handshaker_result_get_unused_bytes()

static tsi_result fake_handshaker_result_get_unused_bytes ( const tsi_handshaker_result self,
const unsigned char **  bytes,
size_t *  bytes_size 
)
static

Definition at line 554 of file fake_transport_security.cc.

◆ fake_protector_destroy()

static void fake_protector_destroy ( tsi_frame_protector self)
static

Definition at line 396 of file fake_transport_security.cc.

◆ fake_protector_protect()

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

Definition at line 261 of file fake_transport_security.cc.

◆ fake_protector_protect_flush()

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

Definition at line 324 of file fake_transport_security.cc.

◆ fake_protector_unprotect()

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

Definition at line 346 of file fake_transport_security.cc.

◆ fake_zero_copy_grpc_protector_destroy()

static void fake_zero_copy_grpc_protector_destroy ( tsi_zero_copy_grpc_protector self)
static

Definition at line 480 of file fake_transport_security.cc.

◆ fake_zero_copy_grpc_protector_max_frame_size()

static tsi_result fake_zero_copy_grpc_protector_max_frame_size ( tsi_zero_copy_grpc_protector self,
size_t *  max_frame_size 
)
static

Definition at line 490 of file fake_transport_security.cc.

◆ fake_zero_copy_grpc_protector_protect()

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

Definition at line 413 of file fake_transport_security.cc.

◆ fake_zero_copy_grpc_protector_unprotect()

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

Definition at line 438 of file fake_transport_security.cc.

◆ load32_little_endian()

static uint32_t load32_little_endian ( const unsigned char *  buf)
static

Definition at line 111 of file fake_transport_security.cc.

◆ read_frame_size()

static uint32_t read_frame_size ( const grpc_slice_buffer sb)
static

Definition at line 124 of file fake_transport_security.cc.

◆ store32_little_endian()

static void store32_little_endian ( uint32_t  value,
unsigned char *  buf 
)
static

Definition at line 117 of file fake_transport_security.cc.

◆ tsi_create_fake_frame_protector()

tsi_frame_protector* tsi_create_fake_frame_protector ( size_t *  max_protected_frame_size)

Definition at line 797 of file fake_transport_security.cc.

◆ tsi_create_fake_handshaker()

tsi_handshaker* tsi_create_fake_handshaker ( int  is_client)

Definition at line 778 of file fake_transport_security.cc.

◆ tsi_create_fake_zero_copy_grpc_protector()

tsi_zero_copy_grpc_protector* tsi_create_fake_zero_copy_grpc_protector ( size_t *  max_protected_frame_size)

Definition at line 808 of file fake_transport_security.cc.

◆ tsi_fake_frame_decode()

static tsi_result tsi_fake_frame_decode ( const unsigned char *  incoming_bytes,
size_t *  incoming_bytes_size,
tsi_fake_frame frame 
)
static

Definition at line 175 of file fake_transport_security.cc.

◆ tsi_fake_frame_destruct()

static void tsi_fake_frame_destruct ( tsi_fake_frame frame)
static

Definition at line 255 of file fake_transport_security.cc.

◆ tsi_fake_frame_encode()

static tsi_result tsi_fake_frame_encode ( unsigned char *  outgoing_bytes,
size_t *  outgoing_bytes_size,
tsi_fake_frame frame 
)
static

Definition at line 225 of file fake_transport_security.cc.

◆ tsi_fake_frame_ensure_size()

static void tsi_fake_frame_ensure_size ( tsi_fake_frame frame)
static

Definition at line 159 of file fake_transport_security.cc.

◆ tsi_fake_frame_reset()

static void tsi_fake_frame_reset ( tsi_fake_frame frame,
int  needs_draining 
)
static

Definition at line 151 of file fake_transport_security.cc.

◆ tsi_fake_frame_set_data()

static tsi_result tsi_fake_frame_set_data ( unsigned char *  data,
size_t  data_size,
tsi_fake_frame frame 
)
static

Definition at line 243 of file fake_transport_security.cc.

◆ tsi_fake_handshake_message_from_string()

static tsi_result tsi_fake_handshake_message_from_string ( const char *  msg_string,
tsi_fake_handshake_message msg 
)
static

Definition at line 98 of file fake_transport_security.cc.

◆ tsi_fake_handshake_message_to_string()

static const char* tsi_fake_handshake_message_to_string ( int  msg)
static

Definition at line 90 of file fake_transport_security.cc.

◆ tsi_fake_zero_copy_grpc_protector_next_frame_size()

uint32_t tsi_fake_zero_copy_grpc_protector_next_frame_size ( const grpc_slice_buffer protected_slices)

Definition at line 146 of file fake_transport_security.cc.

Variable Documentation

◆ frame_protector_vtable

const tsi_frame_protector_vtable frame_protector_vtable
static

◆ handshaker_result_vtable

const tsi_handshaker_result_vtable handshaker_result_vtable
static

◆ handshaker_vtable

const tsi_handshaker_vtable handshaker_vtable
static
Initial value:
= {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
}

Definition at line 767 of file fake_transport_security.cc.

◆ tsi_fake_handshake_message_strings

const char* tsi_fake_handshake_message_strings[]
static
Initial value:
= {
"CLIENT_INIT", "SERVER_INIT", "CLIENT_FINISHED", "SERVER_FINISHED"}

Definition at line 87 of file fake_transport_security.cc.

◆ zero_copy_grpc_protector_vtable

const tsi_zero_copy_grpc_protector_vtable zero_copy_grpc_protector_vtable
static
fake_zero_copy_grpc_protector_protect
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)
Definition: fake_transport_security.cc:413
fake_protector_unprotect
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)
Definition: fake_transport_security.cc:346
fake_handshaker_next
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 *)
Definition: fake_transport_security.cc:702
fake_handshaker_result_destroy
static void fake_handshaker_result_destroy(tsi_handshaker_result *self)
Definition: fake_transport_security.cc:564
fake_handshaker_result_create_zero_copy_grpc_protector
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)
Definition: fake_transport_security.cc:538
fake_handshaker_result_get_unused_bytes
static tsi_result fake_handshaker_result_get_unused_bytes(const tsi_handshaker_result *self, const unsigned char **bytes, size_t *bytes_size)
Definition: fake_transport_security.cc:554
fake_handshaker_result_create_frame_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)
Definition: fake_transport_security.cc:547
fake_zero_copy_grpc_protector_unprotect
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)
Definition: fake_transport_security.cc:438
fake_protector_protect_flush
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)
Definition: fake_transport_security.cc:324
fake_zero_copy_grpc_protector_destroy
static void fake_zero_copy_grpc_protector_destroy(tsi_zero_copy_grpc_protector *self)
Definition: fake_transport_security.cc:480
fake_zero_copy_grpc_protector_max_frame_size
static tsi_result fake_zero_copy_grpc_protector_max_frame_size(tsi_zero_copy_grpc_protector *self, size_t *max_frame_size)
Definition: fake_transport_security.cc:490
fake_handshaker_result_get_frame_protector_type
static tsi_result fake_handshaker_result_get_frame_protector_type(const tsi_handshaker_result *, tsi_frame_protector_type *frame_protector_type)
Definition: fake_transport_security.cc:531
fake_protector_protect
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)
Definition: fake_transport_security.cc:261
fake_protector_destroy
static void fake_protector_destroy(tsi_frame_protector *self)
Definition: fake_transport_security.cc:396
fake_handshaker_result_extract_peer
static tsi_result fake_handshaker_result_extract_peer(const tsi_handshaker_result *, tsi_peer *peer)
Definition: fake_transport_security.cc:515
fake_handshaker_destroy
static void fake_handshaker_destroy(tsi_handshaker *self)
Definition: fake_transport_security.cc:694


grpc
Author(s):
autogenerated on Fri May 16 2025 03:01:12