Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oak_crypto depends on oak_dice #4688

Open
tiziano88 opened this issue Jan 19, 2024 · 1 comment
Open

oak_crypto depends on oak_dice #4688

tiziano88 opened this issue Jan 19, 2024 · 1 comment
Assignees

Comments

@tiziano88
Copy link
Collaborator

          that's a good point, I agree oak_crypto should not depend on oak_dice at all, but it looks like it does already:

impl TryFrom<&oak_dice::evidence::RestrictedKernelDiceData> for EncryptionKeyProvider {
type Error = anyhow::Error;
fn try_from(
dice_data: &oak_dice::evidence::RestrictedKernelDiceData,
) -> Result<Self, Self::Error> {
let claims = dice_data
.evidence
.application_keys
.claims()
.map_err(|err| {
anyhow::anyhow!("couldn't parse encryption public key certificate: {err}")
})?;
let private_key = PrivateKey::from_bytes(
&dice_data.application_private_keys.encryption_private_key
[..oak_dice::evidence::X25519_PRIVATE_KEY_SIZE],
)
.map_err(|error| anyhow::anyhow!("couldn't deserialize private key: {}", error))?;
let public_key = {
let cose_key =
oak_dice::cert::get_public_key_from_claims_set(&claims).map_err(|err| {
anyhow::anyhow!("couldn't get public key from certificate: {err}")
})?;
oak_dice::cert::cose_key_to_hpke_public_key(&cose_key)
.map_err(|err| anyhow::anyhow!("couldn't extract public key: {err}"))?
};
let encryption_key_provider = EncryptionKeyProvider::new(
private_key,
PublicKey::from_bytes(&public_key)
.map_err(|err| anyhow::anyhow!("couldn't decode public key: {err}"))?,
);
Ok(encryption_key_provider)
}
}

Maybe that impl should be moved to oak_dice?

Originally posted by @tiziano88 in #4683 (comment)

@tiziano88
Copy link
Collaborator Author

Not super urgent, but the dependency here is backwards -- oak_crypto should know nothing about DICE. In fact, we may want to use it on Intel TDX (for which we may not rely on DICE at all).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants