Skip to content

Commit

Permalink
Handle "ear.veraison.key-attestation" on deserialisation
Browse files Browse the repository at this point in the history
Fix #7

Signed-off-by: Thomas Fossati <[email protected]>
  • Loading branch information
thomas-fossati committed Jan 11, 2024
1 parent b6f8ad5 commit bd6f25d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/appraisal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ impl<'de> Visitor<'de> for AppraisalVisitor {
loop {
if self.is_human_readable {
match map.next_key::<&str>()? {
Some("ear.veraison.key-attestation") => {
appraisal.key_attestation = Some(map.next_value::<KeyAttestation>()?)
}
Some("ear.status") => appraisal.status = map.next_value::<TrustTier>()?,
Some("ear.trustworthiness-vector") => {
appraisal.trust_vector = map.next_value::<TrustVector>()?
Expand Down
19 changes: 19 additions & 0 deletions src/ear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,4 +656,23 @@ MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgPp4XZRnRHSMhGg0t
assert_eq!(ear.vid.developer, ear2.vid.developer);
assert_eq!(ear.raw_evidence, ear2.raw_evidence);
}

#[test]
fn verify() {
const VERIF_KEY: &str = r#"
{
"crv": "P-256",
"kty": "EC",
"x": "usWxHK2PmfnHKwXPS54m0kTcGJ90UiglWiGahtagnv8",
"y": "IBOL-C3BttVivg-lSreASjpkttcsz-1rb7btKLv8EX4"
}
"#;

let ear_jwt = "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJlYXIudmVyaWZpZXItaWQiOnsiYnVpbGQiOiJOL0EiLCJkZXZlbG9wZXIiOiJWZXJhaXNvbiBQcm9qZWN0In0sImVhdF9ub25jZSI6IjNXSHlqbmRHT1RJPSIsImVhdF9wcm9maWxlIjoidGFnOmdpdGh1Yi5jb20sMjAyMzp2ZXJhaXNvbi9lYXIiLCJpYXQiOjE3MDQ5MDgxOTUsInN1Ym1vZHMiOnsiUE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WEMvYzQiLCJ0cG1WZXIiOiIyLjAifSwicGF0Ijp7ImF0dGVzdEluZm8iOiIvMVJEUjRBWUFDSUFDNE9mcktPRktIbGEzakV6VVBLM01KQ1MrVzJ0d0JWVEVERjhFOTZ3MVZaWkFBZ0FBUUlEQkFVR0J3QUFBQUFhdkk5Mk9IVGc5M050eWJRQkRNNkg1UlJBMWM0QUFBQUJBQXNEQndBQUFDQXVxYXVSbU5GamdBZEFETkxEdnZITWRGdUdTM1lCR2c0YnhTR0FyR1JTMUE9PSIsImtpZCI6IkFhRkpRQ1FIM3NPdHFIV1RVazZaNStmdy9rMTh2eXZKRW5ZdzFNN2tUdnRUIiwic2lnIjoiQUJnQUN3QWdNcWN0TlRuZFh3VU5MZkNERW1lOC81c0hVM2diaGFPL05OdW4xY2tpT0xBQUlLVFkwU2VWUUJIWkpuaXNPRzNTb2VOQ1dHYTJnWlMrSUhuWkN2M3dUOTVJIiwidHBtVmVyIjoiMi4wIn19LCJlYXIudmVyYWlzb24ua2V5LWF0dGVzdGF0aW9uIjp7ImFrcHViIjoiTUZrd0V3WUhLb1pJemowQ0FRWUlLb1pJemowREFRY0RRZ0FFb1Q4RUhiYXNsb0tjcEQ2bXJjMDdFUFd0dG5uUEpfNmN6eXpYOXlYMm5CTjJQOUJvaDBwOURiaWphR2lVUXVmREdYM1pfRlhkVWp3ckJNRkQtOU9NbncifX19fQ.eRyCRmGEOt2GeMvi1-PiSaIVOuixBHwz8FYPSm7XuKnZd6XYe_8HQaCXEtarpOppvzoyHcZvU_4rV54iE7PQaw";

let ear = Ear::from_jwt_jwk(ear_jwt, Algorithm::ES256, VERIF_KEY.as_bytes())
.expect("successfully verified");

assert_eq!("tag:github.com,2023:veraison/ear", ear.profile);
}
}

0 comments on commit bd6f25d

Please sign in to comment.