| 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 <openssl/err.h> | 7 #include <openssl/err.h> |
| 8 #include <openssl/evp.h> | 8 #include <openssl/evp.h> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 DCHECK_EQ(nonce_prefix.size(), nonce_prefix_size_); | 74 DCHECK_EQ(nonce_prefix.size(), nonce_prefix_size_); |
| 75 if (nonce_prefix.size() != nonce_prefix_size_) { | 75 if (nonce_prefix.size() != nonce_prefix_size_) { |
| 76 return false; | 76 return false; |
| 77 } | 77 } |
| 78 memcpy(nonce_prefix_, nonce_prefix.data(), nonce_prefix.size()); | 78 memcpy(nonce_prefix_, nonce_prefix.data(), nonce_prefix.size()); |
| 79 return true; | 79 return true; |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool AeadBaseDecrypter::DecryptPacket(QuicPathId path_id, | 82 bool AeadBaseDecrypter::DecryptPacket(QuicPathId path_id, |
| 83 QuicPacketNumber packet_number, | 83 QuicPacketNumber packet_number, |
| 84 const StringPiece& associated_data, | 84 StringPiece associated_data, |
| 85 const StringPiece& ciphertext, | 85 StringPiece ciphertext, |
| 86 char* output, | 86 char* output, |
| 87 size_t* output_length, | 87 size_t* output_length, |
| 88 size_t max_output_length) { | 88 size_t max_output_length) { |
| 89 if (ciphertext.length() < auth_tag_size_) { | 89 if (ciphertext.length() < auth_tag_size_) { |
| 90 return false; | 90 return false; |
| 91 } | 91 } |
| 92 | 92 |
| 93 uint8_t nonce[sizeof(nonce_prefix_) + sizeof(packet_number)]; | 93 uint8_t nonce[sizeof(nonce_prefix_) + sizeof(packet_number)]; |
| 94 const size_t nonce_size = nonce_prefix_size_ + sizeof(packet_number); | 94 const size_t nonce_size = nonce_prefix_size_ + sizeof(packet_number); |
| 95 memcpy(nonce, nonce_prefix_, nonce_prefix_size_); | 95 memcpy(nonce, nonce_prefix_, nonce_prefix_size_); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 122 | 122 |
| 123 StringPiece AeadBaseDecrypter::GetNoncePrefix() const { | 123 StringPiece AeadBaseDecrypter::GetNoncePrefix() const { |
| 124 if (nonce_prefix_size_ == 0) { | 124 if (nonce_prefix_size_ == 0) { |
| 125 return StringPiece(); | 125 return StringPiece(); |
| 126 } | 126 } |
| 127 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), | 127 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), |
| 128 nonce_prefix_size_); | 128 nonce_prefix_size_); |
| 129 } | 129 } |
| 130 | 130 |
| 131 } // namespace net | 131 } // namespace net |
| OLD | NEW |