security_handshaker.cc
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 
20 
22 
23 #include <limits.h>
24 #include <stdint.h>
25 #include <string.h>
26 
27 #include <limits>
28 #include <memory>
29 #include <string>
30 
31 #include "absl/base/attributes.h"
32 #include "absl/container/inlined_vector.h"
33 #include "absl/memory/memory.h"
34 #include "absl/strings/str_cat.h"
35 #include "absl/strings/string_view.h"
36 #include "absl/types/optional.h"
37 
38 #include <grpc/grpc_security.h>
40 #include <grpc/slice.h>
41 #include <grpc/slice_buffer.h>
42 #include <grpc/support/alloc.h>
43 #include <grpc/support/log.h>
44 
67 
68 #define GRPC_INITIAL_HANDSHAKE_BUFFER_SIZE 256
69 
70 namespace grpc_core {
71 
72 namespace {
73 
74 class SecurityHandshaker : public Handshaker {
75  public:
76  SecurityHandshaker(tsi_handshaker* handshaker,
77  grpc_security_connector* connector,
78  const grpc_channel_args* args);
79  ~SecurityHandshaker() override;
80  void Shutdown(grpc_error_handle why) override;
81  void DoHandshake(grpc_tcp_server_acceptor* acceptor,
83  HandshakerArgs* args) override;
84  const char* name() const override { return "security"; }
85 
86  private:
87  grpc_error_handle DoHandshakerNextLocked(const unsigned char* bytes_received,
88  size_t bytes_received_size);
89 
90  grpc_error_handle OnHandshakeNextDoneLocked(
91  tsi_result result, const unsigned char* bytes_to_send,
92  size_t bytes_to_send_size, tsi_handshaker_result* handshaker_result);
93  void HandshakeFailedLocked(grpc_error_handle error);
94  void CleanupArgsForFailureLocked();
95 
96  static void OnHandshakeDataReceivedFromPeerFn(void* arg,
98  static void OnHandshakeDataSentToPeerFn(void* arg, grpc_error_handle error);
99  static void OnHandshakeDataReceivedFromPeerFnScheduler(
100  void* arg, grpc_error_handle error);
101  static void OnHandshakeDataSentToPeerFnScheduler(void* arg,
103  static void OnHandshakeNextDoneGrpcWrapper(
104  tsi_result result, void* user_data, const unsigned char* bytes_to_send,
105  size_t bytes_to_send_size, tsi_handshaker_result* handshaker_result);
106  static void OnPeerCheckedFn(void* arg, grpc_error_handle error);
107  void OnPeerCheckedInner(grpc_error_handle error);
108  size_t MoveReadBufferIntoHandshakeBuffer();
109  grpc_error_handle CheckPeerLocked();
110 
111  // State set at creation time.
113  RefCountedPtr<grpc_security_connector> connector_;
114 
116 
117  bool is_shutdown_ = false;
118  // Endpoint and read buffer to destroy after a shutdown.
121 
122  // State saved while performing the handshake.
123  HandshakerArgs* args_ = nullptr;
125 
127  unsigned char* handshake_buffer_;
132  RefCountedPtr<grpc_auth_context> auth_context_;
134  size_t max_frame_size_ = 0;
135 };
136 
137 SecurityHandshaker::SecurityHandshaker(tsi_handshaker* handshaker,
138  grpc_security_connector* connector,
139  const grpc_channel_args* args)
140  : handshaker_(handshaker),
141  connector_(connector->Ref(DEBUG_LOCATION, "handshake")),
144  static_cast<uint8_t*>(gpr_malloc(handshake_buffer_size_))),
147  {0, 0, std::numeric_limits<int>::max()})) {
149  GRPC_CLOSURE_INIT(&on_peer_checked_, &SecurityHandshaker::OnPeerCheckedFn,
150  this, grpc_schedule_on_exec_ctx);
151 }
152 
153 SecurityHandshaker::~SecurityHandshaker() {
156  if (endpoint_to_destroy_ != nullptr) {
158  }
159  if (read_buffer_to_destroy_ != nullptr) {
162  }
165  auth_context_.reset(DEBUG_LOCATION, "handshake");
166  connector_.reset(DEBUG_LOCATION, "handshake");
167 }
168 
169 size_t SecurityHandshaker::MoveReadBufferIntoHandshakeBuffer() {
170  size_t bytes_in_read_buffer = args_->read_buffer->length;
171  if (handshake_buffer_size_ < bytes_in_read_buffer) {
172  handshake_buffer_ = static_cast<uint8_t*>(
173  gpr_realloc(handshake_buffer_, bytes_in_read_buffer));
174  handshake_buffer_size_ = bytes_in_read_buffer;
175  }
176  size_t offset = 0;
177  while (args_->read_buffer->count > 0) {
178  grpc_slice* next_slice = grpc_slice_buffer_peek_first(args_->read_buffer);
180  GRPC_SLICE_LENGTH(*next_slice));
181  offset += GRPC_SLICE_LENGTH(*next_slice);
183  }
184  return bytes_in_read_buffer;
185 }
186 
187 // Set args_ fields to NULL, saving the endpoint and read buffer for
188 // later destruction.
189 void SecurityHandshaker::CleanupArgsForFailureLocked() {
190  endpoint_to_destroy_ = args_->endpoint;
191  args_->endpoint = nullptr;
192  read_buffer_to_destroy_ = args_->read_buffer;
193  args_->read_buffer = nullptr;
195  args_->args = nullptr;
196 }
197 
198 // If the handshake failed or we're shutting down, clean up and invoke the
199 // callback with the error.
200 void SecurityHandshaker::HandshakeFailedLocked(grpc_error_handle error) {
201  if (GRPC_ERROR_IS_NONE(error)) {
202  // If we were shut down after the handshake succeeded but before an
203  // endpoint callback was invoked, we need to generate our own error.
204  error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshaker shutdown");
205  }
206  gpr_log(GPR_DEBUG, "Security handshake failed: %s",
208  if (!is_shutdown_) {
210  // TODO(ctiller): It is currently necessary to shutdown endpoints
211  // before destroying them, even if we know that there are no
212  // pending read/write callbacks. This should be fixed, at which
213  // point this can be removed.
215  // Not shutting down, so the write failed. Clean up before
216  // invoking the callback.
217  CleanupArgsForFailureLocked();
218  // Set shutdown to true so that subsequent calls to
219  // security_handshaker_shutdown() do nothing.
220  is_shutdown_ = true;
221  }
222  // Invoke callback.
224 }
225 
226 namespace {
227 
228 RefCountedPtr<channelz::SocketNode::Security>
229 MakeChannelzSecurityFromAuthContext(grpc_auth_context* auth_context) {
230  RefCountedPtr<channelz::SocketNode::Security> security =
231  MakeRefCounted<channelz::SocketNode::Security>();
232  // TODO(yashykt): Currently, we are assuming TLS by default and are only able
233  // to fill in the remote certificate but we should ideally be able to fill in
234  // other fields in
235  // https://github.com/grpc/grpc/blob/fcd43e90304862a823316b224ee733d17a8cfd90/src/proto/grpc/channelz/channelz.proto#L326
236  // from grpc_auth_context.
237  security->type = channelz::SocketNode::Security::ModelType::kTls;
238  security->tls = absl::make_optional<channelz::SocketNode::Security::Tls>();
240  auth_context, GRPC_X509_PEM_CERT_PROPERTY_NAME);
242  if (prop != nullptr) {
243  security->tls->remote_certificate =
244  std::string(prop->value, prop->value_length);
245  }
246  return security;
247 }
248 
249 } // namespace
250 
251 void SecurityHandshaker::OnPeerCheckedInner(grpc_error_handle error) {
252  MutexLock lock(&mu_);
254  HandshakeFailedLocked(error);
255  return;
256  }
257  // Get unused bytes.
258  const unsigned char* unused_bytes = nullptr;
259  size_t unused_bytes_size = 0;
261  handshaker_result_, &unused_bytes, &unused_bytes_size);
262  if (result != TSI_OK) {
263  HandshakeFailedLocked(grpc_set_tsi_error_result(
265  "TSI handshaker result does not provide unused bytes"),
266  result));
267  return;
268  }
269  // Check whether we need to wrap the endpoint.
270  tsi_frame_protector_type frame_protector_type;
272  handshaker_result_, &frame_protector_type);
273  if (result != TSI_OK) {
274  HandshakeFailedLocked(grpc_set_tsi_error_result(
276  "TSI handshaker result does not implement "
277  "get_frame_protector_type"),
278  result));
279  return;
280  }
281  tsi_zero_copy_grpc_protector* zero_copy_protector = nullptr;
282  tsi_frame_protector* protector = nullptr;
283  switch (frame_protector_type) {
287  // Create zero-copy frame protector.
290  &zero_copy_protector);
291  if (result != TSI_OK) {
292  HandshakeFailedLocked(grpc_set_tsi_error_result(
294  "Zero-copy frame protector creation failed"),
295  result));
296  return;
297  }
298  break;
300  // Create normal frame protector.
303  &protector);
304  if (result != TSI_OK) {
305  HandshakeFailedLocked(
307  "Frame protector creation failed"),
308  result));
309  return;
310  }
311  break;
313  break;
314  }
315  bool has_frame_protector =
316  zero_copy_protector != nullptr || protector != nullptr;
317  // If we have a frame protector, create a secure endpoint.
318  if (has_frame_protector) {
319  if (unused_bytes_size > 0) {
321  reinterpret_cast<const char*>(unused_bytes), unused_bytes_size);
322  args_->endpoint =
323  grpc_secure_endpoint_create(protector, zero_copy_protector,
324  args_->endpoint, &slice, args_->args, 1);
326  } else {
327  args_->endpoint =
328  grpc_secure_endpoint_create(protector, zero_copy_protector,
329  args_->endpoint, nullptr, args_->args, 0);
330  }
331  } else if (unused_bytes_size > 0) {
332  // Not wrapping the endpoint, so just pass along unused bytes.
334  reinterpret_cast<const char*>(unused_bytes), unused_bytes_size);
335  grpc_slice_buffer_add(args_->read_buffer, slice);
336  }
337  // Done with handshaker result.
339  handshaker_result_ = nullptr;
340  absl::InlinedVector<grpc_arg, 2> args_to_add = {
341  // Add auth context to channel args.
343  };
344  RefCountedPtr<channelz::SocketNode::Security> channelz_security;
345  // Add channelz channel args only if frame protector is created.
346  if (has_frame_protector) {
347  channelz_security =
348  MakeChannelzSecurityFromAuthContext(auth_context_.get());
349  args_to_add.push_back(channelz_security->MakeChannelArg());
350  }
351  grpc_channel_args* tmp_args = args_->args;
352  args_->args = grpc_channel_args_copy_and_add(tmp_args, args_to_add.data(),
353  args_to_add.size());
354  grpc_channel_args_destroy(tmp_args);
355  // Invoke callback.
357  // Set shutdown to true so that subsequent calls to
358  // security_handshaker_shutdown() do nothing.
359  is_shutdown_ = true;
360 }
361 
362 void SecurityHandshaker::OnPeerCheckedFn(void* arg, grpc_error_handle error) {
363  RefCountedPtr<SecurityHandshaker>(static_cast<SecurityHandshaker*>(arg))
364  ->OnPeerCheckedInner(GRPC_ERROR_REF(error));
365 }
366 
367 grpc_error_handle SecurityHandshaker::CheckPeerLocked() {
368  tsi_peer peer;
371  if (result != TSI_OK) {
373  GRPC_ERROR_CREATE_FROM_STATIC_STRING("Peer extraction failed"), result);
374  }
375  connector_->check_peer(peer, args_->endpoint, &auth_context_,
377  return GRPC_ERROR_NONE;
378 }
379 
380 grpc_error_handle SecurityHandshaker::OnHandshakeNextDoneLocked(
381  tsi_result result, const unsigned char* bytes_to_send,
382  size_t bytes_to_send_size, tsi_handshaker_result* handshaker_result) {
384  // Handshaker was shutdown.
385  if (is_shutdown_) {
386  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshaker shutdown");
387  }
388  // Read more if we need to.
389  if (result == TSI_INCOMPLETE_DATA) {
390  GPR_ASSERT(bytes_to_send_size == 0);
392  args_->endpoint, args_->read_buffer,
395  &SecurityHandshaker::OnHandshakeDataReceivedFromPeerFnScheduler,
396  this, grpc_schedule_on_exec_ctx),
397  /*urgent=*/true, /*min_progress_size=*/1);
398  return error;
399  }
400  if (result != TSI_OK) {
401  auto* security_connector =
403  absl::string_view connector_type = "<unknown>";
404  if (security_connector != nullptr) {
405  connector_type = security_connector->type().name();
406  }
409  absl::StrCat(connector_type, " handshake failed")),
410  result);
411  }
412  // Update handshaker result.
413  if (handshaker_result != nullptr) {
414  GPR_ASSERT(handshaker_result_ == nullptr);
415  handshaker_result_ = handshaker_result;
416  }
417  if (bytes_to_send_size > 0) {
418  // Send data to peer, if needed.
420  reinterpret_cast<const char*>(bytes_to_send), bytes_to_send_size);
422  grpc_slice_buffer_add(&outgoing_, to_send);
424  args_->endpoint, &outgoing_,
427  &SecurityHandshaker::OnHandshakeDataSentToPeerFnScheduler, this,
428  grpc_schedule_on_exec_ctx),
429  nullptr, /*max_frame_size=*/INT_MAX);
430  } else if (handshaker_result == nullptr) {
431  // There is nothing to send, but need to read from peer.
433  args_->endpoint, args_->read_buffer,
436  &SecurityHandshaker::OnHandshakeDataReceivedFromPeerFnScheduler,
437  this, grpc_schedule_on_exec_ctx),
438  /*urgent=*/true, /*min_progress_size=*/1);
439  } else {
440  // Handshake has finished, check peer and so on.
441  error = CheckPeerLocked();
442  }
443  return error;
444 }
445 
446 void SecurityHandshaker::OnHandshakeNextDoneGrpcWrapper(
447  tsi_result result, void* user_data, const unsigned char* bytes_to_send,
448  size_t bytes_to_send_size, tsi_handshaker_result* handshaker_result) {
449  RefCountedPtr<SecurityHandshaker> h(
450  static_cast<SecurityHandshaker*>(user_data));
451  MutexLock lock(&h->mu_);
452  grpc_error_handle error = h->OnHandshakeNextDoneLocked(
453  result, bytes_to_send, bytes_to_send_size, handshaker_result);
454  if (!GRPC_ERROR_IS_NONE(error)) {
455  h->HandshakeFailedLocked(error);
456  } else {
457  h.release(); // Avoid unref
458  }
459 }
460 
461 grpc_error_handle SecurityHandshaker::DoHandshakerNextLocked(
462  const unsigned char* bytes_received, size_t bytes_received_size) {
463  // Invoke TSI handshaker.
464  const unsigned char* bytes_to_send = nullptr;
465  size_t bytes_to_send_size = 0;
466  tsi_handshaker_result* hs_result = nullptr;
468  handshaker_, bytes_received, bytes_received_size, &bytes_to_send,
469  &bytes_to_send_size, &hs_result, &OnHandshakeNextDoneGrpcWrapper, this);
470  if (result == TSI_ASYNC) {
471  // Handshaker operating asynchronously. Nothing else to do here;
472  // callback will be invoked in a TSI thread.
473  return GRPC_ERROR_NONE;
474  }
475  // Handshaker returned synchronously. Invoke callback directly in
476  // this thread with our existing exec_ctx.
477  return OnHandshakeNextDoneLocked(result, bytes_to_send, bytes_to_send_size,
478  hs_result);
479 }
480 
481 // This callback might be run inline while we are still holding on to the mutex,
482 // so schedule OnHandshakeDataReceivedFromPeerFn on ExecCtx to avoid a deadlock.
483 void SecurityHandshaker::OnHandshakeDataReceivedFromPeerFnScheduler(
484  void* arg, grpc_error_handle error) {
485  SecurityHandshaker* h = static_cast<SecurityHandshaker*>(arg);
486  ExecCtx::Run(
488  GRPC_CLOSURE_INIT(&h->on_handshake_data_received_from_peer_,
489  &SecurityHandshaker::OnHandshakeDataReceivedFromPeerFn,
490  h, grpc_schedule_on_exec_ctx),
492 }
493 
494 void SecurityHandshaker::OnHandshakeDataReceivedFromPeerFn(
495  void* arg, grpc_error_handle error) {
496  RefCountedPtr<SecurityHandshaker> h(static_cast<SecurityHandshaker*>(arg));
497  MutexLock lock(&h->mu_);
498  if (!GRPC_ERROR_IS_NONE(error) || h->is_shutdown_) {
500  "Handshake read failed", &error, 1));
501  return;
502  }
503  // Copy all slices received.
504  size_t bytes_received_size = h->MoveReadBufferIntoHandshakeBuffer();
505  // Call TSI handshaker.
506  error = h->DoHandshakerNextLocked(h->handshake_buffer_, bytes_received_size);
507  if (!GRPC_ERROR_IS_NONE(error)) {
508  h->HandshakeFailedLocked(error);
509  } else {
510  h.release(); // Avoid unref
511  }
512 }
513 
514 // This callback might be run inline while we are still holding on to the mutex,
515 // so schedule OnHandshakeDataSentToPeerFn on ExecCtx to avoid a deadlock.
516 void SecurityHandshaker::OnHandshakeDataSentToPeerFnScheduler(
517  void* arg, grpc_error_handle error) {
518  SecurityHandshaker* h = static_cast<SecurityHandshaker*>(arg);
519  ExecCtx::Run(
521  GRPC_CLOSURE_INIT(&h->on_handshake_data_sent_to_peer_,
522  &SecurityHandshaker::OnHandshakeDataSentToPeerFn, h,
523  grpc_schedule_on_exec_ctx),
525 }
526 
527 void SecurityHandshaker::OnHandshakeDataSentToPeerFn(void* arg,
529  RefCountedPtr<SecurityHandshaker> h(static_cast<SecurityHandshaker*>(arg));
530  MutexLock lock(&h->mu_);
531  if (!GRPC_ERROR_IS_NONE(error) || h->is_shutdown_) {
533  "Handshake write failed", &error, 1));
534  return;
535  }
536  // We may be done.
537  if (h->handshaker_result_ == nullptr) {
539  h->args_->endpoint, h->args_->read_buffer,
541  &h->on_handshake_data_received_from_peer_,
542  &SecurityHandshaker::OnHandshakeDataReceivedFromPeerFnScheduler,
543  h.get(), grpc_schedule_on_exec_ctx),
544  /*urgent=*/true, /*min_progress_size=*/1);
545  } else {
546  error = h->CheckPeerLocked();
547  if (!GRPC_ERROR_IS_NONE(error)) {
548  h->HandshakeFailedLocked(error);
549  return;
550  }
551  }
552  h.release(); // Avoid unref
553 }
554 
555 //
556 // public handshaker API
557 //
558 
560  MutexLock lock(&mu_);
561  if (!is_shutdown_) {
562  is_shutdown_ = true;
563  connector_->cancel_check_peer(&on_peer_checked_, GRPC_ERROR_REF(why));
566  CleanupArgsForFailureLocked();
567  }
568  GRPC_ERROR_UNREF(why);
569 }
570 
571 void SecurityHandshaker::DoHandshake(grpc_tcp_server_acceptor* /*acceptor*/,
573  HandshakerArgs* args) {
574  auto ref = Ref();
575  MutexLock lock(&mu_);
576  args_ = args;
578  size_t bytes_received_size = MoveReadBufferIntoHandshakeBuffer();
580  DoHandshakerNextLocked(handshake_buffer_, bytes_received_size);
581  if (!GRPC_ERROR_IS_NONE(error)) {
582  HandshakeFailedLocked(error);
583  } else {
584  ref.release(); // Avoid unref
585  }
586 }
587 
588 //
589 // FailHandshaker
590 //
591 
592 class FailHandshaker : public Handshaker {
593  public:
594  const char* name() const override { return "security_fail"; }
595  void Shutdown(grpc_error_handle why) override { GRPC_ERROR_UNREF(why); }
596  void DoHandshake(grpc_tcp_server_acceptor* /*acceptor*/,
598  HandshakerArgs* args) override {
600  "Failed to create security handshaker");
602  grpc_endpoint_destroy(args->endpoint);
603  args->endpoint = nullptr;
605  args->args = nullptr;
607  gpr_free(args->read_buffer);
608  args->read_buffer = nullptr;
610  }
611 
612  private:
613  ~FailHandshaker() override = default;
614 };
615 
616 //
617 // handshaker factories
618 //
619 
620 class ClientSecurityHandshakerFactory : public HandshakerFactory {
621  public:
622  void AddHandshakers(const grpc_channel_args* args,
623  grpc_pollset_set* interested_parties,
624  HandshakeManager* handshake_mgr) override {
625  auto* security_connector =
626  reinterpret_cast<grpc_channel_security_connector*>(
628  if (security_connector) {
629  security_connector->add_handshakers(args, interested_parties,
630  handshake_mgr);
631  }
632  }
633  ~ClientSecurityHandshakerFactory() override = default;
634 };
635 
636 class ServerSecurityHandshakerFactory : public HandshakerFactory {
637  public:
638  void AddHandshakers(const grpc_channel_args* args,
639  grpc_pollset_set* interested_parties,
640  HandshakeManager* handshake_mgr) override {
641  auto* security_connector =
642  reinterpret_cast<grpc_server_security_connector*>(
644  if (security_connector) {
645  security_connector->add_handshakers(args, interested_parties,
646  handshake_mgr);
647  }
648  }
649  ~ServerSecurityHandshakerFactory() override = default;
650 };
651 
652 } // namespace
653 
654 //
655 // exported functions
656 //
657 
659  tsi_handshaker* handshaker, grpc_security_connector* connector,
660  const grpc_channel_args* args) {
661  // If no TSI handshaker was created, return a handshaker that always fails.
662  // Otherwise, return a real security handshaker.
663  if (handshaker == nullptr) {
664  return MakeRefCounted<FailHandshaker>();
665  } else {
666  return MakeRefCounted<SecurityHandshaker>(handshaker, connector, args);
667  }
668 }
669 
671  builder->handshaker_registry()->RegisterHandshakerFactory(
672  false /* at_start */, HANDSHAKER_CLIENT,
673  absl::make_unique<ClientSecurityHandshakerFactory>());
674  builder->handshaker_registry()->RegisterHandshakerFactory(
675  false /* at_start */, HANDSHAKER_SERVER,
676  absl::make_unique<ServerSecurityHandshakerFactory>());
677 }
678 
679 } // namespace grpc_core
680 
682  tsi_handshaker* handshaker, grpc_security_connector* connector,
683  const grpc_channel_args* args) {
684  return SecurityHandshakerCreate(handshaker, connector, args).release();
685 }
GRPC_CLOSURE_INIT
#define GRPC_CLOSURE_INIT(closure, cb, cb_arg, scheduler)
Definition: closure.h:115
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
grpc_auth_context
Definition: security_context.h:63
regen-readme.it
it
Definition: regen-readme.py:15
GRPC_ERROR_NONE
#define GRPC_ERROR_NONE
Definition: error.h:234
log.h
core_configuration.h
grpc_security_handshaker_create
grpc_handshaker * grpc_security_handshaker_create(tsi_handshaker *handshaker, grpc_security_connector *connector, const grpc_channel_args *args)
Definition: security_handshaker.cc:681
MutexLock
#define MutexLock(x)
Definition: bloaty/third_party/re2/util/mutex.h:125
on_handshake_done_
grpc_closure * on_handshake_done_
Definition: security_handshaker.cc:124
absl::StrCat
std::string StrCat(const AlphaNum &a, const AlphaNum &b)
Definition: abseil-cpp/absl/strings/str_cat.cc:98
grpc_server_security_connector::add_handshakers
virtual void add_handshakers(const grpc_channel_args *args, grpc_pollset_set *interested_parties, grpc_core::HandshakeManager *handshake_mgr)=0
handshaker_
tsi_handshaker * handshaker_
Definition: security_handshaker.cc:112
grpc_server_security_connector
Definition: security_connector.h:171
grpc_core::RefCountedPtr::get
T * get() const
Definition: ref_counted_ptr.h:146
read_buffer_to_destroy_
grpc_slice_buffer * read_buffer_to_destroy_
Definition: security_handshaker.cc:120
tsi_handshaker
Definition: transport_security.h:84
grpc_core::SecurityHandshakerCreate
RefCountedPtr< Handshaker > SecurityHandshakerCreate(tsi_handshaker *handshaker, grpc_security_connector *connector, const grpc_channel_args *args)
Creates a security handshaker using handshaker.
Definition: security_handshaker.cc:658
slice.h
tsi_handshaker_destroy
void tsi_handshaker_destroy(tsi_handshaker *self)
Definition: transport_security.cc:237
grpc_core
Definition: call_metric_recorder.h:31
grpc_core::CoreConfiguration::Builder
Definition: core_configuration.h:41
grpc_pollset_set
struct grpc_pollset_set grpc_pollset_set
Definition: iomgr_fwd.h:23
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
string.h
grpc_core::RefCountedPtr::reset
void reset(T *value=nullptr)
Definition: ref_counted_ptr.h:111
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
gpr_free
GPRAPI void gpr_free(void *ptr)
Definition: alloc.cc:51
grpc_endpoint_read
void grpc_endpoint_read(grpc_endpoint *ep, grpc_slice_buffer *slices, grpc_closure *cb, bool urgent, int min_progress_size)
Definition: endpoint.cc:25
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
error
grpc_error_handle error
Definition: retry_filter.cc:499
bytes_received
static int bytes_received
Definition: test-callback-stack.c:44
gpr_malloc
GPRAPI void * gpr_malloc(size_t size)
Definition: alloc.cc:29
closure.h
TSI_FRAME_PROTECTOR_NORMAL
@ TSI_FRAME_PROTECTOR_NORMAL
Definition: transport_security_interface.h:73
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING
#define GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(desc, errs, count)
Definition: error.h:307
setup.name
name
Definition: setup.py:542
secure_endpoint.h
args_
HandshakerArgs * args_
Definition: security_handshaker.cc:123
grpc_security.h
channelz.h
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
handshake_buffer_size_
size_t handshake_buffer_size_
Definition: security_handshaker.cc:126
grpc_channel_args
Definition: grpc_types.h:132
TSI_FRAME_PROTECTOR_ZERO_COPY
@ TSI_FRAME_PROTECTOR_ZERO_COPY
Definition: transport_security_interface.h:77
GRPC_ARG_TSI_MAX_FRAME_SIZE
#define GRPC_ARG_TSI_MAX_FRAME_SIZE
Definition: grpc_types.h:290
tsi_handshaker_result_get_frame_protector_type
tsi_result tsi_handshaker_result_get_frame_protector_type(const tsi_handshaker_result *self, tsi_frame_protector_type *frame_protector_type)
Definition: transport_security.cc:254
grpc_auth_property_iterator_next
const GRPCAPI grpc_auth_property * grpc_auth_property_iterator_next(grpc_auth_property_iterator *it)
Definition: security_context.cc:182
grpc_auth_context_to_arg
grpc_arg grpc_auth_context_to_arg(grpc_auth_context *c)
Definition: security_context.cc:305
max_frame_size_
size_t max_frame_size_
Definition: security_handshaker.cc:134
grpc_core::Handshaker
Definition: handshaker.h:84
grpc_core::HANDSHAKER_SERVER
@ HANDSHAKER_SERVER
Definition: handshaker_registry.h:36
grpc_security_connector
Definition: security_connector.h:61
TSI_OK
@ TSI_OK
Definition: transport_security_interface.h:32
DEBUG_LOCATION
#define DEBUG_LOCATION
Definition: debug_location.h:41
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
profile_analyzer.builder
builder
Definition: profile_analyzer.py:159
grpc_core::HANDSHAKER_CLIENT
@ HANDSHAKER_CLIENT
Definition: handshaker_registry.h:35
connector_
RefCountedPtr< grpc_security_connector > connector_
Definition: security_handshaker.cc:113
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
tsi_frame_protector_type
tsi_frame_protector_type
Definition: transport_security_interface.h:69
grpc_core::RefCountedPtr
Definition: ref_counted_ptr.h:35
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
gpr_realloc
GPRAPI void * gpr_realloc(void *p, size_t size)
Definition: alloc.cc:56
gen_stats_data.c_str
def c_str(s, encoding='ascii')
Definition: gen_stats_data.py:38
handshake_buffer_
unsigned char * handshake_buffer_
Definition: security_handshaker.cc:127
max
int max
Definition: bloaty/third_party/zlib/examples/enough.c:170
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
on_handshake_data_sent_to_peer_
grpc_closure on_handshake_data_sent_to_peer_
Definition: security_handshaker.cc:129
grpc_secure_endpoint_create
grpc_endpoint * grpc_secure_endpoint_create(struct tsi_frame_protector *protector, struct tsi_zero_copy_grpc_protector *zero_copy_protector, grpc_endpoint *to_wrap, grpc_slice *leftover_slices, const grpc_channel_args *channel_args, size_t leftover_nslices)
Definition: secure_endpoint.cc:563
slice
grpc_slice slice
Definition: src/core/lib/surface/server.cc:467
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
grpc_auth_property_iterator
Definition: grpc_security.h:36
handshaker_registry.h
grpc_auth_property::value_length
size_t value_length
Definition: grpc_security.h:46
absl::InlinedVector::push_back
void push_back(const_reference v)
Definition: abseil-cpp/absl/container/inlined_vector.h:682
tsi_handshaker_result_create_zero_copy_grpc_protector
tsi_result tsi_handshaker_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_grpc.cc:24
tsi_result
tsi_result
Definition: transport_security_interface.h:31
GRPC_SLICE_START_PTR
#define GRPC_SLICE_START_PTR(slice)
Definition: include/grpc/impl/codegen/slice.h:101
slice_buffer.h
grpc_channel_args_destroy
void grpc_channel_args_destroy(grpc_channel_args *a)
Definition: channel_args.cc:360
arg
Definition: cmdline.cc:40
ref
unsigned ref
Definition: cxa_demangle.cpp:4909
grpc_slice
Definition: include/grpc/impl/codegen/slice.h:65
absl::InlinedVector::data
pointer data() noexcept
Definition: abseil-cpp/absl/container/inlined_vector.h:302
endpoint_to_destroy_
grpc_endpoint * endpoint_to_destroy_
Definition: security_handshaker.cc:119
on_handshake_data_received_from_peer_
grpc_closure on_handshake_data_received_from_peer_
Definition: security_handshaker.cc:130
grpc_auth_property::value
char * value
Definition: grpc_security.h:45
error.h
grpc_endpoint_shutdown
void grpc_endpoint_shutdown(grpc_endpoint *ep, grpc_error_handle why)
Definition: endpoint.cc:49
benchmark::Shutdown
void Shutdown()
Definition: benchmark/src/benchmark.cc:607
absl::InlinedVector::size
size_type size() const noexcept
Definition: abseil-cpp/absl/container/inlined_vector.h:270
slice_internal.h
grpc_channel_security_connector::add_handshakers
virtual void add_handshakers(const grpc_channel_args *args, grpc_pollset_set *interested_parties, grpc_core::HandshakeManager *handshake_mgr)=0
Registers handshakers with handshake_mgr.
outgoing_
grpc_slice_buffer outgoing_
Definition: security_handshaker.cc:128
grpc_endpoint_destroy
void grpc_endpoint_destroy(grpc_endpoint *ep)
Definition: endpoint.cc:53
grpc_core::SecurityRegisterHandshakerFactories
void SecurityRegisterHandshakerFactories(CoreConfiguration::Builder *builder)
Registers security handshaker factories.
Definition: security_handshaker.cc:670
grpc_slice_buffer_peek_first
grpc_slice * grpc_slice_buffer_peek_first(grpc_slice_buffer *sb)
Definition: slice_internal.h:45
grpc_slice_buffer_init
GPRAPI void grpc_slice_buffer_init(grpc_slice_buffer *sb)
Definition: slice/slice_buffer.cc:116
tsi_handshaker_result_extract_peer
tsi_result tsi_handshaker_result_extract_peer(const tsi_handshaker_result *self, tsi_peer *peer)
Definition: transport_security.cc:244
tsi_error.h
stdint.h
GRPC_ERROR_CREATE_FROM_STATIC_STRING
#define GRPC_ERROR_CREATE_FROM_STATIC_STRING(desc)
Definition: error.h:291
auth_context_
RefCountedPtr< grpc_auth_context > auth_context_
Definition: security_handshaker.cc:132
GRPC_SLICE_LENGTH
#define GRPC_SLICE_LENGTH(slice)
Definition: include/grpc/impl/codegen/slice.h:104
grpc_auth_property
Definition: grpc_security.h:43
tsi_handshaker_shutdown
void tsi_handshaker_shutdown(tsi_handshaker *self)
Definition: transport_security.cc:229
on_peer_checked_
grpc_closure on_peer_checked_
Definition: security_handshaker.cc:131
GRPC_INITIAL_HANDSHAKE_BUFFER_SIZE
#define GRPC_INITIAL_HANDSHAKE_BUFFER_SIZE
Definition: security_handshaker.cc:68
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
security_handshaker.h
tsi_peer
Definition: transport_security_interface.h:238
GRPC_X509_PEM_CERT_PROPERTY_NAME
#define GRPC_X509_PEM_CERT_PROPERTY_NAME
Definition: grpc_security_constants.h:33
security_context.h
grpc_slice_buffer_add
GPRAPI void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice slice)
Definition: slice/slice_buffer.cc:170
grpc_slice_from_copied_buffer
GPRAPI grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len)
Definition: slice/slice.cc:170
GRPC_ERROR_REF
#define GRPC_ERROR_REF(err)
Definition: error.h:261
tsi_handshaker_result_destroy
void tsi_handshaker_result_destroy(tsi_handshaker_result *self)
Definition: transport_security.cc:288
debug_location.h
TSI_INCOMPLETE_DATA
@ TSI_INCOMPLETE_DATA
Definition: transport_security_interface.h:36
TSI_ASYNC
@ TSI_ASYNC
Definition: transport_security_interface.h:45
grpc_tcp_server_acceptor
Definition: tcp_server.h:36
grpc_error_std_string
std::string grpc_error_std_string(grpc_error_handle error)
Definition: error.cc:944
GRPC_ERROR_CREATE_FROM_CPP_STRING
#define GRPC_ERROR_CREATE_FROM_CPP_STRING(desc)
Definition: error.h:297
handshaker_factory.h
alloc.h
google::protobuf.internal::Mutex
WrappedMutex Mutex
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/mutex.h:113
grpc_security_constants.h
arg
struct arg arg
exec_ctx.h
slice_refcount.h
handshaker.h
unique_type_name.h
GRPC_ERROR_UNREF
#define GRPC_ERROR_UNREF(err)
Definition: error.h:262
ref_counted_ptr.h
grpc_security_connector_find_in_args
grpc_security_connector * grpc_security_connector_find_in_args(const grpc_channel_args *args)
Definition: security_connector.cc:117
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
channel_args.h
tsi_handshaker_result
Definition: transport_security.h:121
grpc_slice_buffer_destroy_internal
void grpc_slice_buffer_destroy_internal(grpc_slice_buffer *sb)
Definition: slice/slice_buffer.cc:123
grpc_endpoint_write
void grpc_endpoint_write(grpc_endpoint *ep, grpc_slice_buffer *slices, grpc_closure *cb, void *arg, int max_frame_size)
Definition: endpoint.cc:30
grpc_channel_security_connector
Definition: security_connector.h:118
GPR_DEBUG
#define GPR_DEBUG
Definition: include/grpc/impl/codegen/log.h:55
handshaker_result_
tsi_handshaker_result * handshaker_result_
Definition: security_handshaker.cc:133
TSI_FRAME_PROTECTOR_NORMAL_OR_ZERO_COPY
@ TSI_FRAME_PROTECTOR_NORMAL_OR_ZERO_COPY
Definition: transport_security_interface.h:83
grpc_auth_context_find_properties_by_name
GRPCAPI grpc_auth_property_iterator grpc_auth_context_find_properties_by_name(const grpc_auth_context *ctx, const char *name)
Definition: security_context.cc:207
grpc_slice_buffer
Definition: include/grpc/impl/codegen/slice.h:83
tsi_frame_protector
Definition: transport_security.h:51
iomgr_fwd.h
absl::InlinedVector
Definition: abseil-cpp/absl/container/inlined_vector.h:69
tsi_zero_copy_grpc_protector
Definition: transport_security_grpc.h:79
endpoint.h
googletest-break-on-failure-unittest.Run
def Run(command)
Definition: bloaty/third_party/googletest/googletest/test/googletest-break-on-failure-unittest.py:76
is_shutdown_
bool is_shutdown_
Definition: security_handshaker.cc:117
grpc_error
Definition: error_internal.h:42
grpc_channel_args_find_integer
int grpc_channel_args_find_integer(const grpc_channel_args *args, const char *name, const grpc_integer_options options)
Definition: channel_args.cc:425
testing::Ref
internal::RefMatcher< T & > Ref(T &x)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:8628
tcp_server.h
grpc_slice_buffer_remove_first
void grpc_slice_buffer_remove_first(grpc_slice_buffer *sb)
Definition: slice/slice_buffer.cc:449
ABSL_FALLTHROUGH_INTENDED
#define ABSL_FALLTHROUGH_INTENDED
Definition: abseil-cpp/absl/base/attributes.h:641
absl::str_format_internal::LengthMod::h
@ h
grpc_closure
Definition: closure.h:56
grpc_endpoint
Definition: endpoint.h:105
grpc_slice_buffer_reset_and_unref_internal
void grpc_slice_buffer_reset_and_unref_internal(grpc_slice_buffer *sb)
Definition: slice/slice_buffer.cc:238
on_handshake_done
static void on_handshake_done(void *arg, grpc_error_handle error)
Definition: ssl_server_fuzzer.cc:45
sync.h
mu_
Mutex mu_
Definition: security_handshaker.cc:115
grpc_channel_args_copy_and_add
grpc_channel_args * grpc_channel_args_copy_and_add(const grpc_channel_args *src, const grpc_arg *to_add, size_t num_to_add)
Definition: channel_args.cc:224
offset
voidpf uLong offset
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:142
grpc_slice_unref_internal
void grpc_slice_unref_internal(const grpc_slice &slice)
Definition: slice_refcount.h:39
GRPC_ERROR_IS_NONE
#define GRPC_ERROR_IS_NONE(err)
Definition: error.h:241
transport_security_grpc.h
port_platform.h
TSI_FRAME_PROTECTOR_NONE
@ TSI_FRAME_PROTECTOR_NONE
Definition: transport_security_interface.h:86


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