aboutsummaryrefslogtreecommitdiff
path: root/cc/primitive_set.h
diff options
context:
space:
mode:
authortholenst <tholenst@google.com>2020-10-09 04:45:35 -0700
committerCopybara-Service <copybara-worker@google.com>2020-10-09 04:46:07 -0700
commit815e5c34b3baf6ae8d40ef24552b637f93149ac5 (patch)
tree8e49b6fd13bdb4b6755e961b5bf4b85b56a79d62 /cc/primitive_set.h
parent4323440eefb76a51fdaf13c0dda50573d6840541 (diff)
downloadtink-815e5c34b3baf6ae8d40ef24552b637f93149ac5.tar.gz
Migrate PrimitiveSet::AddPrimitive to take a KeyInfo instead of a Key.
PiperOrigin-RevId: 336271198
Diffstat (limited to 'cc/primitive_set.h')
-rw-r--r--cc/primitive_set.h19
1 files changed, 10 insertions, 9 deletions
diff --git a/cc/primitive_set.h b/cc/primitive_set.h
index b5a435ac9..16d79e5a3 100644
--- a/cc/primitive_set.h
+++ b/cc/primitive_set.h
@@ -56,13 +56,14 @@ class PrimitiveSet {
class Entry {
public:
static crypto::tink::util::StatusOr<std::unique_ptr<Entry<P>>> New(
- std::unique_ptr<P> primitive, google::crypto::tink::Keyset::Key key) {
- if (key.status() != google::crypto::tink::KeyStatusType::ENABLED) {
+ std::unique_ptr<P> primitive,
+ const google::crypto::tink::KeysetInfo::KeyInfo& key_info) {
+ if (key_info.status() != google::crypto::tink::KeyStatusType::ENABLED) {
return util::Status(crypto::tink::util::error::INVALID_ARGUMENT,
"The key must be ENABLED.");
}
- auto identifier_result =
- CryptoFormat::GetOutputPrefix(key.key_id(), key.output_prefix_type());
+ auto identifier_result = CryptoFormat::GetOutputPrefix(
+ key_info.key_id(), key_info.output_prefix_type());
if (!identifier_result.ok()) return identifier_result.status();
if (primitive == nullptr) {
return util::Status(crypto::tink::util::error::INVALID_ARGUMENT,
@@ -70,9 +71,8 @@ class PrimitiveSet {
}
std::string identifier = identifier_result.ValueOrDie();
return absl::WrapUnique(new Entry(std::move(primitive), identifier,
- key.status(),
- key.key_id(),
- key.output_prefix_type()));
+ key_info.status(), key_info.key_id(),
+ key_info.output_prefix_type()));
}
P2& get_primitive() const { return *primitive_; }
@@ -111,8 +111,9 @@ class PrimitiveSet {
// Adds 'primitive' to this set for the specified 'key'.
crypto::tink::util::StatusOr<Entry<P>*> AddPrimitive(
- std::unique_ptr<P> primitive, google::crypto::tink::Keyset::Key key) {
- auto entry_or = Entry<P>::New(std::move(primitive), key);
+ std::unique_ptr<P> primitive,
+ const google::crypto::tink::KeysetInfo::KeyInfo& key_info) {
+ auto entry_or = Entry<P>::New(std::move(primitive), key_info);
if (!entry_or.ok()) return entry_or.status();
absl::MutexLock lock(&primitives_mutex_);