From 5e4d2b4fae1ddc90e844f8c1d0713f7031b187db Mon Sep 17 00:00:00 2001 From: Grant Nunn Date: Mon, 1 Jun 2026 16:30:07 +0100 Subject: [PATCH 1/3] Extend TeePubKey for AKP key type for use in PQC algorithm for KBS Protocol. Signed-off-by: Grant Nunn --- Cargo.toml | 2 +- src/lib.rs | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ae28b45..c60d552 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kbs-types" description = "Rust (de)serializable types for KBS" -version = "0.16.0" +version = "0.17.0" authors = ["Sergio Lopez "] edition = "2021" repository = "https://github.com/virtee/kbs-types" diff --git a/src/lib.rs b/src/lib.rs index fdc3f10..ec7d9cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -104,6 +104,12 @@ pub enum TeePubKey { x: String, y: String, }, + AKP { + alg: String, + #[serde(rename = "pub")] + public_key: String + } + } #[cfg(feature = "std")] @@ -152,6 +158,20 @@ impl From<&TeePubKey> for ear::RawValue { RawValue::String(y.clone()), )); } + TeePubKey::AKP { alg, public_key } => { + map.push(( + RawValue::String("kty".to_string()), + RawValue::String("AKP".to_string()) + )); + map.push(( + RawValue::String("alg".to_string()), + RawValue::String(alg.clone()) + )); + map.push(( + RawValue::String("pub".to_string()), + RawValue::String(public_key.clone()) + )); + } } RawValue::Map(map) @@ -618,6 +638,44 @@ mod tests { ); } + #[test] + fn parse_attestation_akp() { + let data = r#" + { + "runtime-data": { + "nonce": "test_nonce", + "tee-pubkey": { + "kty": "AKP", + "alg": "fakealgorithm", + "pub": "fakepublickey" + } + }, + "tee-evidence": { + "primary_evidence": "test_primary_evidence", + "additional_evidence": "test_additional_evidence" + } + }"#; + + let attestation: Attestation = serde_json::from_str(data).unwrap(); + let tee_pubkey = attestation.runtime_data.tee_pubkey; + + let TeePubKey::AKP { alg, public_key } = tee_pubkey else { + panic!("Must be a AKP key"); + }; + + assert_eq!(attestation.runtime_data.nonce, "test_nonce"); + assert_eq!(alg, "fakealgorithm"); + assert_eq!(public_key, "fakepublickey"); + assert_eq!( + attestation.tee_evidence.primary_evidence, + "test_primary_evidence" + ); + assert_eq!( + attestation.tee_evidence.additional_evidence, + "test_additional_evidence" + ); + } + #[test] fn parse_error_information() { let data = r#" @@ -655,6 +713,16 @@ mod tests { let ear_raw: RawValue = (&tpk).into(); let json_str = serde_json::to_string(&ear_raw).unwrap(); assert_eq!(json_str, serde_json::to_string(&tpk).unwrap()); + + // AKP key. + let tpk = TeePubKey::AKP { + alg: "test".to_string(), + public_key: "test".to_string() + }; + let ear_raw: RawValue = (&tpk).into(); + let json_str = serde_json::to_string(&ear_raw).unwrap(); + assert_eq!(json_str, serde_json::to_string(&tpk).unwrap()); + } #[test] From 2009cbbc2b2c7c069317057deac0a718ca783a6f Mon Sep 17 00:00:00 2001 From: Grant Nunn Date: Mon, 1 Jun 2026 16:31:02 +0100 Subject: [PATCH 2/3] Explanatory comments. Signed-off-by: Grant Nunn --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index ec7d9cb..0e253b1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -104,6 +104,8 @@ pub enum TeePubKey { x: String, y: String, }, + /// Algorithm Key Pair (AKP) key type for PQC algorithm support as per + /// [draft-ietf-jose-pqc-kem-05](https://datatracker.ietf.org/doc/draft-ietf-jose-pqc-kem/) AKP { alg: String, #[serde(rename = "pub")] From b9c6cf9d9d48835588ba373c3e7b8b68c2ff7471 Mon Sep 17 00:00:00 2001 From: Grant Nunn Date: Wed, 10 Jun 2026 11:40:41 +0100 Subject: [PATCH 3/3] Cargo fmt. Signed-off-by: Grant Nunn --- src/lib.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0e253b1..a8ced18 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -109,9 +109,8 @@ pub enum TeePubKey { AKP { alg: String, #[serde(rename = "pub")] - public_key: String - } - + public_key: String, + }, } #[cfg(feature = "std")] @@ -163,15 +162,15 @@ impl From<&TeePubKey> for ear::RawValue { TeePubKey::AKP { alg, public_key } => { map.push(( RawValue::String("kty".to_string()), - RawValue::String("AKP".to_string()) + RawValue::String("AKP".to_string()), )); map.push(( RawValue::String("alg".to_string()), - RawValue::String(alg.clone()) + RawValue::String(alg.clone()), )); map.push(( RawValue::String("pub".to_string()), - RawValue::String(public_key.clone()) + RawValue::String(public_key.clone()), )); } } @@ -717,14 +716,13 @@ mod tests { assert_eq!(json_str, serde_json::to_string(&tpk).unwrap()); // AKP key. - let tpk = TeePubKey::AKP { - alg: "test".to_string(), - public_key: "test".to_string() + let tpk = TeePubKey::AKP { + alg: "test".to_string(), + public_key: "test".to_string(), }; let ear_raw: RawValue = (&tpk).into(); let json_str = serde_json::to_string(&ear_raw).unwrap(); assert_eq!(json_str, serde_json::to_string(&tpk).unwrap()); - } #[test]