Skip to content

Commit 12eed9f

Browse files
authored
Add validated keys to the output (#44)
1 parent 258d74f commit 12eed9f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

crates/http-signature-directory/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,18 @@ $ RUST_LOG=debug http-signature-directory https://http-message-signatures-exampl
5555
"thumbprint": "poqkLGiymh_W0uP6PZFw-dvez3QJT5SolqXBCW38r0U",
5656
"valid": true,
5757
"signature_verified": true,
58+
"raw_key_data": {
59+
"kty": "OKP",
60+
"crv": "Ed25519",
61+
"x": "JrQLj5P_89iXES9-vFgrIy29clF9CC_oPPsw3c5D0bs"
62+
},
5863
"error": null
5964
}
6065
],
6166
"errors": [],
6267
"warnings": []
6368
}
69+
}
6470
```
6571

6672
## Security Considerations

crates/http-signature-directory/src/main.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,17 @@ struct KeyValidationInfo {
4646
thumbprint: String,
4747
valid: bool, // Checks if the key structure is valid (correct key type, curve is Ed25519, import succeeds)
4848
signature_verified: bool, // Checks if the HTTP signature on the directory response is cryptographically valid using this key
49+
raw_key_data: Option<RawKeyData>,
4950
error: Option<String>,
5051
}
5152

53+
#[derive(Serialize, Deserialize)]
54+
struct RawKeyData {
55+
kty: String,
56+
crv: String,
57+
x: String,
58+
}
59+
5260
struct SignedDirectory {
5361
signature: Vec<String>,
5462
input: Vec<String>,
@@ -219,6 +227,7 @@ fn main() -> Result<(), String> {
219227
thumbprint: thumbprint.clone(),
220228
valid: false,
221229
signature_verified: false,
230+
raw_key_data: None,
222231
error: None,
223232
};
224233

@@ -278,6 +287,11 @@ fn main() -> Result<(), String> {
278287
match verifier.verify(&keyring, None) {
279288
Ok(_) => {
280289
key_info.signature_verified = true;
290+
key_info.raw_key_data = Some(RawKeyData {
291+
kty: "OKP".to_string(),
292+
crv: crv.to_string(),
293+
x: x.to_string(),
294+
});
281295
}
282296
Err(err) => {
283297
key_info.error = Some(format!(

0 commit comments

Comments
 (0)