| 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 |
|
| 19 |
#ifndef GRPC_CORE_TSI_FAKE_TRANSPORT_SECURITY_H |
| 20 |
#define GRPC_CORE_TSI_FAKE_TRANSPORT_SECURITY_H |
| 21 |
|
| 22 |
#include <grpc/support/port_platform.h> |
| 23 |
|
| 24 |
#include "src/core/lib/slice/slice_internal.h" |
| 25 |
#include "src/core/tsi/transport_security_interface.h" |
| 26 |
|
| 27 |
/* Value for the TSI_CERTIFICATE_TYPE_PEER_PROPERTY property for FAKE certs. */ |
| 28 |
#define TSI_FAKE_CERTIFICATE_TYPE "FAKE" |
| 29 |
/* Value of the TSI_SECURITY_LEVEL_PEER_PROPERTY property for FAKE certs. */ |
| 30 |
#define TSI_FAKE_SECURITY_LEVEL "TSI_SECURITY_NONE" |
| 31 |
|
| 32 |
/* Creates a fake handshaker that will create a fake frame protector. |
| 33 |
|
| 34 |
No cryptography is performed in these objects. They just simulate handshake |
| 35 |
messages going back and forth for the handshaker and do some framing on |
| 36 |
cleartext data for the protector. */ |
| 37 |
tsi_handshaker* tsi_create_fake_handshaker(int is_client); |
| 38 |
|
| 39 |
/* Creates a protector directly without going through the handshake phase. */ |
| 40 |
tsi_frame_protector* tsi_create_fake_frame_protector( |
| 41 |
size_t* max_protected_frame_size); |
| 42 |
|
| 43 |
/* Creates a zero-copy protector directly without going through the handshake |
| 44 |
* phase. */ |
| 45 |
tsi_zero_copy_grpc_protector* tsi_create_fake_zero_copy_grpc_protector( |
| 46 |
size_t* max_protected_frame_size); |
| 47 |
|
| 48 |
/* Given a buffer containing slices encrypted by a fake_zero_copy_protector |
| 49 |
* it parses these protected slices to return the total frame size of the first |
| 50 |
* contained frame */ |
| 51 |
uint32_t tsi_fake_zero_copy_grpc_protector_next_frame_size( |
| 52 |
const grpc_slice_buffer* protected_slices); |
| 53 |
#endif /* GRPC_CORE_TSI_FAKE_TRANSPORT_SECURITY_H */ |