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/crypto/null_decrypter.h" | 5 #include "net/quic/crypto/null_decrypter.h" |
6 #include "net/quic/quic_utils.h" | 6 #include "net/quic/quic_utils.h" |
7 #include "net/quic/quic_data_reader.h" | 7 #include "net/quic/quic_data_reader.h" |
8 | 8 |
9 using base::StringPiece; | 9 using base::StringPiece; |
10 using std::string; | 10 using std::string; |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 | 13 |
14 bool NullDecrypter::SetKey(StringPiece key) { | 14 bool NullDecrypter::SetKey(StringPiece key) { return key.empty(); } |
15 return key.empty(); | |
16 } | |
17 | 15 |
18 bool NullDecrypter::SetNoncePrefix(StringPiece nonce_prefix) { | 16 bool NullDecrypter::SetNoncePrefix(StringPiece nonce_prefix) { |
19 return nonce_prefix.empty(); | 17 return nonce_prefix.empty(); |
20 } | 18 } |
21 | 19 |
22 bool NullDecrypter::Decrypt(StringPiece /*nonce*/, | 20 bool NullDecrypter::Decrypt(StringPiece /*nonce*/, |
23 StringPiece associated_data, | 21 StringPiece associated_data, |
24 StringPiece ciphertext, | 22 StringPiece ciphertext, |
25 unsigned char* output, | 23 unsigned char* output, |
26 size_t* output_length) { | 24 size_t* output_length) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // TODO(rch): avoid buffer copy here | 60 // TODO(rch): avoid buffer copy here |
63 string buffer = associated_data.as_string(); | 61 string buffer = associated_data.as_string(); |
64 plaintext.AppendToString(&buffer); | 62 plaintext.AppendToString(&buffer); |
65 | 63 |
66 if (hash != QuicUtils::FNV1a_128_Hash(buffer.data(), buffer.length())) { | 64 if (hash != QuicUtils::FNV1a_128_Hash(buffer.data(), buffer.length())) { |
67 return NULL; | 65 return NULL; |
68 } | 66 } |
69 return new QuicData(plaintext.data(), plaintext.length()); | 67 return new QuicData(plaintext.data(), plaintext.length()); |
70 } | 68 } |
71 | 69 |
72 StringPiece NullDecrypter::GetKey() const { | 70 StringPiece NullDecrypter::GetKey() const { return StringPiece(); } |
73 return StringPiece(); | |
74 } | |
75 | 71 |
76 StringPiece NullDecrypter::GetNoncePrefix() const { | 72 StringPiece NullDecrypter::GetNoncePrefix() const { return StringPiece(); } |
77 return StringPiece(); | |
78 } | |
79 | 73 |
80 } // namespace net | 74 } // namespace net |
OLD | NEW |