transport_security.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_CORE_TSI_TRANSPORT_SECURITY_H
20 #define GRPC_CORE_TSI_TRANSPORT_SECURITY_H
21 
23 
24 #include <stdbool.h>
25 
28 
30 
31 /* Base for tsi_frame_protector implementations.
32  See transport_security_interface.h for documentation.
33  All methods must be implemented. */
36  const unsigned char* unprotected_bytes,
37  size_t* unprotected_bytes_size,
38  unsigned char* protected_output_frames,
39  size_t* protected_output_frames_size);
41  unsigned char* protected_output_frames,
42  size_t* protected_output_frames_size,
43  size_t* still_pending_size);
45  const unsigned char* protected_frames_bytes,
46  size_t* protected_frames_bytes_size,
47  unsigned char* unprotected_bytes,
48  size_t* unprotected_bytes_size);
49  void (*destroy)(tsi_frame_protector* self);
50 };
53 };
54 
55 /* Base for tsi_handshaker implementations.
56  See transport_security_interface.h for documentation. */
58  /* Methods for supporting the old synchronous API.
59  These can be null if the TSI impl supports only the new
60  async-capable API. */
62  unsigned char* bytes,
63  size_t* bytes_size);
65  const unsigned char* bytes,
66  size_t* bytes_size);
70  size_t* max_protected_frame_size,
71  tsi_frame_protector** protector);
72  /* Must be implemented by all TSI impls. */
73  void (*destroy)(tsi_handshaker* self);
74  /* Methods for supporting the new async-capable API.
75  These can be null if the TSI impl supports only the old sync API. */
76  tsi_result (*next)(tsi_handshaker* self, const unsigned char* received_bytes,
77  size_t received_bytes_size,
78  const unsigned char** bytes_to_send,
79  size_t* bytes_to_send_size,
80  tsi_handshaker_result** handshaker_result,
81  tsi_handshaker_on_next_done_cb cb, void* user_data);
82  void (*shutdown)(tsi_handshaker* self);
83 };
89 };
90 
91 /* Base for tsi_handshaker_result implementations.
92  See transport_security_interface.h for documentation.
93  The exec_ctx parameter in create_zero_copy_grpc_protector is supposed to be
94  of type grpc_exec_ctx*, but we're using void* instead to avoid making the TSI
95  API depend on grpc. The create_zero_copy_grpc_protector() method is only used
96  in grpc, where we do need the exec_ctx passed through, but the API still
97  needs to compile in other applications, where grpc_exec_ctx is not defined.
98  All methods must be non-null, except where noted below.
99 */
103  const tsi_handshaker_result* self,
104  tsi_frame_protector_type* frame_protector_type);
105  /* May be null if get_frame_protector_type() returns
106  TSI_FRAME_PROTECTOR_NORMAL or TSI_FRAME_PROTECTOR_NONE. */
108  const tsi_handshaker_result* self,
109  size_t* max_output_protected_frame_size,
110  tsi_zero_copy_grpc_protector** protector);
111  /* May be null if get_frame_protector_type() returns
112  TSI_FRAME_PROTECTOR_ZERO_COPY or TSI_FRAME_PROTECTOR_NONE. */
114  size_t* max_output_protected_frame_size,
115  tsi_frame_protector** protector);
117  const unsigned char** bytes,
118  size_t* bytes_size);
120 };
123 };
124 
125 /* Peer and property construction/destruction functions. */
126 tsi_result tsi_construct_peer(size_t property_count, tsi_peer* peer);
130  const char* value,
131  size_t value_length,
132  tsi_peer_property* property);
134  const char* name, size_t value_length, tsi_peer_property* property);
136  const char* name, const char* value, tsi_peer_property* property);
138  const char* name);
139 /* Utils. */
140 char* tsi_strdup(const char* src); /* Sadly, no strdup in C89. */
141 
142 #endif /* GRPC_CORE_TSI_TRANSPORT_SECURITY_H */
trace.h
tsi_frame_protector_vtable::protect_flush
tsi_result(* protect_flush)(tsi_frame_protector *self, unsigned char *protected_output_frames, size_t *protected_output_frames_size, size_t *still_pending_size)
Definition: transport_security.h:40
tsi_handshaker::vtable
const tsi_handshaker_vtable * vtable
Definition: transport_security.h:85
tsi_handshaker::frame_protector_created
bool frame_protector_created
Definition: transport_security.h:86
tsi_handshaker_vtable
Definition: transport_security.h:57
tsi_frame_protector_vtable::protect
tsi_result(* 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: transport_security.h:35
tsi_handshaker_vtable::shutdown
void(* shutdown)(tsi_handshaker *self)
Definition: transport_security.h:82
tsi_handshaker
Definition: transport_security.h:84
tsi_construct_string_peer_property_from_cstring
tsi_result tsi_construct_string_peer_property_from_cstring(const char *name, const char *value, tsi_peer_property *property)
Definition: transport_security.cc:340
tsi_tracing_enabled
grpc_core::TraceFlag tsi_tracing_enabled
tsi_frame_protector_vtable::unprotect
tsi_result(* 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: transport_security.h:44
setup.name
name
Definition: setup.py:542
tsi_handshaker_vtable::next
tsi_result(* 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 cb, void *user_data)
Definition: transport_security.h:76
tsi_handshaker_vtable::process_bytes_from_peer
tsi_result(* process_bytes_from_peer)(tsi_handshaker *self, const unsigned char *bytes, size_t *bytes_size)
Definition: transport_security.h:64
tsi_handshaker_result_vtable::extract_peer
tsi_result(* extract_peer)(const tsi_handshaker_result *self, tsi_peer *peer)
Definition: transport_security.h:101
tsi_construct_string_peer_property
tsi_result tsi_construct_string_peer_property(const char *name, const char *value, size_t value_length, tsi_peer_property *property)
Definition: transport_security.cc:346
tsi_handshaker_result::vtable
const tsi_handshaker_result_vtable * vtable
Definition: transport_security.h:122
tsi_frame_protector_type
tsi_frame_protector_type
Definition: transport_security_interface.h:69
tsi_peer_property_destruct
void tsi_peer_property_destruct(tsi_peer_property *property)
Definition: transport_security.cc:310
tsi_init_peer_property
tsi_peer_property tsi_init_peer_property(void)
Definition: transport_security.cc:295
tsi_handshaker_vtable::destroy
void(* destroy)(tsi_handshaker *self)
Definition: transport_security.h:73
tsi_handshaker_result_vtable::destroy
void(* destroy)(tsi_handshaker_result *self)
Definition: transport_security.h:119
tsi_handshaker_on_next_done_cb
void(* tsi_handshaker_on_next_done_cb)(tsi_result status, void *user_data, const unsigned char *bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result *handshaker_result)
Definition: transport_security_interface.h:462
tsi_handshaker_vtable::get_bytes_to_send_to_peer
tsi_result(* get_bytes_to_send_to_peer)(tsi_handshaker *self, unsigned char *bytes, size_t *bytes_size)
Definition: transport_security.h:61
tsi_result
tsi_result
Definition: transport_security_interface.h:31
tsi_frame_protector_vtable::destroy
void(* destroy)(tsi_frame_protector *self)
Definition: transport_security.h:49
tsi_construct_peer
tsi_result tsi_construct_peer(size_t property_count, tsi_peer *peer)
Definition: transport_security.cc:359
tsi_construct_allocated_string_peer_property
tsi_result tsi_construct_allocated_string_peer_property(const char *name, size_t value_length, tsi_peer_property *property)
Definition: transport_security.cc:329
transport_security_interface.h
tsi_peer_get_property_by_name
const tsi_peer_property * tsi_peer_get_property_by_name(const tsi_peer *peer, const char *name)
Definition: transport_security.cc:369
tsi_handshaker_vtable::create_frame_protector
tsi_result(* create_frame_protector)(tsi_handshaker *self, size_t *max_protected_frame_size, tsi_frame_protector **protector)
Definition: transport_security.h:69
grpc_core::TraceFlag
Definition: debug/trace.h:63
tsi_peer_property
Definition: transport_security_interface.h:230
value
const char * value
Definition: hpack_parser_table.cc:165
tsi_peer
Definition: transport_security_interface.h:238
tsi_frame_protector_vtable
Definition: transport_security.h:34
bytes
uint8 bytes[10]
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc:153
tsi_handshaker_result_vtable::get_unused_bytes
tsi_result(* get_unused_bytes)(const tsi_handshaker_result *self, const unsigned char **bytes, size_t *bytes_size)
Definition: transport_security.h:116
tsi_handshaker_result_vtable::create_frame_protector
tsi_result(* create_frame_protector)(const tsi_handshaker_result *self, size_t *max_output_protected_frame_size, tsi_frame_protector **protector)
Definition: transport_security.h:113
tsi_strdup
char * tsi_strdup(const char *src)
tsi_frame_protector::vtable
const tsi_frame_protector_vtable * vtable
Definition: transport_security.h:52
tsi_handshaker_vtable::get_result
tsi_result(* get_result)(tsi_handshaker *self)
Definition: transport_security.h:67
tsi_handshaker_result
Definition: transport_security.h:121
tsi_frame_protector
Definition: transport_security.h:51
tsi_zero_copy_grpc_protector
Definition: transport_security_grpc.h:79
tsi_handshaker_result_vtable
Definition: transport_security.h:100
tsi_handshaker_result_vtable::get_frame_protector_type
tsi_result(* get_frame_protector_type)(const tsi_handshaker_result *self, tsi_frame_protector_type *frame_protector_type)
Definition: transport_security.h:102
tsi_handshaker_vtable::extract_peer
tsi_result(* extract_peer)(tsi_handshaker *self, tsi_peer *peer)
Definition: transport_security.h:68
cb
OPENSSL_EXPORT pem_password_cb * cb
Definition: pem.h:351
tsi_handshaker::handshaker_result_created
bool handshaker_result_created
Definition: transport_security.h:87
tsi_handshaker::handshake_shutdown
bool handshake_shutdown
Definition: transport_security.h:88
port_platform.h
tsi_handshaker_result_vtable::create_zero_copy_grpc_protector
tsi_result(* create_zero_copy_grpc_protector)(const tsi_handshaker_result *self, size_t *max_output_protected_frame_size, tsi_zero_copy_grpc_protector **protector)
Definition: transport_security.h:107


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:40