Skip to content

Commit

Permalink
Ensure that SDK traits impl both RecipientContextGenerator and `Enc…
Browse files Browse the repository at this point in the history
…ryptionKeyHandle` (#4604)
  • Loading branch information
jul-sh authored Jan 4, 2024
1 parent 13f97d6 commit 9322367
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions oak_restricted_kernel_sdk/src/dice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,15 @@ impl InstanceEncryptionKeyHandle {
}
}

impl EncryptionKeyHandle for InstanceEncryptionKeyHandle {
fn generate_session_keys(&self, encapsulated_public_key: &[u8]) -> anyhow::Result<SessionKeys> {
// Implements `RecipientContextGenerator` instead of `EncryptionKeyHandle`, as
// the latter is implemented for for all structs that impl the former.
// TODO(#3841): remove this comment once `RecipientContextGenerator` has been
// renamed to `EncryptionKeyHandle`, and the alias trait has been removed.
impl RecipientContextGenerator for InstanceEncryptionKeyHandle {
fn generate_recipient_context(
&self,
encapsulated_public_key: &[u8],
) -> anyhow::Result<SessionKeys> {
self.key.generate_session_keys(encapsulated_public_key)
}
}
Expand Down Expand Up @@ -222,8 +229,15 @@ impl MockEncryptionKeyHandle {
}

#[cfg(feature = "mock_attestion")]
impl EncryptionKeyHandle for MockEncryptionKeyHandle {
fn generate_session_keys(&self, encapsulated_public_key: &[u8]) -> anyhow::Result<SessionKeys> {
// Implements `RecipientContextGenerator` instead of `EncryptionKeyHandle`, as
// the latter is implemented for for all structs that impl the former.
// TODO(#3841): remove this comment once `RecipientContextGenerator` has been
// renamed to `EncryptionKeyHandle`, and the alias trait has been removed.
impl RecipientContextGenerator for MockEncryptionKeyHandle {
fn generate_recipient_context(
&self,
encapsulated_public_key: &[u8],
) -> anyhow::Result<SessionKeys> {
self.key.generate_session_keys(encapsulated_public_key)
}
}
Expand Down

0 comments on commit 9322367

Please sign in to comment.