| 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/aead_base_decrypter.h" | 5 #include "net/quic/core/crypto/aead_base_decrypter.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 | 8 |
| 9 #include "net/quic/core/quic_utils.h" | 9 #include "net/quic/core/quic_utils.h" |
| 10 #include "net/quic/platform/api/quic_bug_tracker.h" | 10 #include "net/quic/platform/api/quic_bug_tracker.h" |
| 11 #include "net/quic/platform/api/quic_logging.h" |
| 11 #include "third_party/boringssl/src/include/openssl/err.h" | 12 #include "third_party/boringssl/src/include/openssl/err.h" |
| 12 #include "third_party/boringssl/src/include/openssl/evp.h" | 13 #include "third_party/boringssl/src/include/openssl/evp.h" |
| 13 | 14 |
| 14 using base::StringPiece; | 15 using base::StringPiece; |
| 15 using std::string; | 16 using std::string; |
| 16 | 17 |
| 17 namespace net { | 18 namespace net { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 // Clear OpenSSL error stack. | 22 // Clear OpenSSL error stack. |
| 22 void ClearOpenSslErrors() { | 23 void ClearOpenSslErrors() { |
| 23 while (ERR_get_error()) { | 24 while (ERR_get_error()) { |
| 24 } | 25 } |
| 25 } | 26 } |
| 26 | 27 |
| 27 // In debug builds only, log OpenSSL error stack. Then clear OpenSSL error | 28 // In debug builds only, log OpenSSL error stack. Then clear OpenSSL error |
| 28 // stack. | 29 // stack. |
| 29 void DLogOpenSslErrors() { | 30 void DLogOpenSslErrors() { |
| 30 #ifdef NDEBUG | 31 #ifdef NDEBUG |
| 31 ClearOpenSslErrors(); | 32 ClearOpenSslErrors(); |
| 32 #else | 33 #else |
| 33 while (uint32_t error = ERR_get_error()) { | 34 while (uint32_t error = ERR_get_error()) { |
| 34 char buf[120]; | 35 char buf[120]; |
| 35 ERR_error_string_n(error, buf, arraysize(buf)); | 36 ERR_error_string_n(error, buf, arraysize(buf)); |
| 36 DLOG(ERROR) << "OpenSSL error: " << buf; | 37 QUIC_DLOG(ERROR) << "OpenSSL error: " << buf; |
| 37 } | 38 } |
| 38 #endif | 39 #endif |
| 39 } | 40 } |
| 40 | 41 |
| 41 } // namespace | 42 } // namespace |
| 42 | 43 |
| 43 AeadBaseDecrypter::AeadBaseDecrypter(const EVP_AEAD* aead_alg, | 44 AeadBaseDecrypter::AeadBaseDecrypter(const EVP_AEAD* aead_alg, |
| 44 size_t key_size, | 45 size_t key_size, |
| 45 size_t auth_tag_size, | 46 size_t auth_tag_size, |
| 46 size_t nonce_prefix_size) | 47 size_t nonce_prefix_size) |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 160 |
| 160 StringPiece AeadBaseDecrypter::GetNoncePrefix() const { | 161 StringPiece AeadBaseDecrypter::GetNoncePrefix() const { |
| 161 if (nonce_prefix_size_ == 0) { | 162 if (nonce_prefix_size_ == 0) { |
| 162 return StringPiece(); | 163 return StringPiece(); |
| 163 } | 164 } |
| 164 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), | 165 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), |
| 165 nonce_prefix_size_); | 166 nonce_prefix_size_); |
| 166 } | 167 } |
| 167 | 168 |
| 168 } // namespace net | 169 } // namespace net |
| OLD | NEW |