aboutsummaryrefslogtreecommitdiff
path: root/cc/mac/mac_config.cc
diff options
context:
space:
mode:
authorBartosz Przydatek <przydatek@google.com>2017-09-20 11:39:39 +0200
committerThai Duong <thaidn@google.com>2017-10-06 13:14:30 -0700
commit19a6b69358f5e90452522b7c0cc53fc24827b267 (patch)
treef24d5ff0c4240dcb2c1c6247fc52abd7edeeefeb /cc/mac/mac_config.cc
parent2da371ee93ec6d18158ed0ddc1a32e4018c0e7e4 (diff)
downloadtink-19a6b69358f5e90452522b7c0cc53fc24827b267.tar.gz
Adding C++ configurations support.
Change-Id: I4b17e65859db914458a32d3359f1a44b5b1b6bde ORIGINAL_AUTHOR=Bartosz Przydatek <przydatek@google.com> GitOrigin-RevId: b67033740fe4d4f49410c397aeab503da6365950
Diffstat (limited to 'cc/mac/mac_config.cc')
-rw-r--r--cc/mac/mac_config.cc41
1 files changed, 29 insertions, 12 deletions
diff --git a/cc/mac/mac_config.cc b/cc/mac/mac_config.cc
index eb687338e..c147288a5 100644
--- a/cc/mac/mac_config.cc
+++ b/cc/mac/mac_config.cc
@@ -16,9 +16,10 @@
#include "cc/mac/mac_config.h"
+#include "cc/config.h"
#include "cc/key_manager.h"
#include "cc/registry.h"
-#include "cc/mac/hmac_key_manager.h"
+#include "cc/mac/mac_catalogue.h"
#include "cc/util/status.h"
namespace util = crypto::tink::util;
@@ -26,24 +27,40 @@ namespace util = crypto::tink::util;
namespace crypto {
namespace tink {
+namespace {
+
+google::crypto::tink::RegistryConfig* GenerateRegistryConfig() {
+ google::crypto::tink::RegistryConfig* config =
+ new google::crypto::tink::RegistryConfig();
+ config->add_entry()->MergeFrom(*Config::GetTinkKeyTypeEntry(
+ MacConfig::kCatalogueName, MacConfig::kPrimitiveName,
+ "HmacKey", 0, true));
+ config->set_config_name("TINK_MAC_1_1_0");
+ return config;
+}
+
+} // anonymous namespace
+
+constexpr char MacConfig::kCatalogueName[];
+constexpr char MacConfig::kPrimitiveName[];
+
// static
-util::Status MacConfig::RegisterStandardKeyTypes() {
- return RegisterKeyManager(new HmacKeyManager());
+const google::crypto::tink::RegistryConfig& MacConfig::Tink_1_1_0() {
+ static auto config = GenerateRegistryConfig();
+ return *config;
}
// static
-util::Status MacConfig::RegisterLegacyKeyTypes() {
- return util::Status::OK;
+util::Status MacConfig::Init() {
+ return Registry::get_default_registry().AddCatalogue(kCatalogueName,
+ new MacCatalogue());
}
// static
-util::Status MacConfig::RegisterKeyManager(KeyManager<Mac>* key_manager) {
- if (key_manager == nullptr) {
- return util::Status(util::error::INVALID_ARGUMENT,
- "Parameter 'key_manager' must be non-null.");
- }
- return Registry::get_default_registry().RegisterKeyManager(
- key_manager->get_key_type(), key_manager);
+util::Status MacConfig::RegisterStandardKeyTypes() {
+ auto status = Init();
+ if (!status.ok()) return status;
+ return Config::Register(Tink_1_1_0());
}
} // namespace tink