aboutsummaryrefslogtreecommitdiff
path: root/cc/key_manager.h
diff options
context:
space:
mode:
authorBartosz Przydatek <przydatek@google.com>2017-10-12 13:33:28 +0200
committerThai Duong <thaidn@google.com>2017-11-09 12:33:25 -0800
commitd0bd5007a71eb1e879acc963b92ccae85ef66d1b (patch)
tree4db84c5301e96bb1e1f33830bc80b29e09fb5d22 /cc/key_manager.h
parentc68e8776c927e8048bc6d0e13fbc1d6e74fa6061 (diff)
downloadtink-d0bd5007a71eb1e879acc963b92ccae85ef66d1b.tar.gz
Adding C++ KeysetManager.
Change-Id: If71775ddc160f4ba3b3e6c194b589ebd903f7ef4 ORIGINAL_AUTHOR=Bartosz Przydatek <przydatek@google.com> GitOrigin-RevId: 434de034db10383329ec23ef7b872b8a0586073e
Diffstat (limited to 'cc/key_manager.h')
-rw-r--r--cc/key_manager.h31
1 files changed, 26 insertions, 5 deletions
diff --git a/cc/key_manager.h b/cc/key_manager.h
index 7357f76a1..f0884d3d3 100644
--- a/cc/key_manager.h
+++ b/cc/key_manager.h
@@ -30,6 +30,28 @@
namespace crypto {
namespace tink {
+// An auxiliary container for methods that generate new key material.
+// These methods are grouped separately, as their functionality
+// is independent of the primitive of the corresponding KeyManager.
+class KeyFactory {
+ public:
+ // Generates a new random key, based on the specified 'key_format'.
+ virtual
+ crypto::tink::util::StatusOr<std::unique_ptr<google::protobuf::Message>>
+ NewKey(const google::protobuf::Message& key_format) const = 0;
+
+ // Generates a new random key, based on the specified 'serialized_key_format'.
+ virtual
+ crypto::tink::util::StatusOr<std::unique_ptr<google::protobuf::Message>>
+ NewKey(absl::string_view serialized_key_format) const = 0;
+
+ // Generates a new random key, based on the specified 'serialized_key_format',
+ // and wraps it in a KeyData-proto.
+ virtual
+ crypto::tink::util::StatusOr<std::unique_ptr<google::crypto::tink::KeyData>>
+ NewKeyData(absl::string_view serialized_key_format) const = 0;
+};
+
/**
* KeyManager "understands" keys of a specific key types: it can
* generate keys of a supported type and create primitives for
@@ -50,17 +72,16 @@ class KeyManager {
virtual crypto::tink::util::StatusOr<std::unique_ptr<P>>
GetPrimitive(const google::protobuf::Message& key) const = 0;
- // Generates a new random key, based on the specified 'key_template'.
- virtual
- crypto::tink::util::StatusOr<std::unique_ptr<google::protobuf::Message>>
- NewKey(const google::crypto::tink::KeyTemplate& key_template) const = 0;
-
// Returns the type_url identifying the key type handled by this manager.
virtual const std::string& get_key_type() const = 0;
// Returns the version of this key manager.
virtual uint32_t get_version() const = 0;
+ // Returns a factory that generates keys of the key type
+ // handled by this manager.
+ virtual const KeyFactory& get_key_factory() const = 0;
+
bool DoesSupport(absl::string_view key_type) const {
return (key_type == get_key_type());
}