| 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 <openssl/err.h> | 5 #include <openssl/err.h> |
| 6 #include <openssl/evp.h> | 6 #include <openssl/evp.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "net/quic/core/crypto/aead_base_decrypter.h" | 10 #include "net/quic/core/crypto/aead_base_decrypter.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool AeadBaseDecrypter::SetPreliminaryKey(StringPiece key) { | 88 bool AeadBaseDecrypter::SetPreliminaryKey(StringPiece key) { |
| 89 DCHECK(!have_preliminary_key_); | 89 DCHECK(!have_preliminary_key_); |
| 90 SetKey(key); | 90 SetKey(key); |
| 91 have_preliminary_key_ = true; | 91 have_preliminary_key_ = true; |
| 92 | 92 |
| 93 return true; | 93 return true; |
| 94 } | 94 } |
| 95 | 95 |
| 96 bool AeadBaseDecrypter::SetDiversificationNonce(DiversificationNonce nonce) { | 96 bool AeadBaseDecrypter::SetDiversificationNonce( |
| 97 const DiversificationNonce& nonce) { |
| 97 if (!have_preliminary_key_) { | 98 if (!have_preliminary_key_) { |
| 98 return true; | 99 return true; |
| 99 } | 100 } |
| 100 | 101 |
| 101 string key, nonce_prefix; | 102 string key, nonce_prefix; |
| 102 DiversifyPreliminaryKey( | 103 DiversifyPreliminaryKey( |
| 103 StringPiece(reinterpret_cast<const char*>(key_), key_size_), | 104 StringPiece(reinterpret_cast<const char*>(key_), key_size_), |
| 104 StringPiece(reinterpret_cast<const char*>(nonce_prefix_), | 105 StringPiece(reinterpret_cast<const char*>(nonce_prefix_), |
| 105 nonce_prefix_size_), | 106 nonce_prefix_size_), |
| 106 nonce, key_size_, nonce_prefix_size_, &key, &nonce_prefix); | 107 nonce, key_size_, nonce_prefix_size_, &key, &nonce_prefix); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 159 |
| 159 StringPiece AeadBaseDecrypter::GetNoncePrefix() const { | 160 StringPiece AeadBaseDecrypter::GetNoncePrefix() const { |
| 160 if (nonce_prefix_size_ == 0) { | 161 if (nonce_prefix_size_ == 0) { |
| 161 return StringPiece(); | 162 return StringPiece(); |
| 162 } | 163 } |
| 163 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), | 164 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), |
| 164 nonce_prefix_size_); | 165 nonce_prefix_size_); |
| 165 } | 166 } |
| 166 | 167 |
| 167 } // namespace net | 168 } // namespace net |
| OLD | NEW |