Debian Codegraph @

src/core/tsi/alts/handshaker/alts_tsi_handshaker.h

raw
1 /*
2 *
3 * Copyright 2018 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_ALTS_HANDSHAKER_ALTS_TSI_HANDSHAKER_H
20 #define GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_TSI_HANDSHAKER_H
21
22 #include <grpc/support/port_platform.h>
23
24 #include <grpc/grpc.h>
25
26 #include "src/core/lib/iomgr/pollset_set.h"
27 #include "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h"
28 #include "src/core/tsi/alts/handshaker/alts_handshaker_client.h"
29 #include "src/core/tsi/transport_security.h"
30 #include "src/core/tsi/transport_security_interface.h"
31 #include "src/proto/grpc/gcp/altscontext.upb.h"
32 #include "src/proto/grpc/gcp/handshaker.upb.h"
33
34 #define TSI_ALTS_SERVICE_ACCOUNT_PEER_PROPERTY "service_account"
35 #define TSI_ALTS_CERTIFICATE_TYPE "ALTS"
36 #define TSI_ALTS_RPC_VERSIONS "rpc_versions"
37 #define TSI_ALTS_CONTEXT "alts_context"
38
39 const size_t kTsiAltsNumOfPeerProperties = 5;
40
41 // Frame size negotiation extends send frame size range to
42 // [kTsiAltsMinFrameSize, kTsiAltsMaxFrameSize].
43 const size_t kTsiAltsMinFrameSize = 16 * 1024;
44 const size_t kTsiAltsMaxFrameSize = 1024 * 1024;
45
46 typedef struct alts_tsi_handshaker alts_tsi_handshaker;
47
48 /**
49 * This method creates a ALTS TSI handshaker instance.
50 *
51 * - options: ALTS credentials options containing information passed from TSI
52 * caller (e.g., rpc protocol versions).
53 * - target_name: the name of the endpoint that the channel is connecting to,
54 * and will be used for secure naming check.
55 * - handshaker_service_url: address of ALTS handshaker service in the format of
56 * "host:port".
57 * - is_client: boolean value indicating if the handshaker is used at the client
58 * (is_client = true) or server (is_client = false) side.
59 * - interested_parties: set of pollsets interested in this connection.
60 * - self: address of ALTS TSI handshaker instance to be returned from the
61 * method.
62 * - user_specified_max_frame_size: Determines the maximum frame size used by
63 * frame protector that is specified via user. If unspecified, the value is 0.
64 *
65 * It returns TSI_OK on success and an error status code on failure. Note that
66 * if interested_parties is nullptr, a dedicated TSI thread will be created and
67 * used.
68 */
69 tsi_result alts_tsi_handshaker_create(
70 const grpc_alts_credentials_options* options, const char* target_name,
71 const char* handshaker_service_url, bool is_client,
72 grpc_pollset_set* interested_parties, tsi_handshaker** self,
73 size_t user_specified_max_frame_size);
74
75 /**
76 * This method creates an ALTS TSI handshaker result instance.
77 *
78 * - resp: data received from the handshaker service.
79 * - is_client: a boolean value indicating if the result belongs to a
80 * client or not.
81 * - result: address of ALTS TSI handshaker result instance.
82 */
83 tsi_result alts_tsi_handshaker_result_create(grpc_gcp_HandshakerResp* resp,
84 bool is_client,
85 tsi_handshaker_result** result);
86
87 /**
88 * This method sets unused bytes of ALTS TSI handshaker result instance.
89 *
90 * - result: an ALTS TSI handshaker result instance.
91 * - recv_bytes: data received from the handshaker service.
92 * - bytes_consumed: size of data consumed by the handshaker service.
93 */
94 void alts_tsi_handshaker_result_set_unused_bytes(tsi_handshaker_result* result,
95 grpc_slice* recv_bytes,
96 size_t bytes_consumed);
97
98 /**
99 * This method returns a boolean value indicating if an ALTS TSI handshaker
100 * has been shutdown or not.
101 */
102 bool alts_tsi_handshaker_has_shutdown(alts_tsi_handshaker* handshaker);
103
104 #endif /* GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_TSI_HANDSHAKER_H */