diff options
Diffstat (limited to 'src/federation/event.rs')
| -rw-r--r-- | src/federation/event.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/federation/event.rs b/src/federation/event.rs index b8e89f1..fc519d0 100644 --- a/src/federation/event.rs +++ b/src/federation/event.rs @@ -53,6 +53,16 @@ impl Event { /// back to itself, the signature doesn't hold, or it is larger than federation 1 /// allows. pub(crate) fn read(bytes: &[u8]) -> Option<Event> { + Self::parse(bytes, true) + } + + /// The event `bytes` are, as `read` reads them, but for its signature, which isn't + /// checked: for bytes a store took already, whose signature held then. + pub(crate) fn read_taken(bytes: &[u8]) -> Option<Event> { + Self::parse(bytes, false) + } + + fn parse(bytes: &[u8], verify: bool) -> Option<Event> { if bytes.len() > LARGEST { return None; } @@ -81,7 +91,7 @@ impl Event { return None; } let sig = json.get("sig")?.as_str()?; - if !keys::verifies(&public, sig, &json.without("sig").bytes()) { + if verify && !keys::verifies(&public, sig, &json.without("sig").bytes()) { return None; } let what = json.get(does)?; |
