| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/quic/core/crypto/null_encrypter.h" | 5 #include "net/quic/core/crypto/null_encrypter.h" |
| 6 | 6 |
| 7 #include "net/quic/core/quic_data_writer.h" | 7 #include "net/quic/core/quic_data_writer.h" |
| 8 #include "net/quic/core/quic_utils.h" | 8 #include "net/quic/core/quic_utils.h" |
| 9 | 9 |
| 10 using base::StringPiece; | 10 using base::StringPiece; |
| 11 using std::string; | 11 using std::string; |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 const size_t kHashSizeShort = 12; // size of uint128 serialized short | 15 const size_t kHashSizeShort = 12; // size of uint128 serialized short |
| 16 | 16 |
| 17 NullEncrypter::NullEncrypter(Perspective perspective) | 17 NullEncrypter::NullEncrypter(Perspective perspective) |
| 18 : perspective_(perspective) {} | 18 : perspective_(perspective) {} |
| 19 | 19 |
| 20 bool NullEncrypter::SetKey(StringPiece key) { | 20 bool NullEncrypter::SetKey(StringPiece key) { |
| 21 return key.empty(); | 21 return key.empty(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 bool NullEncrypter::SetNoncePrefix(StringPiece nonce_prefix) { | 24 bool NullEncrypter::SetNoncePrefix(StringPiece nonce_prefix) { |
| 25 return nonce_prefix.empty(); | 25 return nonce_prefix.empty(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool NullEncrypter::EncryptPacket(QuicVersion version, | 28 bool NullEncrypter::EncryptPacket(QuicVersion version, |
| 29 QuicPathId /*path_id*/, | |
| 30 QuicPacketNumber /*packet_number*/, | 29 QuicPacketNumber /*packet_number*/, |
| 31 StringPiece associated_data, | 30 StringPiece associated_data, |
| 32 StringPiece plaintext, | 31 StringPiece plaintext, |
| 33 char* output, | 32 char* output, |
| 34 size_t* output_length, | 33 size_t* output_length, |
| 35 size_t max_output_length) { | 34 size_t max_output_length) { |
| 36 const size_t len = plaintext.size() + GetHashLength(); | 35 const size_t len = plaintext.size() + GetHashLength(); |
| 37 if (max_output_length < len) { | 36 if (max_output_length < len) { |
| 38 return false; | 37 return false; |
| 39 } | 38 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 79 |
| 81 StringPiece NullEncrypter::GetNoncePrefix() const { | 80 StringPiece NullEncrypter::GetNoncePrefix() const { |
| 82 return StringPiece(); | 81 return StringPiece(); |
| 83 } | 82 } |
| 84 | 83 |
| 85 size_t NullEncrypter::GetHashLength() const { | 84 size_t NullEncrypter::GetHashLength() const { |
| 86 return kHashSizeShort; | 85 return kHashSizeShort; |
| 87 } | 86 } |
| 88 | 87 |
| 89 } // namespace net | 88 } // namespace net |
| OLD | NEW |