From a8ca18f4774c291087a31a197a73b24d1ca3f790 Mon Sep 17 00:00:00 2001 From: Suet-Fei Li Date: Thu, 8 Dec 2022 12:46:13 -0800 Subject: [PATCH] Internal refactor. PiperOrigin-RevId: 493970269 --- internal/crypto/BUILD | 4 ++-- internal/crypto/aead.cc | 1 + internal/crypto/ec_private_key.cc | 2 +- internal/crypto/ec_signature_creator.cc | 1 - internal/crypto/encryptor.cc | 5 +++-- internal/crypto/hkdf.cc | 2 +- internal/crypto/hmac.cc | 2 +- internal/crypto/nearby_base.cc | 2 +- internal/crypto/openssl_util.cc | 10 ++-------- internal/crypto/openssl_util.h | 1 - internal/crypto/rsa_private_key.cc | 2 +- internal/crypto/signature_verifier.cc | 2 +- internal/crypto/symmetric_key.cc | 2 +- internal/platform/implementation/g3/BUILD | 1 - .../platform/implementation/windows/generated/BUILD | 1 + 15 files changed, 16 insertions(+), 22 deletions(-) diff --git a/internal/crypto/BUILD b/internal/crypto/BUILD index 2fac40c3..ee15bac5 100644 --- a/internal/crypto/BUILD +++ b/internal/crypto/BUILD @@ -61,9 +61,10 @@ cc_library( "-Ithird_party", ], deps = [ - "//internal/platform:logging", "@boringssl//:crypto", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", "@com_google_absl//absl/types:optional", "@com_google_absl//absl/types:span", @@ -94,7 +95,6 @@ cc_test( ], deps = [ ":crypto", - "//internal/platform/implementation/g3", # build_cleaner: keep "@com_github_protobuf_matchers//protobuf-matchers", "@com_google_absl//absl/strings", "@com_google_absl//absl/types:span", diff --git a/internal/crypto/aead.cc b/internal/crypto/aead.cc index db1b080b..86ed1c2c 100644 --- a/internal/crypto/aead.cc +++ b/internal/crypto/aead.cc @@ -21,6 +21,7 @@ #include #include +#include "absl/log/check.h" #include "absl/types/span.h" #include "internal/crypto/nearby_base.h" #include "internal/crypto/openssl_util.h" diff --git a/internal/crypto/ec_private_key.cc b/internal/crypto/ec_private_key.cc index fd2fd1a4..0bb3696a 100644 --- a/internal/crypto/ec_private_key.cc +++ b/internal/crypto/ec_private_key.cc @@ -23,8 +23,8 @@ #include #include +#include "absl/log/check.h" #include "internal/crypto/openssl_util.h" -#include "internal/platform/logging.h" #include #include #include diff --git a/internal/crypto/ec_signature_creator.cc b/internal/crypto/ec_signature_creator.cc index 499a1641..8b6e50ee 100644 --- a/internal/crypto/ec_signature_creator.cc +++ b/internal/crypto/ec_signature_creator.cc @@ -17,7 +17,6 @@ #include #include "internal/crypto/ec_signature_creator_impl.h" -#include "internal/platform/logging.h" namespace crypto { diff --git a/internal/crypto/encryptor.cc b/internal/crypto/encryptor.cc index b40a91bd..d765faa4 100644 --- a/internal/crypto/encryptor.cc +++ b/internal/crypto/encryptor.cc @@ -22,12 +22,13 @@ #include #include +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/string_view.h" #include "absl/types/span.h" #include "internal/crypto/nearby_base.h" #include "internal/crypto/openssl_util.h" #include "internal/crypto/symmetric_key.h" -#include "internal/platform/logging.h" #include #include @@ -193,7 +194,7 @@ absl::optional Encryptor::CryptCTR(bool do_encrypt, absl::Span input, absl::Span output) { if (iv_.size() != AES_BLOCK_SIZE) { - NEARBY_LOGS(ERROR) << "Counter value not set in CTR mode."; + LOG(ERROR) << "Counter value not set in CTR mode."; return absl::nullopt; } diff --git a/internal/crypto/hkdf.cc b/internal/crypto/hkdf.cc index dbbf61a3..808aebab 100644 --- a/internal/crypto/hkdf.cc +++ b/internal/crypto/hkdf.cc @@ -21,10 +21,10 @@ #include #include +#include "absl/log/check.h" #include "absl/strings/string_view.h" #include "internal/crypto/hkdf.h" #include "internal/crypto/hmac.h" -#include "internal/platform/logging.h" #include namespace crypto { diff --git a/internal/crypto/hmac.cc b/internal/crypto/hmac.cc index b5ac2688..43a96558 100644 --- a/internal/crypto/hmac.cc +++ b/internal/crypto/hmac.cc @@ -19,12 +19,12 @@ #include #include +#include "absl/log/check.h" #include "internal/crypto/hmac.h" #include "internal/crypto/nearby_base.h" #include "internal/crypto/openssl_util.h" #include "internal/crypto/secure_util.h" #include "internal/crypto/symmetric_key.h" -#include "internal/platform/logging.h" namespace crypto { diff --git a/internal/crypto/nearby_base.cc b/internal/crypto/nearby_base.cc index 17683c9e..4369348c 100644 --- a/internal/crypto/nearby_base.cc +++ b/internal/crypto/nearby_base.cc @@ -18,8 +18,8 @@ #include #include +#include "absl/log/check.h" #include "absl/types/span.h" -#include "internal/platform/logging.h" namespace nearbybase { diff --git a/internal/crypto/openssl_util.cc b/internal/crypto/openssl_util.cc index 1568612d..6b5d099c 100644 --- a/internal/crypto/openssl_util.cc +++ b/internal/crypto/openssl_util.cc @@ -19,8 +19,8 @@ #include +#include "absl/log/log.h" #include "absl/strings/string_view.h" -#include "internal/platform/logging.h" #include #include @@ -38,7 +38,7 @@ namespace { // error queue and return, otherwise it will continue calling this function // until all errors have been removed from the queue. int OpenSSLErrorCallback(const char* str, size_t len, void* context) { - NEARBY_LOGS(VERBOSE) << "\t" << absl::string_view(str, len); + LOG(INFO) << "\t" << absl::string_view(str, len); return 1; } @@ -50,13 +50,7 @@ void EnsureOpenSSLInit() { } void ClearOpenSSLERRStack() { - if (NEARBY_LOG_IS_ON(VERBOSE)) { - uint32_t error_num = ERR_peek_error(); - if (error_num == 0) return; - ERR_print_errors_cb(&OpenSSLErrorCallback, nullptr); - } else { ERR_clear_error(); - } } } // namespace crypto diff --git a/internal/crypto/openssl_util.h b/internal/crypto/openssl_util.h index 2ddb517a..f1af2ec9 100644 --- a/internal/crypto/openssl_util.h +++ b/internal/crypto/openssl_util.h @@ -19,7 +19,6 @@ #include #include "internal/crypto/crypto_export.h" -#include "internal/platform/logging.h" namespace crypto { diff --git a/internal/crypto/rsa_private_key.cc b/internal/crypto/rsa_private_key.cc index 57e7b1c1..c0a19d47 100644 --- a/internal/crypto/rsa_private_key.cc +++ b/internal/crypto/rsa_private_key.cc @@ -20,9 +20,9 @@ #include #include +#include "absl/log/check.h" #include "absl/types/span.h" #include "internal/crypto/openssl_util.h" -#include "internal/platform/logging.h" #include #include #include diff --git a/internal/crypto/signature_verifier.cc b/internal/crypto/signature_verifier.cc index 1328a823..8793acf1 100644 --- a/internal/crypto/signature_verifier.cc +++ b/internal/crypto/signature_verifier.cc @@ -16,8 +16,8 @@ #include +#include "absl/log/check.h" #include "internal/crypto/openssl_util.h" -#include "internal/platform/logging.h" #include #include #include diff --git a/internal/crypto/symmetric_key.cc b/internal/crypto/symmetric_key.cc index 13c24bd4..0a43f5d6 100644 --- a/internal/crypto/symmetric_key.cc +++ b/internal/crypto/symmetric_key.cc @@ -22,9 +22,9 @@ #include #include +#include "absl/log/check.h" #include "internal/crypto/nearby_base.h" #include "internal/crypto/openssl_util.h" -#include "internal/platform/logging.h" #include #include diff --git a/internal/platform/implementation/g3/BUILD b/internal/platform/implementation/g3/BUILD index fecfbea1..785f7dbe 100644 --- a/internal/platform/implementation/g3/BUILD +++ b/internal/platform/implementation/g3/BUILD @@ -122,7 +122,6 @@ cc_library( "//connections:__subpackages__", "//fastpair:__subpackages__", "//internal/analytics:__subpackages__", - "//internal/crypto:__subpackages__", "//internal/platform:__subpackages__", "//internal/proto/analytics:__subpackages__", "//location/nearby/cpp/fastpair:__subpackages__", diff --git a/internal/platform/implementation/windows/generated/BUILD b/internal/platform/implementation/windows/generated/BUILD index 3a59f01e..de97d32c 100644 --- a/internal/platform/implementation/windows/generated/BUILD +++ b/internal/platform/implementation/windows/generated/BUILD @@ -38,6 +38,7 @@ cc_library( textual_hdrs = glob(["**/*.h"]), visibility = [ "//connections/windows:__subpackages__", + "//internal:__subpackages__", "//internal/platform/implementation/windows:__subpackages__", ], )