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_SRC_CORE_TSI_ALTS_FRAME_PROTECTOR_ALTS_FRAME_PROTECTOR_H
20 #define GRPC_SRC_CORE_TSI_ALTS_FRAME_PROTECTOR_ALTS_FRAME_PROTECTOR_H
21 
22 #include <grpc/support/port_platform.h>
23 
24 #include <stdbool.h>
25 
26 #include "src/core/tsi/transport_security_interface.h"
27 
28 typedef struct alts_frame_protector alts_frame_protector;
29 
30 ///
31 /// TODO: Add a parameter to the interface to support the use of
32 /// different record protocols within a frame protector.
33 ///
34 /// This method creates a frame protector.
35 ///
36 ///- key: a symmetric key used to seal/unseal frames.
37 ///- key_size: the size of symmetric key.
38 ///- is_client: a flag indicating if the frame protector will be used at client
39 ///  (is_client = true) or server (is_client = false) side.
40 ///- is_rekey: a flag indicating if the frame protector will use an AEAD with
41 ///  rekeying.
42 ///- max_protected_frame_size: an in/out parameter indicating max frame size
43 ///  to be used by the frame protector. If it is nullptr, the default frame
44 ///  size will be used. Otherwise, the provided frame size will be adjusted (if
45 ///  not falling into a valid frame range) and used.
46 ///- self: a pointer to the frame protector returned from the method.
47 ///
48 /// This method returns TSI_OK on success and TSI_INTERNAL_ERROR otherwise.
49 ///
50 tsi_result alts_create_frame_protector(const uint8_t* key, size_t key_size,
51                                        bool is_client, bool is_rekey,
52                                        size_t* max_protected_frame_size,
53                                        tsi_frame_protector** self);
54 
55 #endif  // GRPC_SRC_CORE_TSI_ALTS_FRAME_PROTECTOR_ALTS_FRAME_PROTECTOR_H
56