Skip to content

Commit

Permalink
Add GroupEncryptionKeyHandle to C++ Containers SDK (#4964)
Browse files Browse the repository at this point in the history
Ref #4442
  • Loading branch information
ipetr0v authored Mar 27, 2024
1 parent 863ee00 commit 57a8f73
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cc/containers/sdk/encryption_key_handle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,16 @@ InstanceEncryptionKeyHandle::GenerateRecipientContext(
return RecipientContext::Deserialize(*session_keys);
}

absl::StatusOr<std::unique_ptr<RecipientContext>>
GroupEncryptionKeyHandle::GenerateRecipientContext(
absl::string_view serialized_encapsulated_public_key) {
absl::StatusOr<SessionKeys> session_keys = orchestrator_crypto_client_.DeriveSessionKeys(
KeyOrigin::GROUP, serialized_encapsulated_public_key);
if (!session_keys.ok()) {
return absl::InternalError("couldn't derive session keys");
}

return RecipientContext::Deserialize(*session_keys);
}

} // namespace oak::containers::sdk
9 changes: 9 additions & 0 deletions cc/containers/sdk/encryption_key_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ class InstanceEncryptionKeyHandle : public ::oak::crypto::EncryptionKeyHandle {
OrchestratorCryptoClient orchestrator_crypto_client_;
};

class GroupEncryptionKeyHandle : public ::oak::crypto::EncryptionKeyHandle {
public:
absl::StatusOr<std::unique_ptr<::oak::crypto::RecipientContext>> GenerateRecipientContext(
absl::string_view serialized_encapsulated_public_key) override;

private:
OrchestratorCryptoClient orchestrator_crypto_client_;
};

} // namespace oak::containers::sdk

#endif // THIRD_PARTY_OAK_CC_CONTAINERS_ENCRYPTION_KEY_HANDLE_H_

0 comments on commit 57a8f73

Please sign in to comment.