aboutsummaryrefslogtreecommitdiff
path: root/cc/mac/mac_config.cc
diff options
context:
space:
mode:
authorBartosz Przydatek <przydatek@google.com>2017-07-03 17:54:38 +0200
committerThai Duong <thaidn@google.com>2017-07-10 20:32:57 -0700
commitf12db8a65d733a4744e4ea5dab68560bd2e993aa (patch)
tree3bfa0b2bcb64e62078cd62703428775223647ecc /cc/mac/mac_config.cc
parenta058c3e2017a7abd0fc1cb35b01c7947e7a4e703 (diff)
downloadtink-f12db8a65d733a4744e4ea5dab68560bd2e993aa.tar.gz
Adding C++ ...Config-classes for primitives.
Change-Id: Ie289cf5a84adf92991e15193f3244c5264ca7ed3 ORIGINAL_AUTHOR=Bartosz Przydatek <przydatek@google.com> GitOrigin-RevId: 0a16afe6c8a506713b043867f697219a02277626
Diffstat (limited to 'cc/mac/mac_config.cc')
-rw-r--r--cc/mac/mac_config.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/cc/mac/mac_config.cc b/cc/mac/mac_config.cc
new file mode 100644
index 000000000..683ef5504
--- /dev/null
+++ b/cc/mac/mac_config.cc
@@ -0,0 +1,48 @@
+// Copyright 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include "cc/mac/mac_config.h"
+
+#include "cc/key_manager.h"
+#include "cc/registry.h"
+#include "cc/mac/hmac_key_manager.h"
+#include "cc/util/status.h"
+
+namespace crypto {
+namespace tink {
+
+// static
+util::Status MacConfig::RegisterStandardKeyTypes() {
+ return RegisterKeyManager(new HmacKeyManager());
+}
+
+// static
+util::Status MacConfig::RegisterLegacyKeyTypes() {
+ return util::Status::OK;
+}
+
+// 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);
+}
+
+} // namespace tink
+} // namespace crypto