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/security/credentials/alts/grpc_alts_credentials_options.h" 27 #include "src/core/tsi/alts_transport_security.h" 28 #include "src/core/tsi/transport_security.h" 29 #include "src/core/tsi/transport_security_interface.h" 30 31 #define TSI_ALTS_SERVICE_ACCOUNT_PEER_PROPERTY "service_accont" 32 #define TSI_ALTS_CERTIFICATE_TYPE "ALTS" 33 #define TSI_ALTS_RPC_VERSIONS "rpc_versions" 34 35 const size_t kTsiAltsNumOfPeerProperties = 3; 36 37 /** 38 * Main struct for ALTS TSI handshaker. All APIs in the header are 39 * thread-comptabile. 40 */ 41 typedef struct alts_tsi_handshaker alts_tsi_handshaker; 42 43 /** 44 * This method creates a ALTS TSI handshaker instance. 45 * 46 * - options: ALTS credentials options containing information passed from TSI 47 * caller (e.g., rpc protocol versions). 48 * - target_name: the name of the endpoint that the channel is connecting to, 49 * and will be used for secure naming check. 50 * - handshaker_service_url: address of ALTS handshaker service in the format of 51 * "host:port". 52 * - is_client: boolean value indicating if the handshaker is used at the client 53 * (is_client = true) or server (is_client = false) side. 54 * - self: address of ALTS TSI handshaker instance to be returned from the 55 * method. 56 * 57 * It returns TSI_OK on success and an error status code on failure. 58 */ 59 tsi_result alts_tsi_handshaker_create( 60 const grpc_alts_credentials_options* options, const char* target_name, 61 const char* handshaker_service_url, bool is_client, tsi_handshaker** self); 62 63 /** 64 * This method handles handshaker response returned from ALTS handshaker 65 * service. 66 * 67 * - handshaker: ALTS TSI handshaker instance. 68 * - recv_buffer: buffer holding data received from the handshaker service. 69 * - status: status of the grpc call made to the handshaker service. 70 * - details: error details of the grpc call made to the handshaker service. 71 * - cb: callback function of ALTS TSI event. 72 * - user_data: argument of callback function. 73 * - is_ok: a boolean value indicating if the handshaker response is ok to read. 74 * 75 */ 76 void alts_tsi_handshaker_handle_response(alts_tsi_handshaker* handshaker, 77 grpc_byte_buffer* recv_buffer, 78 grpc_status_code status, 79 grpc_slice* details, 80 tsi_handshaker_on_next_done_cb cb, 81 void* user_data, bool is_ok); 82 83 #endif /* GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_TSI_HANDSHAKER_H */ 84