| 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/core/crypto/crypto_secret_boxer.h" | 5 #include "net/quic/core/crypto/crypto_secret_boxer.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "net/quic/core/crypto/aes_128_gcm_12_decrypter.h" | 10 #include "net/quic/core/crypto/aes_128_gcm_12_decrypter.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 std::unique_ptr<Aes128Gcm12Decrypter> decrypter(new Aes128Gcm12Decrypter()); | 102 std::unique_ptr<Aes128Gcm12Decrypter> decrypter(new Aes128Gcm12Decrypter()); |
| 103 char plaintext[kMaxPacketSize]; | 103 char plaintext[kMaxPacketSize]; |
| 104 size_t plaintext_length = 0; | 104 size_t plaintext_length = 0; |
| 105 bool ok = false; | 105 bool ok = false; |
| 106 { | 106 { |
| 107 QuicReaderMutexLock l(&lock_); | 107 QuicReaderMutexLock l(&lock_); |
| 108 for (const string& key : keys_) { | 108 for (const string& key : keys_) { |
| 109 if (decrypter->SetKey(key)) { | 109 if (decrypter->SetKey(key)) { |
| 110 decrypter->SetNoncePrefix(nonce_prefix); | 110 decrypter->SetNoncePrefix(nonce_prefix); |
| 111 if (decrypter->DecryptPacket(QUIC_VERSION_36, | 111 if (decrypter->DecryptPacket(QUIC_VERSION_36, packet_number, |
| 112 /*path_id=*/0u, packet_number, | |
| 113 /*associated data=*/StringPiece(), | 112 /*associated data=*/StringPiece(), |
| 114 ciphertext, plaintext, &plaintext_length, | 113 ciphertext, plaintext, &plaintext_length, |
| 115 kMaxPacketSize)) { | 114 kMaxPacketSize)) { |
| 116 ok = true; | 115 ok = true; |
| 117 break; | 116 break; |
| 118 } | 117 } |
| 119 } | 118 } |
| 120 } | 119 } |
| 121 } | 120 } |
| 122 if (!ok) { | 121 if (!ok) { |
| 123 return false; | 122 return false; |
| 124 } | 123 } |
| 125 | 124 |
| 126 out_storage->resize(plaintext_length); | 125 out_storage->resize(plaintext_length); |
| 127 out_storage->assign(plaintext, plaintext_length); | 126 out_storage->assign(plaintext, plaintext_length); |
| 128 out->set(out_storage->data(), plaintext_length); | 127 out->set(out_storage->data(), plaintext_length); |
| 129 return true; | 128 return true; |
| 130 } | 129 } |
| 131 | 130 |
| 132 } // namespace net | 131 } // namespace net |
| OLD | NEW |