diff options
author | Bartosz Przydatek <przydatek@google.com> | 2017-10-12 13:33:28 +0200 |
---|---|---|
committer | Thai Duong <thaidn@google.com> | 2017-11-09 12:33:25 -0800 |
commit | d0bd5007a71eb1e879acc963b92ccae85ef66d1b (patch) | |
tree | 4db84c5301e96bb1e1f33830bc80b29e09fb5d22 /cc/mac/hmac_key_manager.h | |
parent | c68e8776c927e8048bc6d0e13fbc1d6e74fa6061 (diff) | |
download | tink-d0bd5007a71eb1e879acc963b92ccae85ef66d1b.tar.gz |
Adding C++ KeysetManager.
Change-Id: If71775ddc160f4ba3b3e6c194b589ebd903f7ef4
ORIGINAL_AUTHOR=Bartosz Przydatek <przydatek@google.com>
GitOrigin-RevId: 434de034db10383329ec23ef7b872b8a0586073e
Diffstat (limited to 'cc/mac/hmac_key_manager.h')
-rw-r--r-- | cc/mac/hmac_key_manager.h | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/cc/mac/hmac_key_manager.h b/cc/mac/hmac_key_manager.h index e8658c4d0..fad7fe543 100644 --- a/cc/mac/hmac_key_manager.h +++ b/cc/mac/hmac_key_manager.h @@ -20,6 +20,7 @@ #ifndef TINK_MAC_HMAC_KEY_MANAGER_H_ #define TINK_MAC_HMAC_KEY_MANAGER_H_ +#include "absl/strings/string_view.h" #include "cc/mac.h" #include "cc/key_manager.h" #include "cc/util/errors.h" @@ -36,8 +37,9 @@ class HmacKeyManager : public KeyManager<Mac> { public: static constexpr char kKeyType[] = "type.googleapis.com/google.crypto.tink.HmacKey"; + static constexpr uint32_t kVersion = 0; - HmacKeyManager() : key_type_(kKeyType) {} + HmacKeyManager(); // Constructs an instance of HMAC-Mac for the given 'key_data', // which must contain HmacKey-proto. @@ -49,34 +51,38 @@ class HmacKeyManager : public KeyManager<Mac> { crypto::tink::util::StatusOr<std::unique_ptr<Mac>> GetPrimitive(const google::protobuf::Message& key) const override; - // Generates a new random HmacKey, based on the specified 'key_template', - // which must contain HmacKeyFormat-proto. - crypto::tink::util::StatusOr<std::unique_ptr<google::protobuf::Message>> - NewKey(const google::crypto::tink::KeyTemplate& key_template) - const override; - // Returns the type_url identifying the key type handled by this manager. const std::string& get_key_type() const override; // Returns the version of this key manager. uint32_t get_version() const override; + // Returns a factory that generates keys of the key type + // handled by this manager. + const KeyFactory& get_key_factory() const override; + virtual ~HmacKeyManager() {} private: + friend class HmacKeyFactory; + static constexpr char kKeyTypePrefix[] = "type.googleapis.com/"; + static constexpr char kKeyFormatUrl[] = + "type.googleapis.com/google.crypto.tink.HmacKeyFormat"; + std::string key_type_; + std::unique_ptr<KeyFactory> key_factory_; // Constructs an instance of HMAC-Mac for the given 'key'. crypto::tink::util::StatusOr<std::unique_ptr<Mac>> GetPrimitiveImpl(const google::crypto::tink::HmacKey& key) const; - crypto::tink::util::Status Validate( - const google::crypto::tink::HmacParams& params) const; - crypto::tink::util::Status Validate( - const google::crypto::tink::HmacKey& key) const; - crypto::tink::util::Status Validate( - const google::crypto::tink::HmacKeyFormat& key_format) const; + static crypto::tink::util::Status Validate( + const google::crypto::tink::HmacParams& params); + static crypto::tink::util::Status Validate( + const google::crypto::tink::HmacKey& key); + static crypto::tink::util::Status Validate( + const google::crypto::tink::HmacKeyFormat& key_format); }; } // namespace tink |