| 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" |
| 11 | 11 |
| 12 using base::StringPiece; | 12 using base::StringPiece; |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // Clear OpenSSL error stack. | 18 // Clear OpenSSL error stack. |
| 19 void ClearOpenSslErrors() { | 19 void ClearOpenSslErrors() { |
| 20 while (ERR_get_error()) {} | 20 while (ERR_get_error()) {} |
| 21 } | 21 } |
| 22 | 22 |
| 23 // In debug builds only, log OpenSSL error stack. Then clear OpenSSL error | 23 // In debug builds only, log OpenSSL error stack. Then clear OpenSSL error |
| 24 // stack. | 24 // stack. |
| 25 void DLogOpenSslErrors() { | 25 void DLogOpenSslErrors() { |
| 26 #ifdef NDEBUG | 26 #ifdef NDEBUG |
| 27 ClearOpenSslErrors(); | 27 ClearOpenSslErrors(); |
| 28 #else | 28 #else |
| 29 while (unsigned long error = ERR_get_error()) { | 29 while (uint32_t error = ERR_get_error()) { |
| 30 char buf[120]; | 30 char buf[120]; |
| 31 ERR_error_string_n(error, buf, arraysize(buf)); | 31 ERR_error_string_n(error, buf, arraysize(buf)); |
| 32 DLOG(ERROR) << "OpenSSL error: " << buf; | 32 DLOG(ERROR) << "OpenSSL error: " << buf; |
| 33 } | 33 } |
| 34 #endif | 34 #endif |
| 35 } | 35 } |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 AeadBaseDecrypter::AeadBaseDecrypter(const EVP_AEAD* aead_alg, | 39 AeadBaseDecrypter::AeadBaseDecrypter(const EVP_AEAD* aead_alg, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 StringPiece AeadBaseDecrypter::GetNoncePrefix() const { | 129 StringPiece AeadBaseDecrypter::GetNoncePrefix() const { |
| 130 if (nonce_prefix_size_ == 0) { | 130 if (nonce_prefix_size_ == 0) { |
| 131 return StringPiece(); | 131 return StringPiece(); |
| 132 } | 132 } |
| 133 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), | 133 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), |
| 134 nonce_prefix_size_); | 134 nonce_prefix_size_); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace net | 137 } // namespace net |
| OLD | NEW |