diff options
author | cinlin <cinlin@google.com> | 2023-07-13 13:43:53 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-07-13 13:44:47 -0700 |
commit | 0bbdfd84df04e7b8fe7da3217627bb9a9febb163 (patch) | |
tree | 2027105a64e77c9e0b27589845ea9cc95a1a9b11 /cc/config | |
parent | d26ed0209a33cd88a951ed9c2e17dd330baa9696 (diff) | |
download | tink-0bbdfd84df04e7b8fe7da3217627bb9a9febb163.tar.gz |
Move KeyGen/ConfigGlobalRegistry to public API. #tinkApiChange
PiperOrigin-RevId: 547908174
Diffstat (limited to 'cc/config')
-rw-r--r-- | cc/config/BUILD.bazel | 28 | ||||
-rw-r--r-- | cc/config/CMakeLists.txt | 29 | ||||
-rw-r--r-- | cc/config/global_registry.cc (renamed from cc/config/internal/global_registry.cc) | 8 | ||||
-rw-r--r-- | cc/config/global_registry.h (renamed from cc/config/internal/global_registry.h) | 11 | ||||
-rw-r--r-- | cc/config/global_registry_test.cc (renamed from cc/config/internal/global_registry_test.cc) | 8 | ||||
-rw-r--r-- | cc/config/internal/BUILD.bazel | 31 | ||||
-rw-r--r-- | cc/config/internal/CMakeLists.txt | 28 |
7 files changed, 65 insertions, 78 deletions
diff --git a/cc/config/BUILD.bazel b/cc/config/BUILD.bazel index a760eea84..3f179c15b 100644 --- a/cc/config/BUILD.bazel +++ b/cc/config/BUILD.bazel @@ -53,6 +53,20 @@ cc_library( ) cc_library( + name = "global_registry", + srcs = ["global_registry.cc"], + hdrs = ["global_registry.h"], + include_prefix = "tink/config", + deps = [ + "//:configuration", + "//:key_gen_configuration", + "//internal:configuration_impl", + "//internal:key_gen_configuration_impl", + "@com_google_absl//absl/log:check", + ], +) + +cc_library( name = "fips_140_2", srcs = ["fips_140_2.cc"], hdrs = ["fips_140_2.h"], @@ -246,6 +260,20 @@ cc_test( ) cc_test( + name = "global_registry_test", + srcs = ["global_registry_test.cc"], + deps = [ + ":global_registry", + "//:keyset_handle", + "//proto:aes_gcm_cc_proto", + "//proto:tink_cc_proto", + "//util:test_matchers", + "@com_google_absl//absl/status", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( name = "fips_140_2_test", srcs = ["fips_140_2_test.cc"], deps = [ diff --git a/cc/config/CMakeLists.txt b/cc/config/CMakeLists.txt index 58e9f5435..652a84d58 100644 --- a/cc/config/CMakeLists.txt +++ b/cc/config/CMakeLists.txt @@ -1,7 +1,5 @@ tink_module(config) -add_subdirectory(internal) - tink_cc_library( NAME tink_config SRCS @@ -43,6 +41,19 @@ tink_cc_library( ) tink_cc_library( + NAME global_registry + SRCS + global_registry.cc + global_registry.h + DEPS + absl::check + tink::core::configuration + tink::core::key_gen_configuration + tink::internal::configuration_impl + tink::internal::key_gen_configuration_impl +) + +tink_cc_library( NAME fips_140_2 SRCS fips_140_2.cc @@ -228,6 +239,20 @@ tink_cc_test( ) tink_cc_test( + NAME global_registry_test + SRCS + global_registry_test.cc + DEPS + tink::config::global_registry + gmock + absl::status + tink::core::keyset_handle + tink::util::test_matchers + tink::proto::aes_gcm_cc_proto + tink::proto::tink_cc_proto +) + +tink_cc_test( NAME fips_140_2_test SRCS fips_140_2_test.cc diff --git a/cc/config/internal/global_registry.cc b/cc/config/global_registry.cc index e6b34fe27..b8f8109bd 100644 --- a/cc/config/internal/global_registry.cc +++ b/cc/config/global_registry.cc @@ -14,7 +14,7 @@ // //////////////////////////////////////////////////////////////////////////////// -#include "tink/config/internal/global_registry.h" +#include "tink/config/global_registry.h" #include "absl/log/check.h" #include "tink/configuration.h" @@ -24,12 +24,11 @@ namespace crypto { namespace tink { -namespace internal { const Configuration& ConfigGlobalRegistry() { static const Configuration* instance = [] { static Configuration* config = new Configuration(); - CHECK_OK(ConfigurationImpl::SetGlobalRegistryMode(*config)); + CHECK_OK(internal::ConfigurationImpl::SetGlobalRegistryMode(*config)); return config; }(); return *instance; @@ -38,12 +37,11 @@ const Configuration& ConfigGlobalRegistry() { const KeyGenConfiguration& KeyGenConfigGlobalRegistry() { static const KeyGenConfiguration* instance = [] { static KeyGenConfiguration* config = new KeyGenConfiguration(); - CHECK_OK(KeyGenConfigurationImpl::SetGlobalRegistryMode(*config)); + CHECK_OK(internal::KeyGenConfigurationImpl::SetGlobalRegistryMode(*config)); return config; }(); return *instance; } -} // namespace internal } // namespace tink } // namespace crypto diff --git a/cc/config/internal/global_registry.h b/cc/config/global_registry.h index 422b8bcbe..ddd9010c1 100644 --- a/cc/config/internal/global_registry.h +++ b/cc/config/global_registry.h @@ -14,23 +14,20 @@ // //////////////////////////////////////////////////////////////////////////////// -#ifndef TINK_CONFIG_INTERNAL_GLOBAL_REGISTRY_H_ -#define TINK_CONFIG_INTERNAL_GLOBAL_REGISTRY_H_ +#ifndef TINK_CONFIG_GLOBAL_REGISTRY_H_ +#define TINK_CONFIG_GLOBAL_REGISTRY_H_ #include "tink/configuration.h" #include "tink/key_gen_configuration.h" namespace crypto { namespace tink { -namespace internal { -// TODO(b/265705174): Move to public API after API review. -// Used to generate keys using the global crypto::tink::Registry. +// Used to generate primitives and keys using the global crypto::tink::Registry. const crypto::tink::Configuration& ConfigGlobalRegistry(); const crypto::tink::KeyGenConfiguration& KeyGenConfigGlobalRegistry(); -} // namespace internal } // namespace tink } // namespace crypto -#endif // TINK_CONFIG_INTERNAL_GLOBAL_REGISTRY_H_ +#endif // TINK_CONFIG_GLOBAL_REGISTRY_H_ diff --git a/cc/config/internal/global_registry_test.cc b/cc/config/global_registry_test.cc index 0de5a1028..1180f2d60 100644 --- a/cc/config/internal/global_registry_test.cc +++ b/cc/config/global_registry_test.cc @@ -14,7 +14,7 @@ // //////////////////////////////////////////////////////////////////////////////// -#include "tink/config/internal/global_registry.h" +#include "tink/config/global_registry.h" #include <memory> #include <string> @@ -29,7 +29,6 @@ namespace crypto { namespace tink { -namespace internal { namespace { using ::crypto::tink::test::IsOk; @@ -107,7 +106,7 @@ class FakePrimitiveWrapper } }; -TEST(GlobalRegistryTest, KeyGenConfigGlobalRegistry) { +TEST(GlobalRegistryTest, GenerateNewKeysetHandleFromKeyGenConfig) { Registry::Reset(); KeyTemplate templ; @@ -127,7 +126,7 @@ TEST(GlobalRegistryTest, KeyGenConfigGlobalRegistry) { IsOk()); } -TEST(GlobalRegistryTest, ConfigGlobalRegistry) { +TEST(GlobalRegistryTest, GetPrimitiveFromConfig) { Registry::Reset(); ASSERT_THAT( Registry::RegisterKeyTypeManager(absl::make_unique<FakeKeyTypeManager>(), @@ -158,6 +157,5 @@ TEST(GlobalRegistryTest, ConfigGlobalRegistry) { } } // namespace -} // namespace internal } // namespace tink } // namespace crypto diff --git a/cc/config/internal/BUILD.bazel b/cc/config/internal/BUILD.bazel deleted file mode 100644 index 620bd3c18..000000000 --- a/cc/config/internal/BUILD.bazel +++ /dev/null @@ -1,31 +0,0 @@ -package(default_visibility = ["//:__subpackages__"]) - -licenses(["notice"]) - -cc_library( - name = "global_registry", - srcs = ["global_registry.cc"], - hdrs = ["global_registry.h"], - include_prefix = "tink/config/internal", - deps = [ - "//:configuration", - "//:key_gen_configuration", - "//internal:configuration_impl", - "//internal:key_gen_configuration_impl", - "@com_google_absl//absl/log:check", - ], -) - -cc_test( - name = "global_registry_test", - srcs = ["global_registry_test.cc"], - deps = [ - ":global_registry", - "//:keyset_handle", - "//proto:aes_gcm_cc_proto", - "//proto:tink_cc_proto", - "//util:test_matchers", - "@com_google_absl//absl/status", - "@com_google_googletest//:gtest_main", - ], -) diff --git a/cc/config/internal/CMakeLists.txt b/cc/config/internal/CMakeLists.txt deleted file mode 100644 index 5e72ac69a..000000000 --- a/cc/config/internal/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -tink_module(config::internal) - -tink_cc_library( - NAME global_registry - SRCS - global_registry.cc - global_registry.h - DEPS - absl::check - tink::core::configuration - tink::core::key_gen_configuration - tink::internal::configuration_impl - tink::internal::key_gen_configuration_impl -) - -tink_cc_test( - NAME global_registry_test - SRCS - global_registry_test.cc - DEPS - tink::config::internal::global_registry - gmock - absl::status - tink::core::keyset_handle - tink::util::test_matchers - tink::proto::aes_gcm_cc_proto - tink::proto::tink_cc_proto -) |