GRPC Core  18.0.0
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. */
35  const unsigned char* unprotected_bytes,
36  size_t* unprotected_bytes_size,
37  unsigned char* protected_output_frames,
38  size_t* protected_output_frames_size);
40  unsigned char* protected_output_frames,
41  size_t* protected_output_frames_size,
42  size_t* still_pending_size);
44  const unsigned char* protected_frames_bytes,
45  size_t* protected_frames_bytes_size,
46  unsigned char* unprotected_bytes,
47  size_t* unprotected_bytes_size);
48  void (*destroy)(tsi_frame_protector* self);
49 };
52 };
53 
54 /* Base for tsi_handshaker implementations.
55  See transport_security_interface.h for documentation. */
58  unsigned char* bytes,
59  size_t* bytes_size);
61  const unsigned char* bytes,
62  size_t* bytes_size);
66  size_t* max_protected_frame_size,
67  tsi_frame_protector** protector);
68  void (*destroy)(tsi_handshaker* self);
69  tsi_result (*next)(tsi_handshaker* self, const unsigned char* received_bytes,
70  size_t received_bytes_size,
71  const unsigned char** bytes_to_send,
72  size_t* bytes_to_send_size,
73  tsi_handshaker_result** handshaker_result,
74  tsi_handshaker_on_next_done_cb cb, void* user_data);
75  void (*shutdown)(tsi_handshaker* self);
76 };
82 };
83 
84 /* Base for tsi_handshaker_result implementations.
85  See transport_security_interface.h for documentation.
86  The exec_ctx parameter in create_zero_copy_grpc_protector is supposed to be
87  of type grpc_exec_ctx*, but we're using void* instead to avoid making the TSI
88  API depend on grpc. The create_zero_copy_grpc_protector() method is only used
89  in grpc, where we do need the exec_ctx passed through, but the API still
90  needs to compile in other applications, where grpc_exec_ctx is not defined.
91 */
95  const tsi_handshaker_result* self,
96  size_t* max_output_protected_frame_size,
97  tsi_zero_copy_grpc_protector** protector);
99  size_t* max_output_protected_frame_size,
100  tsi_frame_protector** protector);
102  const unsigned char** bytes,
103  size_t* bytes_size);
105 };
108 };
109 
110 /* Peer and property construction/destruction functions. */
111 tsi_result tsi_construct_peer(size_t property_count, tsi_peer* peer);
115  const char* value,
116  size_t value_length,
117  tsi_peer_property* property);
119  const char* name, size_t value_length, tsi_peer_property* property);
121  const char* name, const char* value, tsi_peer_property* property);
123  const char* name);
124 /* Utils. */
125 char* tsi_strdup(const char* src); /* Sadly, no strdup in C89. */
126 
127 #endif /* GRPC_CORE_TSI_TRANSPORT_SECURITY_H */
Definition: trace.h:61
Definition: transport_security.h:33
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:34
void(* destroy)(tsi_frame_protector *self)
Definition: transport_security.h:48
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:43
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:39
Definition: transport_security.h:50
const tsi_frame_protector_vtable * vtable
Definition: transport_security.h:51
Definition: transport_security.h:92
tsi_result(* get_unused_bytes)(const tsi_handshaker_result *self, const unsigned char **bytes, size_t *bytes_size)
Definition: transport_security.h:101
void(* destroy)(tsi_handshaker_result *self)
Definition: transport_security.h:104
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:98
tsi_result(* extract_peer)(const tsi_handshaker_result *self, tsi_peer *peer)
Definition: transport_security.h:93
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:94
Definition: transport_security.h:106
const tsi_handshaker_result_vtable * vtable
Definition: transport_security.h:107
Definition: transport_security.h:56
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:69
void(* shutdown)(tsi_handshaker *self)
Definition: transport_security.h:75
tsi_result(* get_bytes_to_send_to_peer)(tsi_handshaker *self, unsigned char *bytes, size_t *bytes_size)
Definition: transport_security.h:57
void(* destroy)(tsi_handshaker *self)
Definition: transport_security.h:68
tsi_result(* process_bytes_from_peer)(tsi_handshaker *self, const unsigned char *bytes, size_t *bytes_size)
Definition: transport_security.h:60
tsi_result(* create_frame_protector)(tsi_handshaker *self, size_t *max_protected_frame_size, tsi_frame_protector **protector)
Definition: transport_security.h:65
tsi_result(* get_result)(tsi_handshaker *self)
Definition: transport_security.h:63
tsi_result(* extract_peer)(tsi_handshaker *self, tsi_peer *peer)
Definition: transport_security.h:64
Definition: transport_security.h:77
bool frame_protector_created
Definition: transport_security.h:79
bool handshaker_result_created
Definition: transport_security.h:80
const tsi_handshaker_vtable * vtable
Definition: transport_security.h:78
bool handshake_shutdown
Definition: transport_security.h:81
Definition: transport_security_interface.h:208
Definition: transport_security_interface.h:216
Definition: transport_security_grpc.h:75
tsi_result tsi_construct_peer(size_t property_count, tsi_peer *peer)
Definition: transport_security.cc:347
char * tsi_strdup(const char *src)
const tsi_peer_property * tsi_peer_get_property_by_name(const tsi_peer *peer, const char *name)
Definition: transport_security.cc:357
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:334
void tsi_peer_property_destruct(tsi_peer_property *property)
Definition: transport_security.cc:298
tsi_result tsi_construct_allocated_string_peer_property(const char *name, size_t value_length, tsi_peer_property *property)
Definition: transport_security.cc:317
tsi_result tsi_construct_string_peer_property_from_cstring(const char *name, const char *value, tsi_peer_property *property)
Definition: transport_security.cc:328
tsi_peer_property tsi_init_peer_property(void)
Definition: transport_security.cc:283
grpc_core::TraceFlag tsi_tracing_enabled
tsi_result
Definition: transport_security_interface.h:31
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:434