48 Commits

Author SHA1 Message Date
Jonas Platte
ba5bf8cfce
Replace assert_matches by assert_matches2 2023-06-08 11:37:11 +02:00
Kévin Commaille
d78c3e11f1 signatures: Remove age_ts from reference hash calculation
According to a spec clarification
2023-05-24 20:08:20 +02:00
gnieto
7565588be7
signatures: Prevent accepting events without at least one valid signature
`verify_event` has been changed recently to be more aligned with the
spec. In the previous algorithm, it returned an error if the event was
not signed by at least one of the required entities.

The new algortihm is iterating over all the signtures for the required
entities *and* skipping unknown algorithms. If an event is signed only
by unkonwn algorithms, the event would be accepted and not verifications
will happen. In order to prevent that, we check that, at least, a single
key is checked. This covers the 2nd point in: https://spec.matrix.org/v1.6/appendices/#checking-for-a-signature

A few more test cases were added:

- The event is properly signed, but key map contains a key with an
  unknown algorithm. Under this circumstances, the event should be
  allowed.
- An event signed by multiple keys for an entity, should verify all
  those signatures
- An event signed by a single key with an unkown algorithm by the
  required entity, should fail
2023-03-02 09:34:57 +00:00
Jason Volk
87237bf100 signatures: Comply with the specified signature checking algorithm.
Based on research https://github.com/ruma/ruma/pull/1491#issuecomment-1445042510 by @zecakeh
2023-03-01 22:25:06 +01:00
Jason Volk
920a412da1 signatures: Skip keys which don't split so other keys can be used instead. 2023-03-01 22:25:06 +01:00
Kévin Commaille
f159776f52 chore: Make all applicable spec links use the latest spec instead of a specific version 2023-02-12 12:39:24 +01:00
Jonas Platte
fe5077b1a5
Upgrade base64 to 0.21 2023-01-31 18:01:01 +01:00
Jonas Platte
536341ca7e Upgrade base64 to 0.20 2022-12-20 15:34:50 +01:00
Jonas Platte
284b797e05
Add optional redacted_because insertion to redaction 2022-12-19 12:52:15 +01:00
Jonas Platte
ba9634f5bf
Update redact to take ownership of the event to be redacted 2022-12-19 10:42:27 +01:00
Kévin Commaille
045861441a doc: Update Matrix spec links to v1.4 2022-10-21 10:41:20 +02:00
Jonas Platte
c745d3baf7
Fix clippy lint 2022-09-02 14:07:28 +02:00
Jonas Platte
a4a95e74fa Address review feedback and finish canonical JSON move 2022-06-23 10:18:26 +02:00
Jonas Platte
940450b953 [WIP] Move redaction from ruma-signatures to ruma-common 2022-06-23 10:18:26 +02:00
Jonas Platte
402b2764fb common: Move CanonicalJson out of serde mod and behind a Cargo feature 2022-06-23 10:18:26 +02:00
Kévin Commaille
3deae8eac7 identifiers: Add MatrixVersionId::V10
According to MSC3604
2022-06-21 13:38:34 +02:00
Kévin Commaille
75cf634413 signatures: Make some test assertions more helpful 2022-06-14 10:01:49 +02:00
Jonas Platte
8912182c56
Increase usage of implicit named arguments in format strings 2022-06-03 10:06:28 +02:00
Jonas Platte
73c2963ebd
Enforce consistent semicolons after ()-typed expressions in blocks 2022-06-03 08:40:16 +02:00
Jonathan de Jong
49663f4adf
signatures: Update pkcs8, and add ring backwards compatibility 2022-05-30 14:43:21 +02:00
Jonas Platte
5f902851af
Upgrade to Rust 2021 2022-05-27 12:04:23 +02:00
Jonathan de Jong
cc72ddb689
Implement MSC2870 (Protect server ACLs from redaction) 2022-04-27 10:22:43 +02:00
Jonas Platte
6100a0fa12 Use new owned ID types in more places 2022-04-20 10:39:36 +02:00
Jonas Platte
d855ec33d6 identifiers: Update ToOwned implementations to use new types
… and a lot of changes that cascaded from that.
2022-04-20 10:39:36 +02:00
Timo Kösters
83e46b6aea
state-res: Fix restricted joins 2022-03-14 15:02:21 +01:00
Kévin Commaille
bdcf07be87
common: Merge ruma-serde into ruma-common 2022-03-10 12:11:00 +01:00
Kévin Commaille
088d1872b7
common: Merge ruma-identifiers into ruma-common 2022-03-09 17:46:51 +00:00
Jonathan de Jong
936bb64e84
Update links to spec.matrix.org/v1.2 2022-02-18 19:45:04 +01:00
Jonas Platte
41d6bcc2a6
Format code in doc comments 2022-02-18 11:33:16 +01:00
Kévin Commaille
2da8a34ff4
signatures: Move Room v9 allowed content keys out of unstable-pre-spec
Part of #849
2022-02-10 18:11:29 +01:00
Jonathan de Jong
e4d8761222
signatures: Add redact_content function 2022-02-02 14:27:27 +01:00
Jonathan de Jong
bdf4a86770
signatures: Add redact_in_place 2022-02-01 15:03:22 +01:00
Jonas Platte
b7bcecbb77
serde: Fix lots of issues from previous commit 2022-01-23 14:10:57 +01:00
Jonas Platte
4c859c5aeb
Introduce a Base64 type and use it where applicable 2022-01-13 16:22:21 +01:00
Jonas Platte
2f732bf9c2
signatures: Implement room version 9 redaction change 2021-12-17 18:58:40 +01:00
Jonas Platte
881f64fd64
signatures: Simplify imports 2021-11-27 01:26:02 +01:00
Jonas Platte
6b76d7813e
identifiers: Shorten RoomVersionId variant names 2021-11-26 01:07:26 +01:00
Jonas Platte
3ce578f384
identifiers: Make UserId a DST 2021-11-26 00:40:40 +01:00
Jonas Platte
52608cc72c
identifiers: Make EventId a DST 2021-11-25 22:34:40 +01:00
Jonas Platte
438efee143
identifiers: Remove Box<$id> aliases 2021-11-25 21:07:14 +01:00
Jonas Platte
aa5fdf9d22
Merge serde attributes and improve docs 2021-10-08 12:49:13 +02:00
Jonas Platte
3c76fa1492
signatures: Fix verify_json and sign_json enforcing PDU size limits
These functions are used for request signatures too.
2021-08-10 15:22:47 +02:00
Devin Ragotzy
96567a295e
signatures: Fix canonical json functions to now return Result
signatures: Fix canonical json functions to now return Result
2021-08-10 15:22:26 +02:00
Jonathan de Jong
cc50f8b8dc
Convert ruma-signatures error story into thiserror 2021-06-17 19:43:22 +02:00
Jonathan de Jong
b6f0cb9715
signatures: Replace ring with ed25519-dalek 2021-06-17 19:43:22 +02:00
Jonathan de Jong
42bbb81bd2
Tolerate slightly malformed base64
* add in fixes

* cargo fmt and newline

* sort dependencies
2021-05-24 22:31:36 +02:00
Devin Ragotzy
c6aa2e0428 Fix clippy warnings across workspace 2021-05-06 06:16:28 -04:00
Jonas Platte
3db0ea7026
Move all crates into a new crates directory 2021-05-03 15:50:27 +02:00