Skip to content

add support for CMW evidence format - agent side #1051

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

HarshvMahawar
Copy link

Server side - keylime/keylime#1777

Concise Summary

Support CMW-based evidence serving instead of custom quote format

This PR adds initial support for sending attestation evidence encoded using the Conceptual Message Wrapper (CMW), as prescribed by the IETF draft. It introduces encoding logic and also introduced an api-version v2.4 (subject to approval) to serve the CMW

e.g.

curl -vk --cert /var/lib/keylime/cv_ca/client-cert.crt --key /var/lib/keylime/cv_ca/client-private.pem "https://localhost:9002/v2.4/quotes/integrity?nonce=1234567890ABCDEF&mask=0x10401&partial=0" | jq

Copy link

codecov bot commented Jul 15, 2025

Codecov Report

❌ Patch coverage is 84.77509% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.41%. Comparing base (d7003ab) to head (f13aceb).

Files with missing lines Patch % Lines
keylime/src/cmw.rs 82.20% 42 Missing ⚠️
keylime-agent/src/quotes_handler.rs 96.07% 2 Missing ⚠️
Additional details and impacted files
Flag Coverage Δ
e2e-testsuite 58.41% <84.77%> (-0.49%) ⬇️
upstream-unit-tests 58.41% <84.77%> (-0.49%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
keylime-agent/src/api.rs 81.01% <100.00%> (+0.49%) ⬆️
keylime/src/config/base.rs 87.08% <ø> (ø)
keylime-agent/src/quotes_handler.rs 68.50% <96.07%> (+6.92%) ⬆️
keylime/src/cmw.rs 82.20% <82.20%> (ø)

... and 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ansasaki ansasaki mentioned this pull request Jul 22, 2025
30 tasks
@THS-on
Copy link
Member

THS-on commented Jul 27, 2025

@HarshvMahawar make sure that all the test pass.

@ansasaki can you have a look?

Comment on lines +187 to +218
pub fn decode_cmw(cmw: &CMW) -> Result<HashMap<String, Value>, String> {
let mut result = HashMap::new();

let tpms_attest = general_purpose::URL_SAFE_NO_PAD
.decode(&cmw.evidence.tpms_attest.1)
.map_err(|e| format!("Failed to decode TPMS_ATTEST: {}", e))?;
result.insert("TPMS_ATTEST".to_string(), json!(tpms_attest));

let tpmt_signature = general_purpose::URL_SAFE_NO_PAD
.decode(&cmw.evidence.tpmt_signature.1)
.map_err(|e| format!("Failed to decode TPMT_SIGNATURE: {}", e))?;
result.insert("TPMT_SIGNATURE".to_string(), json!(tpmt_signature));

let pcrs = general_purpose::URL_SAFE_NO_PAD
.decode(&cmw.evidence.pcr_values.1)
.map_err(|e| format!("Failed to decode PCRs: {}", e))?;
result.insert("PCRs".to_string(), json!(pcrs));

let event_log_bin = general_purpose::URL_SAFE_NO_PAD
.decode(&cmw.evidence.event_log.1)
.map_err(|e| format!("Failed to decode event_log: {}", e))?;
result.insert("event_log".to_string(), json!(event_log_bin));

let metadata_str = general_purpose::URL_SAFE_NO_PAD
.decode(&cmw.evidence.keylime_metadata.1)
.map_err(|e| format!("Failed to decode keylime_metadata: {}", e))?;
let metadata_json: Value = serde_json::from_slice(&metadata_str)
.map_err(|e| format!("Invalid metadata JSON: {}", e))?;
result.insert("keylime_metadata".to_string(), metadata_json);

Ok(result)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be possible to derive the Deserialiaze trait for the Evidence structure (and all internal structures) and set the method used for deserialization using serde annotations (maybe deserialize_with)?

Maybe it would be possible to reuse the methods in keylime/src/serialization.

Then you could use the Evidence structure directly instead of using a generic HashMap.

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

Successfully merging this pull request may close these issues.

3 participants