blob: a42755027fbc06205cef4fb766cf81e15ae56fac [file] [log] [blame]
Andrew Top0d1858f2019-05-15 22:01:47 -07001// 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
11using quic::DiversificationNonce;
12using quic::Perspective;
13using quic::QuicPacketNumber;
14using quic::QuicStringPiece;
15using quic::QuicTransportVersion;
16
17namespace net {
18
19MockEncrypter::MockEncrypter(Perspective perspective) {}
20
21bool MockEncrypter::SetKey(QuicStringPiece key) {
22 return key.empty();
23}
24
25bool MockEncrypter::SetNoncePrefix(QuicStringPiece nonce_prefix) {
26 return nonce_prefix.empty();
27}
28
29bool MockEncrypter::SetIV(QuicStringPiece iv) {
30 return iv.empty();
31}
32
Chad Duffinac9ac062019-07-23 10:06:45 -070033bool MockEncrypter::EncryptPacket(uint64_t /*packet_number*/,
Andrew Top0d1858f2019-05-15 22:01:47 -070034 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 Kert6f3fc442021-06-25 11:58:59 -070042 memcpy(output, plaintext.data(), plaintext.length());
Andrew Top0d1858f2019-05-15 22:01:47 -070043 *output_length = plaintext.size();
44 return true;
45}
46
47size_t MockEncrypter::GetKeySize() const {
48 return 0;
49}
50
51size_t MockEncrypter::GetNoncePrefixSize() const {
52 return 0;
53}
54
55size_t MockEncrypter::GetIVSize() const {
56 return 0;
57}
58
59size_t MockEncrypter::GetMaxPlaintextSize(size_t ciphertext_size) const {
60 return ciphertext_size;
61}
62
63size_t MockEncrypter::GetCiphertextSize(size_t plaintext_size) const {
64 return plaintext_size;
65}
66
67QuicStringPiece MockEncrypter::GetKey() const {
68 return QuicStringPiece();
69}
70
71QuicStringPiece MockEncrypter::GetNoncePrefix() const {
72 return QuicStringPiece();
73}
74
75} // namespace net