Skip to content

Commit

Permalink
Merge Rust EncryptionKeyProvider and KeyPair (#4771)
Browse files Browse the repository at this point in the history
This PR:
- Merges `oak_crypto::encryptor::EncryptionKeyProvider` and `oak_crypto::hpke::KeyPair` into `oak_crypto::encryption_key::EncryptionKey`
- Implements serialization/deserialization
- Implements encryping the private key for Key Provisioning.
- Removes public keys from `EncryptionKey` struct (it's only used to be put into the evidence)

Ref #4513
  • Loading branch information
ipetr0v authored Feb 9, 2024
1 parent a5df75f commit 9e03dea
Show file tree
Hide file tree
Showing 24 changed files with 277 additions and 430 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion enclave_apps/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

116 changes: 0 additions & 116 deletions micro_rpc_workspace_test/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions oak_attestation/src/attester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use alloc::{sync::Arc, vec::Vec};

use anyhow::Context;
use oak_crypto::encryptor::EncryptionKeyProvider;

use crate::proto::oak::session::v1::AttestationEvidence;

Expand Down Expand Up @@ -47,31 +46,30 @@ impl AttestationReportGenerator for EmptyAttestationReportGenerator {
/// <https://www.rfc-editor.org/rfc/rfc9334.html#name-attester>
pub struct Attester {
attestation_report_generator: Arc<dyn AttestationReportGenerator>,
encryption_key_provider: Arc<EncryptionKeyProvider>,
encryption_public_key: Vec<u8>,
}

impl Attester {
pub fn new(
attestation_report_generator: Arc<dyn AttestationReportGenerator>,
encryption_key_provider: Arc<EncryptionKeyProvider>,
encryption_public_key: &[u8],
) -> Self {
Self {
attestation_report_generator,
encryption_key_provider,
encryption_public_key: encryption_public_key.to_vec(),
}
}

/// Generate an attestation evidence containing a remote attestation report and ensuring that
/// `attested_data` is cryptographically bound to the result (e.g. via a signature).
pub fn generate_attestation_evidence(&self) -> anyhow::Result<AttestationEvidence> {
let encryption_public_key = self.encryption_key_provider.get_serialized_public_key();
let attestation_report = self
.attestation_report_generator
.generate_attestation_report(&encryption_public_key)
.generate_attestation_report(&self.encryption_public_key)
.context("couldn't generate attestation report")?;
Ok(AttestationEvidence {
attestation: attestation_report,
encryption_public_key,
encryption_public_key: self.encryption_public_key.to_vec(),
// TODO(#3836): Implement signature generation and add the signing key.
signing_public_key: Vec::new(),
// TODO(#3640): Sign application data.
Expand Down
6 changes: 3 additions & 3 deletions oak_attestation/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ use core::future::Future;

use anyhow::Context;
use oak_crypto::{
encryptor::{AsyncEncryptionKeyHandle, EncryptionKeyHandle, ServerEncryptor},
encryption_key::{AsyncEncryptionKeyHandle, EncryptionKeyHandle},
encryptor::ServerEncryptor,
proto::oak::crypto::v1::{EncryptedRequest, EncryptedResponse},
EMPTY_ASSOCIATED_DATA,
};

const EMPTY_ASSOCIATED_DATA: &[u8] = b"";

/// Information about a public key.
#[derive(Debug, Clone)]
pub struct PublicKeyInfo {
Expand Down
Loading

0 comments on commit 9e03dea

Please sign in to comment.