diff options
author | Thai Duong <thaidn@google.com> | 2017-10-19 12:50:41 -0700 |
---|---|---|
committer | Thai Duong <thaidn@google.com> | 2017-10-25 23:36:20 -0700 |
commit | 0df23c2d9a5ec244bbdbce7cbb324911fd1f62fc (patch) | |
tree | 023633bb8d27311e3c3a0abadac212cca8029089 /cc/registry.h | |
parent | 1a5bb2740179d38c1693c95dc4533a6b7f93f71f (diff) | |
download | tink-0df23c2d9a5ec244bbdbce7cbb324911fd1f62fc.tar.gz |
Adding AesCtrHmacAeadKeyManager.
Deleting AesCtrHmacAeadParams proto as it's not used anywhere.
Change-Id: I069b6ee749ce3522c4a5935fb7b8628921bc6f0b
ORIGINAL_AUTHOR=Thai Duong <thaidn@google.com>
GitOrigin-RevId: e958abc862f4f4fce1b6d55ce1bb0dc3e12bf4dc
Diffstat (limited to 'cc/registry.h')
-rw-r--r-- | cc/registry.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cc/registry.h b/cc/registry.h index 929441add..8fb05d2b1 100644 --- a/cc/registry.h +++ b/cc/registry.h @@ -110,6 +110,14 @@ class Registry { static crypto::tink::util::StatusOr<std::unique_ptr<P>> GetPrimitive( const google::crypto::tink::KeyData& key_data); + // Convenience method for creating a new primitive for the key given + // in 'key'. It looks up a KeyManager identified by type_url, + // and calls manager's GetPrimitive(key)-method. + template <class P> + static crypto::tink::util::StatusOr<std::unique_ptr<P>> GetPrimitive( + google::protobuf::StringPiece type_url, + const google::protobuf::Message& key); + // Creates a set of primitives corresponding to the keys with // (status == ENABLED) in the keyset given in 'keyset_handle', // assuming all the corresponding key managers are present (keys @@ -277,6 +285,18 @@ crypto::tink::util::StatusOr<std::unique_ptr<P>> Registry::GetPrimitive( // static template <class P> +crypto::tink::util::StatusOr<std::unique_ptr<P>> Registry::GetPrimitive( + google::protobuf::StringPiece type_url, + const google::protobuf::Message& key) { + auto key_manager_result = get_key_manager<P>(type_url); + if (key_manager_result.ok()) { + return key_manager_result.ValueOrDie()->GetPrimitive(key); + } + return key_manager_result.status(); +} + +// static +template <class P> crypto::tink::util::StatusOr<std::unique_ptr<PrimitiveSet<P>>> Registry::GetPrimitives( const KeysetHandle& keyset_handle, |