transport_security_test_lib.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2017 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 
20 
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 
25 #include <grpc/grpc.h>
26 #include <grpc/support/alloc.h>
27 #include <grpc/support/log.h>
28 
31 
33  gpr_mu_lock(&fixture->mu);
34  fixture->notified = true;
35  gpr_cv_signal(&fixture->cv);
36  gpr_mu_unlock(&fixture->mu);
37 }
38 
40  gpr_mu_lock(&fixture->mu);
41  while (!fixture->notified) {
43  }
44  fixture->notified = false;
45  gpr_mu_unlock(&fixture->mu);
46 }
47 
48 typedef struct handshaker_args {
50  unsigned char* handshake_buffer;
52  bool is_client;
57 
59  bool is_client) {
60  GPR_ASSERT(fixture != nullptr);
61  GPR_ASSERT(fixture->config != nullptr);
63  args->fixture = fixture;
64  args->handshake_buffer_size = fixture->handshake_buffer_size;
65  args->handshake_buffer =
66  static_cast<unsigned char*>(gpr_zalloc(args->handshake_buffer_size));
67  args->is_client = is_client;
68  args->error = GRPC_ERROR_NONE;
69  return args;
70 }
71 
73  gpr_free(args->handshake_buffer);
74  GRPC_ERROR_UNREF(args->error);
75  delete args;
76 }
77 
79 
81  GPR_ASSERT(fixture != nullptr);
82  GPR_ASSERT(fixture->vtable != nullptr);
83  GPR_ASSERT(fixture->vtable->setup_handshakers != nullptr);
84  fixture->vtable->setup_handshakers(fixture);
85 }
86 
88  tsi_handshaker_result* result_with_unused_bytes =
89  fixture->has_client_finished_first ? fixture->server_result
90  : fixture->client_result;
91  tsi_handshaker_result* result_without_unused_bytes =
92  fixture->has_client_finished_first ? fixture->client_result
93  : fixture->server_result;
94  const unsigned char* bytes = nullptr;
95  size_t bytes_size = 0;
97  result_with_unused_bytes, &bytes, &bytes_size) == TSI_OK);
98  GPR_ASSERT(bytes_size == strlen(TSI_TEST_UNUSED_BYTES));
99  GPR_ASSERT(memcmp(bytes, TSI_TEST_UNUSED_BYTES, bytes_size) == 0);
101  result_without_unused_bytes, &bytes, &bytes_size) == TSI_OK);
102  GPR_ASSERT(bytes_size == 0);
103  GPR_ASSERT(bytes == nullptr);
104 }
105 
107  GPR_ASSERT(fixture != nullptr);
108  GPR_ASSERT(fixture->vtable != nullptr);
109  GPR_ASSERT(fixture->vtable->check_handshaker_peers != nullptr);
110  /* Check handshaker peers. */
111  fixture->vtable->check_handshaker_peers(fixture);
112  /* Check unused bytes. */
113  if (fixture->test_unused_bytes) {
114  tsi_test_channel* channel = fixture->channel;
115  if (fixture->server_result != nullptr &&
116  fixture->client_result != nullptr) {
118  }
119  channel->bytes_written_to_server_channel = 0;
120  channel->bytes_written_to_client_channel = 0;
121  channel->bytes_read_from_client_channel = 0;
122  channel->bytes_read_from_server_channel = 0;
123  }
124 }
125 
126 static void send_bytes_to_peer(tsi_test_channel* test_channel,
127  const unsigned char* buf, size_t buf_size,
128  bool is_client) {
129  GPR_ASSERT(test_channel != nullptr);
130  GPR_ASSERT(buf != nullptr);
131  uint8_t* channel =
132  is_client ? test_channel->server_channel : test_channel->client_channel;
133  GPR_ASSERT(channel != nullptr);
134  size_t* bytes_written = is_client
135  ? &test_channel->bytes_written_to_server_channel
136  : &test_channel->bytes_written_to_client_channel;
137  GPR_ASSERT(bytes_written != nullptr);
139  /* Write data to channel. */
140  memcpy(channel + *bytes_written, buf, buf_size);
141  *bytes_written += buf_size;
142 }
143 
145  GPR_ASSERT(args != nullptr);
146  GPR_ASSERT(args->fixture != nullptr);
147  tsi_test_fixture* fixture = args->fixture;
148  if (fixture->test_unused_bytes && !args->appended_unused_bytes) {
149  args->appended_unused_bytes = true;
151  fixture->channel,
152  reinterpret_cast<const unsigned char*>(TSI_TEST_UNUSED_BYTES),
153  strlen(TSI_TEST_UNUSED_BYTES), args->is_client);
154  if (fixture->client_result != nullptr &&
155  fixture->server_result == nullptr) {
156  fixture->has_client_finished_first = true;
157  }
158  }
159 }
160 
161 static void receive_bytes_from_peer(tsi_test_channel* test_channel,
162  unsigned char** buf, size_t* buf_size,
163  bool is_client) {
164  GPR_ASSERT(test_channel != nullptr);
165  GPR_ASSERT(*buf != nullptr);
166  GPR_ASSERT(buf_size != nullptr);
167  uint8_t* channel =
168  is_client ? test_channel->client_channel : test_channel->server_channel;
169  GPR_ASSERT(channel != nullptr);
170  size_t* bytes_read = is_client
171  ? &test_channel->bytes_read_from_client_channel
172  : &test_channel->bytes_read_from_server_channel;
173  size_t* bytes_written = is_client
174  ? &test_channel->bytes_written_to_client_channel
175  : &test_channel->bytes_written_to_server_channel;
176  GPR_ASSERT(bytes_read != nullptr);
177  GPR_ASSERT(bytes_written != nullptr);
178  size_t to_read = *buf_size < *bytes_written - *bytes_read
179  ? *buf_size
181  /* Read data from channel. */
182  memcpy(*buf, channel + *bytes_read, to_read);
183  *buf_size = to_read;
184  *bytes_read += to_read;
185 }
186 
189  tsi_frame_protector* protector, bool is_client) {
190  /* Initialization. */
191  GPR_ASSERT(config != nullptr);
192  GPR_ASSERT(channel != nullptr);
193  GPR_ASSERT(protector != nullptr);
194  unsigned char* protected_buffer =
195  static_cast<unsigned char*>(gpr_zalloc(config->protected_buffer_size));
196  size_t message_size =
197  is_client ? config->client_message_size : config->server_message_size;
198  uint8_t* message =
199  is_client ? config->client_message : config->server_message;
200  GPR_ASSERT(message != nullptr);
201  const unsigned char* message_bytes =
202  reinterpret_cast<unsigned char*>(message);
204  /* Do protect and send protected data to peer. */
205  while (message_size > 0 && result == TSI_OK) {
206  size_t protected_buffer_size_to_send = config->protected_buffer_size;
207  size_t processed_message_size = message_size;
208  /* Do protect. */
210  protector, message_bytes, &processed_message_size, protected_buffer,
211  &protected_buffer_size_to_send);
213  /* Send protected data to peer. */
214  send_bytes_to_peer(channel, protected_buffer, protected_buffer_size_to_send,
215  is_client);
216  message_bytes += processed_message_size;
217  message_size -= processed_message_size;
218  /* Flush if we're done. */
219  if (message_size == 0) {
220  size_t still_pending_size;
221  do {
222  protected_buffer_size_to_send = config->protected_buffer_size;
224  protector, protected_buffer, &protected_buffer_size_to_send,
225  &still_pending_size);
227  send_bytes_to_peer(channel, protected_buffer,
228  protected_buffer_size_to_send, is_client);
229  } while (still_pending_size > 0 && result == TSI_OK);
231  }
232  }
234  gpr_free(protected_buffer);
235 }
236 
239  tsi_frame_protector* protector, unsigned char* message,
240  size_t* bytes_received, bool is_client) {
241  /* Initialization. */
242  GPR_ASSERT(config != nullptr);
243  GPR_ASSERT(channel != nullptr);
244  GPR_ASSERT(protector != nullptr);
245  GPR_ASSERT(message != nullptr);
246  GPR_ASSERT(bytes_received != nullptr);
247  size_t read_offset = 0;
248  size_t message_offset = 0;
249  size_t read_from_peer_size = 0;
251  bool done = false;
252  unsigned char* read_buffer = static_cast<unsigned char*>(
253  gpr_zalloc(config->read_buffer_allocated_size));
254  unsigned char* message_buffer = static_cast<unsigned char*>(
255  gpr_zalloc(config->message_buffer_allocated_size));
256  /* Do unprotect on data received from peer. */
257  while (!done && result == TSI_OK) {
258  /* Receive data from peer. */
259  if (read_from_peer_size == 0) {
260  read_from_peer_size = config->read_buffer_allocated_size;
261  receive_bytes_from_peer(channel, &read_buffer, &read_from_peer_size,
262  is_client);
263  read_offset = 0;
264  }
265  if (read_from_peer_size == 0) {
266  done = true;
267  }
268  /* Do unprotect. */
269  size_t message_buffer_size;
270  do {
271  message_buffer_size = config->message_buffer_allocated_size;
272  size_t processed_size = read_from_peer_size;
274  protector, read_buffer + read_offset, &processed_size, message_buffer,
275  &message_buffer_size);
277  if (message_buffer_size > 0) {
278  memcpy(message + message_offset, message_buffer, message_buffer_size);
279  message_offset += message_buffer_size;
280  }
281  read_offset += processed_size;
282  read_from_peer_size -= processed_size;
283  } while ((read_from_peer_size > 0 || message_buffer_size > 0) &&
284  result == TSI_OK);
286  }
288  *bytes_received = message_offset;
289  gpr_free(read_buffer);
290  gpr_free(message_buffer);
291 }
292 
294  tsi_result result, void* user_data, const unsigned char* bytes_to_send,
295  size_t bytes_to_send_size, tsi_handshaker_result* handshaker_result) {
296  handshaker_args* args = static_cast<handshaker_args*>(user_data);
297  GPR_ASSERT(args != nullptr);
298  GPR_ASSERT(args->fixture != nullptr);
299  tsi_test_fixture* fixture = args->fixture;
301  /* Read more data if we need to. */
302  if (result == TSI_INCOMPLETE_DATA) {
303  GPR_ASSERT(bytes_to_send_size == 0);
305  return error;
306  }
307  if (result != TSI_OK) {
310  GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshake failed"), result);
311  }
312  /* Update handshaker result. */
313  if (handshaker_result != nullptr) {
314  tsi_handshaker_result** result_to_write =
315  args->is_client ? &fixture->client_result : &fixture->server_result;
316  GPR_ASSERT(*result_to_write == nullptr);
317  *result_to_write = handshaker_result;
318  }
319  /* Send data to peer, if needed. */
320  if (bytes_to_send_size > 0) {
321  send_bytes_to_peer(fixture->channel, bytes_to_send, bytes_to_send_size,
322  args->is_client);
323  args->transferred_data = true;
324  }
325  if (handshaker_result != nullptr) {
327  }
329  return error;
330 }
331 
333  tsi_result result, void* user_data, const unsigned char* bytes_to_send,
334  size_t bytes_to_send_size, tsi_handshaker_result* handshaker_result) {
335  handshaker_args* args = static_cast<handshaker_args*>(user_data);
336  args->error = on_handshake_next_done(result, user_data, bytes_to_send,
337  bytes_to_send_size, handshaker_result);
338 }
339 
341  GPR_ASSERT(args != nullptr);
342  GPR_ASSERT(args->fixture != nullptr);
343  tsi_test_fixture* fixture = args->fixture;
344  return (args->is_client && fixture->client_result != nullptr) ||
345  (!args->is_client && fixture->server_result != nullptr);
346 }
347 
349  /* Initialization. */
350  GPR_ASSERT(args != nullptr);
351  GPR_ASSERT(args->fixture != nullptr);
352  tsi_test_fixture* fixture = args->fixture;
353  tsi_handshaker* handshaker =
354  args->is_client ? fixture->client_handshaker : fixture->server_handshaker;
356  return;
357  }
358  tsi_handshaker_result* handshaker_result = nullptr;
359  unsigned char* bytes_to_send = nullptr;
360  size_t bytes_to_send_size = 0;
362  /* Receive data from peer, if available. */
363  do {
364  size_t buf_size = args->handshake_buffer_size;
365  receive_bytes_from_peer(fixture->channel, &args->handshake_buffer,
366  &buf_size, args->is_client);
367  if (buf_size > 0) {
368  args->transferred_data = true;
369  }
370  /* Peform handshaker next. */
372  handshaker, args->handshake_buffer, buf_size,
373  const_cast<const unsigned char**>(&bytes_to_send), &bytes_to_send_size,
374  &handshaker_result, &on_handshake_next_done_wrapper, args);
375  if (result != TSI_ASYNC) {
376  args->error = on_handshake_next_done(
377  result, args, bytes_to_send, bytes_to_send_size, handshaker_result);
378  if (!GRPC_ERROR_IS_NONE(args->error)) {
379  return;
380  }
381  }
382  } while (result == TSI_INCOMPLETE_DATA);
384 }
385 
387  /* Initializaiton. */
389  handshaker_args* client_args =
390  handshaker_args_create(fixture, true /* is_client */);
391  handshaker_args* server_args =
392  handshaker_args_create(fixture, false /* is_client */);
393  /* Do handshake. */
394  do {
395  client_args->transferred_data = false;
396  server_args->transferred_data = false;
397  do_handshaker_next(client_args);
398  if (!GRPC_ERROR_IS_NONE(client_args->error)) {
399  break;
400  }
401  do_handshaker_next(server_args);
402  if (!GRPC_ERROR_IS_NONE(server_args->error)) {
403  break;
404  }
405  GPR_ASSERT(client_args->transferred_data || server_args->transferred_data);
406  } while (fixture->client_result == nullptr ||
407  fixture->server_result == nullptr);
408  /* Verify handshake results. */
410  /* Cleanup. */
411  handshaker_args_destroy(client_args);
412  handshaker_args_destroy(server_args);
413 }
414 
417  tsi_frame_protector* client_frame_protector,
418  tsi_frame_protector* server_frame_protector) {
419  GPR_ASSERT(config != nullptr);
420  GPR_ASSERT(channel != nullptr);
421  GPR_ASSERT(client_frame_protector != nullptr);
422  GPR_ASSERT(server_frame_protector != nullptr);
423  /* Client sends a message to server. */
425  config, channel, client_frame_protector, true /* is_client */);
426  unsigned char* server_received_message =
427  static_cast<unsigned char*>(gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE));
428  size_t server_received_message_size = 0;
430  config, channel, server_frame_protector, server_received_message,
431  &server_received_message_size, false /* is_client */);
432  GPR_ASSERT(config->client_message_size == server_received_message_size);
433  GPR_ASSERT(memcmp(config->client_message, server_received_message,
434  server_received_message_size) == 0);
435  /* Server sends a message to client. */
437  config, channel, server_frame_protector, false /* is_client */);
438  unsigned char* client_received_message =
439  static_cast<unsigned char*>(gpr_zalloc(TSI_TEST_DEFAULT_CHANNEL_SIZE));
440  size_t client_received_message_size = 0;
442  config, channel, client_frame_protector, client_received_message,
443  &client_received_message_size, true /* is_client */);
444  GPR_ASSERT(config->server_message_size == client_received_message_size);
445  GPR_ASSERT(memcmp(config->server_message, client_received_message,
446  client_received_message_size) == 0);
447  gpr_free(server_received_message);
448  gpr_free(client_received_message);
449 }
450 
453  GPR_ASSERT(fixture != nullptr);
454  tsi_test_do_ping_pong(fixture->config, fixture->channel,
455  fixture->client_frame_protector,
456  fixture->server_frame_protector);
457 }
458 
460  /* Initialization. */
461  GPR_ASSERT(fixture != nullptr);
462  GPR_ASSERT(fixture->config != nullptr);
464  tsi_frame_protector* client_frame_protector = nullptr;
465  tsi_frame_protector* server_frame_protector = nullptr;
466  /* Perform handshake. */
468  /* Create frame protectors.*/
469  size_t client_max_output_protected_frame_size =
470  config->client_max_output_protected_frame_size;
472  fixture->client_result,
473  client_max_output_protected_frame_size == 0
474  ? nullptr
475  : &client_max_output_protected_frame_size,
476  &client_frame_protector) == TSI_OK);
477  size_t server_max_output_protected_frame_size =
478  config->server_max_output_protected_frame_size;
480  fixture->server_result,
481  server_max_output_protected_frame_size == 0
482  ? nullptr
483  : &server_max_output_protected_frame_size,
484  &server_frame_protector) == TSI_OK);
485  tsi_test_do_ping_pong(config, fixture->channel, client_frame_protector,
486  server_frame_protector);
487  /* Destroy server and client frame protectors. */
488  tsi_frame_protector_destroy(client_frame_protector);
489  tsi_frame_protector_destroy(server_frame_protector);
490 }
491 
492 static unsigned char* generate_random_message(size_t size) {
493  size_t i;
494  unsigned char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890";
495  unsigned char* output =
496  static_cast<unsigned char*>(gpr_zalloc(sizeof(unsigned char) * size));
497  for (i = 0; i < size - 1; ++i) {
498  output[i] = chars[rand() % static_cast<int>(sizeof(chars) - 1)];
499  }
500  return output;
501 }
502 
504  bool use_default_read_buffer_allocated_size,
505  bool use_default_message_buffer_allocated_size,
506  bool use_default_protected_buffer_size, bool use_default_client_message,
507  bool use_default_server_message,
508  bool use_default_client_max_output_protected_frame_size,
509  bool use_default_server_max_output_protected_frame_size) {
511  static_cast<tsi_test_frame_protector_config*>(
512  gpr_zalloc(sizeof(*config)));
513  /* Set the value for read_buffer_allocated_size. */
514  config->read_buffer_allocated_size =
515  use_default_read_buffer_allocated_size
518  /* Set the value for message_buffer_allocated_size. */
519  config->message_buffer_allocated_size =
520  use_default_message_buffer_allocated_size
523  /* Set the value for protected_buffer_size. */
524  config->protected_buffer_size = use_default_protected_buffer_size
527  /* Set the value for client message. */
528  config->client_message_size = use_default_client_message
531  config->client_message =
532  use_default_client_message
535  /* Set the value for server message. */
536  config->server_message_size = use_default_server_message
539  config->server_message =
540  use_default_server_message
543  /* Set the value for client max_output_protected_frame_size.
544  If it is 0, we pass NULL to tsi_handshaker_result_create_frame_protector(),
545  which then uses default protected frame size for it. */
546  config->client_max_output_protected_frame_size =
547  use_default_client_max_output_protected_frame_size
548  ? 0
550  /* Set the value for server max_output_protected_frame_size.
551  If it is 0, we pass NULL to tsi_handshaker_result_create_frame_protector(),
552  which then uses default protected frame size for it. */
553  config->server_max_output_protected_frame_size =
554  use_default_server_max_output_protected_frame_size
555  ? 0
557  return config;
558 }
559 
561  tsi_test_frame_protector_config* config, size_t read_buffer_allocated_size,
562  size_t message_buffer_allocated_size, size_t protected_buffer_size,
563  size_t client_max_output_protected_frame_size,
564  size_t server_max_output_protected_frame_size) {
565  GPR_ASSERT(config != nullptr);
566  config->read_buffer_allocated_size = read_buffer_allocated_size;
567  config->message_buffer_allocated_size = message_buffer_allocated_size;
568  config->protected_buffer_size = protected_buffer_size;
569  config->client_max_output_protected_frame_size =
570  client_max_output_protected_frame_size;
571  config->server_max_output_protected_frame_size =
572  server_max_output_protected_frame_size;
573 }
574 
577  if (config == nullptr) {
578  return;
579  }
580  gpr_free(config->client_message);
581  gpr_free(config->server_message);
582  gpr_free(config);
583 }
584 
586  tsi_test_channel* channel = grpc_core::Zalloc<tsi_test_channel>();
587  channel->client_channel =
589  channel->server_channel =
591  channel->bytes_written_to_client_channel = 0;
592  channel->bytes_written_to_server_channel = 0;
593  channel->bytes_read_from_client_channel = 0;
594  channel->bytes_read_from_server_channel = 0;
595  return channel;
596 }
597 
599  if (channel == nullptr) {
600  return;
601  }
602  gpr_free(channel->client_channel);
603  gpr_free(channel->server_channel);
604  gpr_free(channel);
605 }
606 
608  memset(fixture, 0, sizeof(tsi_test_fixture));
610  true, true, true, true, true, true, true);
611  fixture->handshake_buffer_size = TSI_TEST_DEFAULT_BUFFER_SIZE;
612  fixture->channel = tsi_test_channel_create();
613  fixture->test_unused_bytes = true;
614  fixture->has_client_finished_first = false;
615  gpr_mu_init(&fixture->mu);
616  gpr_cv_init(&fixture->cv);
617  fixture->notified = false;
618 }
619 
621  if (fixture == nullptr) {
622  return;
623  }
625  tsi_handshaker_destroy(fixture->client_handshaker);
626  tsi_handshaker_destroy(fixture->server_handshaker);
627  tsi_handshaker_result_destroy(fixture->client_result);
628  tsi_handshaker_result_destroy(fixture->server_result);
630  GPR_ASSERT(fixture->vtable != nullptr);
631  GPR_ASSERT(fixture->vtable->destruct != nullptr);
632  gpr_mu_destroy(&fixture->mu);
633  gpr_cv_destroy(&fixture->cv);
634  fixture->vtable->destruct(fixture);
635 }
636 
639  static_cast<tsi_test_frame_protector_fixture*>(
640  gpr_zalloc(sizeof(*fixture)));
642  true, true, true, true, true, true, true);
643  fixture->channel = tsi_test_channel_create();
644  return fixture;
645 }
646 
649  tsi_frame_protector* client_frame_protector,
650  tsi_frame_protector* server_frame_protector) {
651  GPR_ASSERT(fixture != nullptr);
652  fixture->client_frame_protector = client_frame_protector;
653  fixture->server_frame_protector = server_frame_protector;
654 }
655 
658  if (fixture == nullptr) {
659  return;
660  }
663  tsi_frame_protector_destroy(fixture->client_frame_protector);
664  tsi_frame_protector_destroy(fixture->server_frame_protector);
665  gpr_free(fixture);
666 }
gpr_cv_signal
GPRAPI void gpr_cv_signal(gpr_cv *cv)
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
tsi_test_channel::client_channel
uint8_t * client_channel
Definition: transport_security_test_lib.h:124
TSI_TEST_BIG_MESSAGE_SIZE
#define TSI_TEST_BIG_MESSAGE_SIZE
Definition: transport_security_test_lib.h:36
gpr_mu_unlock
GPRAPI void gpr_mu_unlock(gpr_mu *mu)
tsi_test_frame_protector_fixture_create
tsi_test_frame_protector_fixture * tsi_test_frame_protector_fixture_create()
Definition: transport_security_test_lib.cc:637
GRPC_ERROR_NONE
#define GRPC_ERROR_NONE
Definition: error.h:234
log.h
handshaker_args::handshake_buffer_size
size_t handshake_buffer_size
Definition: transport_security_test_lib.cc:51
tsi_test_channel::bytes_read_from_client_channel
size_t bytes_read_from_client_channel
Definition: transport_security_test_lib.h:130
tsi_test_channel::server_channel
uint8_t * server_channel
Definition: transport_security_test_lib.h:125
tsi_test_frame_protector_config_set_buffer_size
void tsi_test_frame_protector_config_set_buffer_size(tsi_test_frame_protector_config *config, size_t read_buffer_allocated_size, size_t message_buffer_allocated_size, size_t protected_buffer_size, size_t client_max_output_protected_frame_size, size_t server_max_output_protected_frame_size)
Definition: transport_security_test_lib.cc:560
memset
return memset(p, 0, total)
receive_bytes_from_peer
static void receive_bytes_from_peer(tsi_test_channel *test_channel, unsigned char **buf, size_t *buf_size, bool is_client)
Definition: transport_security_test_lib.cc:161
on_handshake_next_done_wrapper
static void on_handshake_next_done_wrapper(tsi_result result, void *user_data, const unsigned char *bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result *handshaker_result)
Definition: transport_security_test_lib.cc:332
tsi_handshaker
Definition: transport_security.h:84
tsi_handshaker_destroy
void tsi_handshaker_destroy(tsi_handshaker *self)
Definition: transport_security.cc:237
handshaker_args::handshake_buffer
unsigned char * handshake_buffer
Definition: transport_security_test_lib.cc:50
tsi_handshaker_result_get_unused_bytes
tsi_result tsi_handshaker_result_get_unused_bytes(const tsi_handshaker_result *self, const unsigned char **bytes, size_t *bytes_size)
Definition: transport_security.cc:277
maybe_append_unused_bytes
static void maybe_append_unused_bytes(handshaker_args *args)
Definition: transport_security_test_lib.cc:144
string.h
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
gpr_free
GPRAPI void gpr_free(void *ptr)
Definition: alloc.cc:51
tsi_test_frame_protector_config_destroy
void tsi_test_frame_protector_config_destroy(tsi_test_frame_protector_config *config)
Definition: transport_security_test_lib.cc:575
error
grpc_error_handle error
Definition: retry_filter.cc:499
tsi_test_fixture_init
void tsi_test_fixture_init(tsi_test_fixture *fixture)
Definition: transport_security_test_lib.cc:607
handshaker_args::appended_unused_bytes
bool appended_unused_bytes
Definition: transport_security_test_lib.cc:54
tsi_test_frame_protector_fixture
Definition: transport_security_test_lib.h:110
is_handshake_finished_properly
static bool is_handshake_finished_properly(handshaker_args *args)
Definition: transport_security_test_lib.cc:340
bytes_received
static int bytes_received
Definition: test-callback-stack.c:44
handshaker_args::transferred_data
bool transferred_data
Definition: transport_security_test_lib.cc:53
tsi_test_fixture_destroy
void tsi_test_fixture_destroy(tsi_test_fixture *fixture)
Definition: transport_security_test_lib.cc:620
gpr_inf_future
GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type)
Definition: src/core/lib/gpr/time.cc:55
TSI_TEST_SMALL_MESSAGE_BUFFER_ALLOCATED_SIZE
#define TSI_TEST_SMALL_MESSAGE_BUFFER_ALLOCATED_SIZE
Definition: transport_security_test_lib.h:30
handshaker_args_create
static handshaker_args * handshaker_args_create(tsi_test_fixture *fixture, bool is_client)
Definition: transport_security_test_lib.cc:58
transport_security_test_lib.h
TSI_TEST_SMALL_READ_BUFFER_ALLOCATED_SIZE
#define TSI_TEST_SMALL_READ_BUFFER_ALLOCATED_SIZE
Definition: transport_security_test_lib.h:28
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
handshaker_args_destroy
static void handshaker_args_destroy(handshaker_args *args)
Definition: transport_security_test_lib.cc:72
message
char * message
Definition: libuv/docs/code/tty-gravity/main.c:12
tsi_frame_protector_protect_flush
tsi_result tsi_frame_protector_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.cc:104
handshaker_args::error
grpc_error_handle error
Definition: transport_security_test_lib.cc:55
TSI_TEST_DEFAULT_CHANNEL_SIZE
#define TSI_TEST_DEFAULT_CHANNEL_SIZE
Definition: transport_security_test_lib.h:35
tsi_test_channel_create
static tsi_test_channel * tsi_test_channel_create()
Definition: transport_security_test_lib.cc:585
tsi_frame_protector_unprotect
tsi_result tsi_frame_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: transport_security.cc:119
tsi_test_do_ping_pong
static void tsi_test_do_ping_pong(tsi_test_frame_protector_config *config, tsi_test_channel *channel, tsi_frame_protector *client_frame_protector, tsi_frame_protector *server_frame_protector)
Definition: transport_security_test_lib.cc:415
gpr_zalloc
GPRAPI void * gpr_zalloc(size_t size)
Definition: alloc.cc:40
memory.h
tsi_test_channel
Definition: transport_security_test_lib.h:120
gpr_mu_destroy
GPRAPI void gpr_mu_destroy(gpr_mu *mu)
TSI_OK
@ TSI_OK
Definition: transport_security_interface.h:32
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
channel
wrapped_grpc_channel * channel
Definition: src/php/ext/grpc/call.h:33
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
fixture
static const char fixture[]
Definition: test-fs-copyfile.c:36
gpr_cv_destroy
GPRAPI void gpr_cv_destroy(gpr_cv *cv)
config
struct config_s config
gmock_output_test.output
output
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
on_handshake_next_done
grpc_error_handle on_handshake_next_done(tsi_result result, void *user_data, const unsigned char *bytes_to_send, size_t bytes_to_send_size, tsi_handshaker_result *handshaker_result)
Definition: transport_security_test_lib.cc:293
tsi_test_do_round_trip
void tsi_test_do_round_trip(tsi_test_fixture *fixture)
Definition: transport_security_test_lib.cc:459
grpc_set_tsi_error_result
grpc_error_handle grpc_set_tsi_error_result(grpc_error_handle error, tsi_result result)
Definition: tsi_error.cc:23
handshaker_args::is_client
bool is_client
Definition: transport_security_test_lib.cc:52
do_handshaker_next
static void do_handshaker_next(handshaker_args *args)
Definition: transport_security_test_lib.cc:348
gpr_mu_init
GPRAPI void gpr_mu_init(gpr_mu *mu)
grpc.h
tsi_test_frame_protector_send_message_to_peer
void tsi_test_frame_protector_send_message_to_peer(tsi_test_frame_protector_config *config, tsi_test_channel *channel, tsi_frame_protector *protector, bool is_client)
Definition: transport_security_test_lib.cc:187
bytes_read
static size_t bytes_read
Definition: test-ipc-heavy-traffic-deadlock-bug.c:47
tsi_result
tsi_result
Definition: transport_security_interface.h:31
done
struct tab * done
Definition: bloaty/third_party/zlib/examples/enough.c:176
tsi_test_frame_protector_config_create
tsi_test_frame_protector_config * tsi_test_frame_protector_config_create(bool use_default_read_buffer_allocated_size, bool use_default_message_buffer_allocated_size, bool use_default_protected_buffer_size, bool use_default_client_message, bool use_default_server_message, bool use_default_client_max_output_protected_frame_size, bool use_default_server_max_output_protected_frame_size)
Definition: transport_security_test_lib.cc:503
handshaker_args
Definition: transport_security_test_lib.cc:48
gpr_cv_wait
GPRAPI int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline)
gpr_mu_lock
GPRAPI void gpr_mu_lock(gpr_mu *mu)
TSI_TEST_DEFAULT_BUFFER_SIZE
#define TSI_TEST_DEFAULT_BUFFER_SIZE
Definition: transport_security_test_lib.h:33
tsi_test_do_handshake
void tsi_test_do_handshake(tsi_test_fixture *fixture)
Definition: transport_security_test_lib.cc:386
TSI_TEST_SMALL_CLIENT_MAX_OUTPUT_PROTECTED_FRAME_SIZE
#define TSI_TEST_SMALL_CLIENT_MAX_OUTPUT_PROTECTED_FRAME_SIZE
Definition: transport_security_test_lib.h:31
tsi_error.h
tsi_test_channel_destroy
static void tsi_test_channel_destroy(tsi_test_channel *channel)
Definition: transport_security_test_lib.cc:598
GRPC_ERROR_CREATE_FROM_STATIC_STRING
#define GRPC_ERROR_CREATE_FROM_STATIC_STRING(desc)
Definition: error.h:291
TSI_TEST_DEFAULT_PROTECTED_BUFFER_SIZE
#define TSI_TEST_DEFAULT_PROTECTED_BUFFER_SIZE
Definition: transport_security_test_lib.h:34
tsi_handshaker_next
tsi_result tsi_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 cb, void *user_data)
Definition: transport_security.cc:215
check_handshake_results
static void check_handshake_results(tsi_test_fixture *fixture)
Definition: transport_security_test_lib.cc:106
tsi_test_channel::bytes_written_to_server_channel
size_t bytes_written_to_server_channel
Definition: transport_security_test_lib.h:128
tsi_handshaker_result_destroy
void tsi_handshaker_result_destroy(tsi_handshaker_result *self)
Definition: transport_security.cc:288
TSI_INCOMPLETE_DATA
@ TSI_INCOMPLETE_DATA
Definition: transport_security_interface.h:36
bytes
uint8 bytes[10]
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc:153
tsi_test_channel::bytes_written_to_client_channel
size_t bytes_written_to_client_channel
Definition: transport_security_test_lib.h:127
TSI_ASYNC
@ TSI_ASYNC
Definition: transport_security_interface.h:45
tsi_test_frame_protector_config
Definition: transport_security_test_lib.h:134
tsi_test_channel::bytes_read_from_server_channel
size_t bytes_read_from_server_channel
Definition: transport_security_test_lib.h:131
tsi_frame_protector_protect
tsi_result tsi_frame_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: transport_security.cc:87
check_unused_bytes
static void check_unused_bytes(tsi_test_fixture *fixture)
Definition: transport_security_test_lib.cc:87
alloc.h
tsi_test_fixture
Definition: transport_security_test_lib.h:73
notification_signal
static void notification_signal(tsi_test_fixture *fixture)
Definition: transport_security_test_lib.cc:32
TSI_TEST_SMALL_SERVER_MAX_OUTPUT_PROTECTED_FRAME_SIZE
#define TSI_TEST_SMALL_SERVER_MAX_OUTPUT_PROTECTED_FRAME_SIZE
Definition: transport_security_test_lib.h:32
GRPC_ERROR_UNREF
#define GRPC_ERROR_UNREF(err)
Definition: error.h:262
config_s
Definition: bloaty/third_party/zlib/deflate.c:120
tsi_handshaker_result_create_frame_protector
tsi_result tsi_handshaker_result_create_frame_protector(const tsi_handshaker_result *self, size_t *max_output_protected_frame_size, tsi_frame_protector **protector)
Definition: transport_security.cc:266
tsi_handshaker_result
Definition: transport_security.h:121
TSI_TEST_SMALL_PROTECTED_BUFFER_SIZE
#define TSI_TEST_SMALL_PROTECTED_BUFFER_SIZE
Definition: transport_security_test_lib.h:29
generate_random_message
static unsigned char * generate_random_message(size_t size)
Definition: transport_security_test_lib.cc:492
bytes_written
static size_t bytes_written
Definition: test-ipc-heavy-traffic-deadlock-bug.c:46
TSI_TEST_UNUSED_BYTES
#define TSI_TEST_UNUSED_BYTES
Definition: transport_security_test_lib.h:40
tsi_frame_protector
Definition: transport_security.h:51
tsi_frame_protector_destroy
void tsi_frame_protector_destroy(tsi_frame_protector *self)
Definition: transport_security.cc:135
setup_handshakers
static void setup_handshakers(tsi_test_fixture *fixture)
Definition: transport_security_test_lib.cc:80
handshaker_args::fixture
tsi_test_fixture * fixture
Definition: transport_security_test_lib.cc:49
grpc_error
Definition: error_internal.h:42
send_bytes_to_peer
static void send_bytes_to_peer(tsi_test_channel *test_channel, const unsigned char *buf, size_t buf_size, bool is_client)
Definition: transport_security_test_lib.cc:126
tsi_test_frame_protector_fixture_destroy
void tsi_test_frame_protector_fixture_destroy(tsi_test_frame_protector_fixture *fixture)
Definition: transport_security_test_lib.cc:656
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
tsi_test_frame_protector_fixture_init
void tsi_test_frame_protector_fixture_init(tsi_test_frame_protector_fixture *fixture, tsi_frame_protector *client_frame_protector, tsi_frame_protector *server_frame_protector)
Definition: transport_security_test_lib.cc:647
GPR_CLOCK_REALTIME
@ GPR_CLOCK_REALTIME
Definition: gpr_types.h:39
TSI_TEST_SMALL_MESSAGE_SIZE
#define TSI_TEST_SMALL_MESSAGE_SIZE
Definition: transport_security_test_lib.h:37
handshaker_args
struct handshaker_args handshaker_args
notification_wait
static void notification_wait(tsi_test_fixture *fixture)
Definition: transport_security_test_lib.cc:39
tsi_test_frame_protector_do_round_trip_no_handshake
void tsi_test_frame_protector_do_round_trip_no_handshake(tsi_test_frame_protector_fixture *fixture)
Definition: transport_security_test_lib.cc:451
tsi_test_frame_protector_receive_message_from_peer
void tsi_test_frame_protector_receive_message_from_peer(tsi_test_frame_protector_config *config, tsi_test_channel *channel, tsi_frame_protector *protector, unsigned char *message, size_t *bytes_received, bool is_client)
Definition: transport_security_test_lib.cc:237
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
gpr_cv_init
GPRAPI void gpr_cv_init(gpr_cv *cv)
GRPC_ERROR_IS_NONE
#define GRPC_ERROR_IS_NONE(err)
Definition: error.h:241


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