| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/aead_base_decrypter.h" | 5 #include "net/quic/crypto/aead_base_decrypter.h" |
| 6 | 6 |
| 7 #include <pk11pub.h> | 7 #include <pk11pub.h> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "crypto/scoped_nss_types.h" | 10 #include "crypto/scoped_nss_types.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 DCHECK_EQ(nonce_prefix.size(), nonce_prefix_size_); | 42 DCHECK_EQ(nonce_prefix.size(), nonce_prefix_size_); |
| 43 if (nonce_prefix.size() != nonce_prefix_size_) { | 43 if (nonce_prefix.size() != nonce_prefix_size_) { |
| 44 return false; | 44 return false; |
| 45 } | 45 } |
| 46 memcpy(nonce_prefix_, nonce_prefix.data(), nonce_prefix.size()); | 46 memcpy(nonce_prefix_, nonce_prefix.data(), nonce_prefix.size()); |
| 47 return true; | 47 return true; |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool AeadBaseDecrypter::DecryptPacket(QuicPathId path_id, | 50 bool AeadBaseDecrypter::DecryptPacket(QuicPathId path_id, |
| 51 QuicPacketNumber packet_number, | 51 QuicPacketNumber packet_number, |
| 52 const StringPiece& associated_data, | 52 StringPiece associated_data, |
| 53 const StringPiece& ciphertext, | 53 StringPiece ciphertext, |
| 54 char* output, | 54 char* output, |
| 55 size_t* output_length, | 55 size_t* output_length, |
| 56 size_t max_output_length) { | 56 size_t max_output_length) { |
| 57 if (ciphertext.length() < auth_tag_size_) { | 57 if (ciphertext.length() < auth_tag_size_) { |
| 58 return false; | 58 return false; |
| 59 } | 59 } |
| 60 | 60 |
| 61 uint8_t nonce[sizeof(nonce_prefix_) + sizeof(packet_number)]; | 61 uint8_t nonce[sizeof(nonce_prefix_) + sizeof(packet_number)]; |
| 62 const size_t nonce_size = nonce_prefix_size_ + sizeof(packet_number); | 62 const size_t nonce_size = nonce_prefix_size_ + sizeof(packet_number); |
| 63 DCHECK_LE(nonce_size, sizeof(nonce)); | 63 DCHECK_LE(nonce_size, sizeof(nonce)); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 StringPiece AeadBaseDecrypter::GetNoncePrefix() const { | 131 StringPiece AeadBaseDecrypter::GetNoncePrefix() const { |
| 132 if (nonce_prefix_size_ == 0) { | 132 if (nonce_prefix_size_ == 0) { |
| 133 return StringPiece(); | 133 return StringPiece(); |
| 134 } | 134 } |
| 135 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), | 135 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), |
| 136 nonce_prefix_size_); | 136 nonce_prefix_size_); |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace net | 139 } // namespace net |
| OLD | NEW |