Andrew Top | 0d1858f | 2019-05-15 22:01:47 -0700 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "net/quic/mock_encrypter.h" |
| 6 | |
| 7 | #include "net/third_party/quic/core/quic_data_writer.h" |
| 8 | #include "net/third_party/quic/core/quic_utils.h" |
| 9 | #include "starboard/memory.h" |
| 10 | |
| 11 | using quic::DiversificationNonce; |
| 12 | using quic::Perspective; |
| 13 | using quic::QuicPacketNumber; |
| 14 | using quic::QuicStringPiece; |
| 15 | using quic::QuicTransportVersion; |
| 16 | |
| 17 | namespace net { |
| 18 | |
| 19 | MockEncrypter::MockEncrypter(Perspective perspective) {} |
| 20 | |
| 21 | bool MockEncrypter::SetKey(QuicStringPiece key) { |
| 22 | return key.empty(); |
| 23 | } |
| 24 | |
| 25 | bool MockEncrypter::SetNoncePrefix(QuicStringPiece nonce_prefix) { |
| 26 | return nonce_prefix.empty(); |
| 27 | } |
| 28 | |
| 29 | bool MockEncrypter::SetIV(QuicStringPiece iv) { |
| 30 | return iv.empty(); |
| 31 | } |
| 32 | |
Chad Duffin | ac9ac06 | 2019-07-23 10:06:45 -0700 | [diff] [blame] | 33 | bool MockEncrypter::EncryptPacket(uint64_t /*packet_number*/, |
Andrew Top | 0d1858f | 2019-05-15 22:01:47 -0700 | [diff] [blame] | 34 | QuicStringPiece associated_data, |
| 35 | QuicStringPiece plaintext, |
| 36 | char* output, |
| 37 | size_t* output_length, |
| 38 | size_t max_output_length) { |
| 39 | if (max_output_length < plaintext.size()) { |
| 40 | return false; |
| 41 | } |
Kaido Kert | 6f3fc44 | 2021-06-25 11:58:59 -0700 | [diff] [blame] | 42 | memcpy(output, plaintext.data(), plaintext.length()); |
Andrew Top | 0d1858f | 2019-05-15 22:01:47 -0700 | [diff] [blame] | 43 | *output_length = plaintext.size(); |
| 44 | return true; |
| 45 | } |
| 46 | |
| 47 | size_t MockEncrypter::GetKeySize() const { |
| 48 | return 0; |
| 49 | } |
| 50 | |
| 51 | size_t MockEncrypter::GetNoncePrefixSize() const { |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | size_t MockEncrypter::GetIVSize() const { |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | size_t MockEncrypter::GetMaxPlaintextSize(size_t ciphertext_size) const { |
| 60 | return ciphertext_size; |
| 61 | } |
| 62 | |
| 63 | size_t MockEncrypter::GetCiphertextSize(size_t plaintext_size) const { |
| 64 | return plaintext_size; |
| 65 | } |
| 66 | |
| 67 | QuicStringPiece MockEncrypter::GetKey() const { |
| 68 | return QuicStringPiece(); |
| 69 | } |
| 70 | |
| 71 | QuicStringPiece MockEncrypter::GetNoncePrefix() const { |
| 72 | return QuicStringPiece(); |
| 73 | } |
| 74 | |
| 75 | } // namespace net |