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

Make our remote attestation crate UEFI compatible using the ring version from on open PR #2659

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion remote_attestation/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ anyhow = { version = "*", default-features = false }
bytes = { version = "*", default-features = false }
log = "*"
prost = { version = "*", default-features = false, features = ["prost-derive"] }
ring = "*"
ring = { git = "https://github.com/jyao1/ring", branch = "/upstream/uefi_support" }

[build-dependencies]
prost-build = "*"
Expand Down
16 changes: 12 additions & 4 deletions remote_attestation/rust/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,13 @@ impl KeyNegotiator {
let (encryption_key, decryption_key) = agreement::agree_ephemeral(
self.private_key,
&agreement::UnparsedPublicKey::new(KEY_AGREEMENT_ALGORITHM, peer_public_key),
anyhow!("Couldn't derive session keys"),
|key_material| {
|key_material| -> Result<
(
Result<[u8; KEY_AGREEMENT_ALGORITHM_KEY_LENGTH], anyhow::Error>,
Result<[u8; KEY_AGREEMENT_ALGORITHM_KEY_LENGTH], anyhow::Error>,
),
anyhow::Error,
> {
let key_material = key_material
.try_into()
.map_err(anyhow::Error::msg)
Expand Down Expand Up @@ -284,6 +289,8 @@ impl KeyNegotiator {
}
},
)
.map_err(anyhow::Error::msg)
.context("Couldn't derive session keys")?
.context("Couldn't agree on session keys")?;
Ok((
EncryptionKey(encryption_key.context("Couldn't derive encryption key")?),
Expand Down Expand Up @@ -351,8 +358,9 @@ impl Signer {
let rng = ring::rand::SystemRandom::new();
let key_pair_pkcs8 = EcdsaKeyPair::generate_pkcs8(SIGNING_ALGORITHM, &rng)
.map_err(|error| anyhow!("Couldn't generate PKCS#8 key pair: {:?}", error))?;
let key_pair = EcdsaKeyPair::from_pkcs8(SIGNING_ALGORITHM, key_pair_pkcs8.as_ref())
.map_err(|error| anyhow!("Couldn't parse generated key pair: {:?}", error))?;
let key_pair =
EcdsaKeyPair::from_pkcs8(SIGNING_ALGORITHM, key_pair_pkcs8.as_ref(), &rng)
.map_err(|error| anyhow!("Couldn't parse generated key pair: {:?}", error))?;

Ok(Self { key_pair })
}
Expand Down