melos 0.0.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +71 -11
- data/docs/roadmap.md +302 -0
- data/docs/validation.md +172 -0
- data/lib/melos/capabilities.rb +18 -0
- data/lib/melos/client.rb +255 -0
- data/lib/melos/credential/x509.rb +91 -0
- data/lib/melos/crypto.rb +109 -15
- data/lib/melos/epoch_secrets.rb +166 -0
- data/lib/melos/errors.rb +18 -0
- data/lib/melos/external_sender.rb +78 -0
- data/lib/melos/group/validation.rb +310 -0
- data/lib/melos/group.rb +1087 -0
- data/lib/melos/key_package_bundle.rb +67 -0
- data/lib/melos/persistence.rb +45 -0
- data/lib/melos/private_tree.rb +70 -0
- data/lib/melos/ratchet_tree.rb +407 -0
- data/lib/melos/secret_tree.rb +130 -88
- data/lib/melos/struct/base.rb +46 -20
- data/lib/melos/struct/structs.rb +205 -87
- data/lib/melos/tree.rb +4 -120
- data/lib/melos/vec.rb +20 -35
- data/lib/melos/version.rb +1 -1
- data/lib/melos.rb +13 -2
- metadata +18 -22
- data/lib/melos/key_schedule.rb +0 -62
- data/lib/melos/struct/ratchet_tree.rb +0 -324
- data/test_vectors/crypto-basics.json +0 -303
- data/test_vectors/deserialization.json +0 -58
- data/test_vectors/key-schedule.json +0 -926
- data/test_vectors/message-protection.json +0 -142
- data/test_vectors/messages.json +0 -5702
- data/test_vectors/passive-client-handling-commit.json +0 -2683
- data/test_vectors/passive-client-random.json +0 -2657
- data/test_vectors/passive-client-welcome.json +0 -814
- data/test_vectors/psk_secret.json +0 -2382
- data/test_vectors/secret-tree.json +0 -4846
- data/test_vectors/transcript-hashes.json +0 -58
- data/test_vectors/tree-math.json +0 -8276
- data/test_vectors/tree-operations.json +0 -47
- data/test_vectors/tree-validation.json +0 -11839
- data/test_vectors/treekem.json +0 -14877
- data/test_vectors/welcome.json +0 -51
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: be015b7f9296463b69d9c5026c935ce90e870f528b4c04a1ab0b7f21e1836ebe
|
|
4
|
+
data.tar.gz: b2f0d94ebad996af6f23aa166caf145d7ae9ddc61cbd1e94e6c59ad9938780c3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 796f95da60f41517aea2ebbacacecf435f1ee74c1a60a2d0237aa35319683cac6ebdcf178cdb99c834b99801a2b56dbd536798562984ce28be122cac554a440f
|
|
7
|
+
data.tar.gz: cc550a93879a9c8c27a6d0dae56a92b6d665cc4fc69528f27a16df32ede7a3e6e6f67671c6936e343ca055c911436120b34518c741218e0733851acbb2f58efc
|
data/README.md
CHANGED
|
@@ -7,18 +7,78 @@ a [Messaging Layer Security Protocol](https://www.rfc-editor.org/rfc/rfc9420.htm
|
|
|
7
7
|
|
|
8
8
|
(yes, [an mls gem](https://rubygems.org/gems/mls) happened to exist since 2014, so...)
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Implementation status
|
|
11
11
|
|
|
12
|
-
As of version 0.0
|
|
12
|
+
As of version 0.1.0, this implements:
|
|
13
13
|
|
|
14
|
-
- Serialization
|
|
15
|
-
- Key
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
|
|
14
|
+
- Serialization and deserialization of the RFC 9420 structures
|
|
15
|
+
- Key schedule, secret tree, pre-shared keys, transcript hashes
|
|
16
|
+
- The ratchet tree: TreeKEM (creating and processing UpdatePaths), tree hashes, parent hashes
|
|
17
|
+
- Groups: creating a group, Add / Remove / PreSharedKey / GroupContextExtensions proposals,
|
|
18
|
+
commits with an UpdatePath and the matching Welcome, joining via Welcome,
|
|
19
|
+
application messages as PrivateMessage, handshake messages as PublicMessage or PrivateMessage
|
|
20
|
+
- Update proposals, commits without an UpdatePath where the RFC allows them, exporters
|
|
21
|
+
- The deletion schedule of Section 9.2 (as far as Ruby allows: references are dropped, strings are not zeroized)
|
|
22
|
+
- External senders and new-member proposals (`Melos::ExternalSender`, `Client#create_new_member_proposal`)
|
|
23
|
+
- Resumption PSKs, ReInit (`Group#create_reinit_proposal`, `Client#reinit_group`) and subgroup branching (`Client#branch_group`)
|
|
24
|
+
- External commits, including resync (`Group#group_info`, `Client#join_by_external_commit`)
|
|
25
|
+
- X.509 credentials (`Melos::Credential::X509`, a `credential_validator:` over an `OpenSSL::X509::Store`)
|
|
26
|
+
- Saving and restoring client and group state (`to_h` / `from_h`, JSON through `Melos::Persistence`)
|
|
27
|
+
- Out-of-order application messages and messages from recent epochs, with bounds on both (Section 15.3)
|
|
28
|
+
- Most MUST-level validations of the RFC; [docs/validation.md](docs/validation.md) maps each one to the code
|
|
29
|
+
- All test vectors in [mls-implementations/test-vectors.md](https://github.com/mlswg/mls-implementations/blob/main/test-vectors.md),
|
|
30
|
+
plus round-trip tests in which several members create, join, message and leave a group
|
|
19
31
|
|
|
20
|
-
|
|
32
|
+
Interop with OpenMLS and MLS++ is tested through the mls-implementations harness; see
|
|
33
|
+
[interop/README.md](interop/README.md) for how to run it and the results.
|
|
21
34
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
Messages cross between members as `Melos::Struct::MLSMessage` objects; `raw` gives the bytes to
|
|
38
|
+
send and `Melos::Struct::MLSMessage.new(bytes)` parses them.
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
require 'melos'
|
|
42
|
+
|
|
43
|
+
# cipher suite 1 is MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519
|
|
44
|
+
alice = Melos::Client.new(1, identity: 'alice')
|
|
45
|
+
bob = Melos::Client.new(1, identity: 'bob')
|
|
46
|
+
|
|
47
|
+
# Bob publishes a KeyPackage
|
|
48
|
+
bob_key_package = bob.create_key_package
|
|
49
|
+
|
|
50
|
+
# Alice creates a group and adds Bob
|
|
51
|
+
group = alice.create_group("some group id")
|
|
52
|
+
group.create_add_proposal(bob_key_package.message)
|
|
53
|
+
result = group.create_commit
|
|
54
|
+
# result.commit is the Commit to send to the group, result.welcome the Welcome for Bob;
|
|
55
|
+
# merge once the Delivery Service has accepted the commit
|
|
56
|
+
group.merge_commit(result.staged)
|
|
57
|
+
|
|
58
|
+
# Bob joins
|
|
59
|
+
bob_group = bob.join_group(result.welcome)
|
|
60
|
+
|
|
61
|
+
# and talks
|
|
62
|
+
message = bob_group.create_application_message("hello")
|
|
63
|
+
group.process_message(message).content.application_data # => "hello"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`Melos::Group` holds one member's view of one group. `Melos::Client` holds the long-lived identity,
|
|
67
|
+
the external PSKs and the KeyPackages it has published.
|
|
68
|
+
|
|
69
|
+
State can be saved and restored, which a client must do to avoid reusing nonces after a restart
|
|
70
|
+
(RFC 9420 6.3.1). The state holds private keys; encrypting it at rest is up to the application.
|
|
71
|
+
|
|
72
|
+
```ruby
|
|
73
|
+
json = Melos::Persistence.dump_client(alice) # or alice.to_h, for Marshal or MessagePack
|
|
74
|
+
alice = Melos::Persistence.load_client(json) # pass credential_validator: etc. again here
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Tests
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
bundle exec rake test
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
runs a subset of the test vectors; `TEST_ALL=1 bundle exec rake test` runs all of them, for every cipher suite.
|
|
84
|
+
The vectors are the ones from [mls-implementations](https://github.com/mlswg/mls-implementations), in `test_vectors/`.
|
data/docs/roadmap.md
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
# Roadmap: the missing features, smallest first
|
|
2
|
+
|
|
3
|
+
What melos does not implement yet, as of 0.1.0, ordered by implementation effort. Each item says
|
|
4
|
+
what the RFC asks for, what the code already has, what to build, and how to test it. Effort is
|
|
5
|
+
S (hours), M (a day or two), L (a week or more). Items are independent unless noted.
|
|
6
|
+
|
|
7
|
+
The list comes from the "not yet" section of the README, the deferred rows of
|
|
8
|
+
[validation.md](validation.md), and the `TODO` comments in `lib/`.
|
|
9
|
+
|
|
10
|
+
## 1. Exporters (S) — RFC 8.5 — done in 7c57cac
|
|
11
|
+
|
|
12
|
+
**RFC.** `MLS-Exporter(Label, Context, Length) = ExpandWithLabel(DeriveSecret(exporter_secret, Label), "exported", Hash(Context), Length)`.
|
|
13
|
+
|
|
14
|
+
**Have.** `EpochSecrets#exporter_secret`, `Crypto.expand_with_label`, `Crypto.derive_secret`.
|
|
15
|
+
|
|
16
|
+
**Build.** `EpochSecrets#export(label, context, length)` and `Group#export_secret(label, context, length)`
|
|
17
|
+
delegating to the current epoch. Also expose `Group#epoch_authenticator` (exists) and the
|
|
18
|
+
`resumption_psk` of past epochs is already kept.
|
|
19
|
+
|
|
20
|
+
**Test.** There is no exporter vector in mls-implementations; test determinism between two members in
|
|
21
|
+
the round-trip test, and against a hand computation in `test_key_schedule.rb`.
|
|
22
|
+
|
|
23
|
+
## 2. An error class hierarchy (S) — done in 43a039d
|
|
24
|
+
|
|
25
|
+
**Have.** Every rejection raises `ArgumentError` with a message. Callers cannot tell a malformed
|
|
26
|
+
message from a wrong argument, or a commit that removed them from a tampered one.
|
|
27
|
+
|
|
28
|
+
**Build.** `Melos::Error < StandardError`, with `Melos::ProtocolError` (malformed or invalid input: the
|
|
29
|
+
validation failures), `Melos::StateError` (wrong group state: inactive group, pending proposals,
|
|
30
|
+
unknown epoch) and `Melos::UnsupportedError` (features below). Replace the `raise ArgumentError` sites
|
|
31
|
+
in `group.rb`, `group/validation.rb`, `ratchet_tree.rb`, `secret_tree.rb`, `vec.rb` and `structs.rb`.
|
|
32
|
+
Keep `ArgumentError` for genuine caller mistakes. `test_validation.rb` then asserts the specific class.
|
|
33
|
+
|
|
34
|
+
Do this before 3 to 12, since all of them add error sites.
|
|
35
|
+
|
|
36
|
+
## 3. Partial commits: omit the UpdatePath when allowed (S) — RFC 12.4 — done in e9a27c9
|
|
37
|
+
|
|
38
|
+
**RFC.** The path MAY be omitted when the commit covers at least one proposal and none of them is of a
|
|
39
|
+
path-required type (Update, Remove, ExternalInit, GroupContextExtensions). The commit secret is then
|
|
40
|
+
all zeros.
|
|
41
|
+
|
|
42
|
+
**Have.** `Group#stage` already handles `commit.path == nil` (zero commit secret, no decryption) and
|
|
43
|
+
enforces the path-required rule. `create_commit` always builds a path (`TODO` at group.rb:351).
|
|
44
|
+
|
|
45
|
+
**Build.** A `path:` option on `create_commit`: `:always` (default, keeps PCS for the committer),
|
|
46
|
+
`:if_required`. When omitted, no `create_update_path`, no private tree change, no `path_secret` in the
|
|
47
|
+
Welcome (`GroupSecrets.path_secret` nil, which `from_welcome` already accepts).
|
|
48
|
+
|
|
49
|
+
**Test.** Round trip: Alice adds Bob with `path: :if_required`; Bob joins without a path secret and
|
|
50
|
+
can decrypt Alice's next commit; a Remove with `path: :if_required` still produces a path.
|
|
51
|
+
|
|
52
|
+
## 4. Update proposals (S/M) — RFC 12.1.2, 7.3 — done
|
|
53
|
+
|
|
54
|
+
**RFC.** A member replaces its own leaf with a fresh encryption key (`leaf_node_source = update`,
|
|
55
|
+
signed with group id and leaf index). When a commit applies the Update, the member's leaf private
|
|
56
|
+
key becomes the new one. The committer must not commit its own Update.
|
|
57
|
+
|
|
58
|
+
**Have.** Receiving side is complete: `apply_proposals` validates the leaf (context `:update`) and
|
|
59
|
+
replaces it. `KeyPackageBundle.generate` shows how a signed leaf is built.
|
|
60
|
+
|
|
61
|
+
**Build.** `Group#create_update_proposal(capabilities: nil, extensions: nil)`: new encryption key pair,
|
|
62
|
+
`LeafNode.create(leaf_node_source: UPDATE, ...)` from the current leaf, `sign(suite, key, group_id,
|
|
63
|
+
leaf_index)`, send via `create_proposal`. Remember the private key in a `@pending_updates` map keyed
|
|
64
|
+
by the new encryption key. In `merge_commit`, if our leaf now carries one of those keys, set
|
|
65
|
+
`private_tree[leaf_index * 2]` to it and drop the rest. `create_commit` already refuses our own
|
|
66
|
+
Update in the list (12.2), so a member with a pending Update must wait for someone else's commit, or
|
|
67
|
+
commit without it (its path replaces the leaf anyway).
|
|
68
|
+
|
|
69
|
+
**Test.** Bob proposes an Update, Alice commits it, both agree; Bob's private tree is consistent
|
|
70
|
+
and he can still decrypt the next commit. Two pending Updates from Bob: the committer applies one.
|
|
71
|
+
|
|
72
|
+
## 5. Deletion schedule (M) — RFC 9.2, 7.5 — done
|
|
73
|
+
|
|
74
|
+
**RFC.** Consumed secrets MUST be deleted immediately: `commit_secret`, `joiner_secret`,
|
|
75
|
+
`epoch_secret`, `encryption_secret` of the epoch and `init_secret` of the previous one, the secret
|
|
76
|
+
tree node secrets on the path to a used leaf, used ratchet secrets, and the path and node secrets
|
|
77
|
+
used to derive updated nodes. Unconsumed values MAY be kept for a bounded time.
|
|
78
|
+
|
|
79
|
+
**Have.** `merge_commit` drops the previous `EpochSecrets` and the staged commit. `SecretTree::Ratchet`
|
|
80
|
+
forgets each ratchet secret as it steps. But `EpochSecrets` memoizes every derived secret for the
|
|
81
|
+
epoch's life, keeps `joiner_secret` and `psk_secret`, and `PrivateTree` keeps private keys for nodes
|
|
82
|
+
that no longer exist or were replaced (the stale-key case the treekem test notes).
|
|
83
|
+
|
|
84
|
+
**Build.** `EpochSecrets#consume!` dropping `epoch_secret`, `joiner_secret`, `init_secret` and
|
|
85
|
+
`encryption_secret` once the secret tree exists and the Welcome is built; `PrivateTree#prune!(tree)`
|
|
86
|
+
removing keys whose node is blank or has a different public key, called from `merge_commit`;
|
|
87
|
+
`StagedCommit` cleared of `path_secrets` once the Welcome exists. Ruby strings cannot be reliably
|
|
88
|
+
zeroized, so this is about not retaining references; say so in the docs.
|
|
89
|
+
|
|
90
|
+
**Test.** After a commit, the previous epoch's secrets are gone from the group; `private_tree`
|
|
91
|
+
holds exactly the keys for nodes on our direct path that exist.
|
|
92
|
+
|
|
93
|
+
## 6. Out-of-order and old-epoch application messages (M) — RFC 9.1, 15.3, 12.4.2 — done
|
|
94
|
+
|
|
95
|
+
**RFC.** Receivers keep unused generation keys of a sender's ratchet for a while, and the secret
|
|
96
|
+
trees of recent epochs, so delayed and reordered messages decrypt. Applications SHOULD bound how
|
|
97
|
+
far a ratchet may be advanced by one message and how many unused keys are kept.
|
|
98
|
+
|
|
99
|
+
**Have.** `SecretTree::Ratchet#ratchet_until` refuses any generation older than the last derived
|
|
100
|
+
(`TODO` at secret_tree.rb:32); `Group#unprotect` rejects any epoch but the current one
|
|
101
|
+
(`TODO` at group.rb:219).
|
|
102
|
+
|
|
103
|
+
**Build.** In `Ratchet`, a `Hash` of unconsumed `generation => [key, nonce]` with a maximum size and a
|
|
104
|
+
maximum forward jump, both options; `ratchet_until` serves from it and deletes on use. In `Group`,
|
|
105
|
+
keep `EpochSecrets` of the last N epochs (option, default a small number) in `@past_epochs`, and let
|
|
106
|
+
`unprotect` select by `PrivateMessage.epoch` for application messages only. Handshake messages stay
|
|
107
|
+
current-epoch only. Interacts with 5: a retained epoch's secrets are not yet "consumed".
|
|
108
|
+
|
|
109
|
+
**Test.** Deliver two application messages in reverse order; deliver an application message from the
|
|
110
|
+
previous epoch after a commit; a generation jump beyond the bound is rejected.
|
|
111
|
+
|
|
112
|
+
**Done as.** `SecretTree::Ratchet` keeps skipped `generation => [key, nonce]`, bounded by
|
|
113
|
+
`out_of_order_tolerance:` (default 100, oldest dropped) and `max_forward_distance:` (default 1000,
|
|
114
|
+
`ProtocolError` beyond). `Group` keeps `PastEpoch` (secret tree and sender data secret only, plus the
|
|
115
|
+
GroupContext and tree for the signature check) for `max_past_epochs:` epochs (default 2). The
|
|
116
|
+
options go to `Group.create` / `.from_welcome` (and so `Client#create_group` / `#join_group`).
|
|
117
|
+
AEAD failures now raise `ProtocolError`.
|
|
118
|
+
|
|
119
|
+
## 7. External senders and external proposals (M) — RFC 12.1.8, 12.1.8.1, 6.1 — done
|
|
120
|
+
|
|
121
|
+
**RFC.** With an `external_senders` GroupContext extension, listed signers may send Add, Remove,
|
|
122
|
+
PreSharedKey, ReInit and GroupContextExtensions proposals as PublicMessages with
|
|
123
|
+
`sender_type = external` and `sender_index` into the extension. A joiner may also send its own Add as
|
|
124
|
+
`new_member_proposal`, signed with the KeyPackage's key. Other proposal types from these senders
|
|
125
|
+
MUST be rejected.
|
|
126
|
+
|
|
127
|
+
**Have.** `Struct::ExternalSender` and `Struct::Sender.create_external` parse and build. `Group#unprotect`
|
|
128
|
+
rejects non-member senders (`TODO` at group.rb:488), `resolve_proposals` rejects proposals by
|
|
129
|
+
reference from non-members.
|
|
130
|
+
|
|
131
|
+
**Build.** Decode the extension in `Group` (like `required_capabilities`); `sender_signature_key` for
|
|
132
|
+
`external` (by index) and `new_member_proposal` (the KeyPackage inside the Add); the content-type
|
|
133
|
+
and proposal-type restrictions of 6.1 and 12.1.8; PublicMessage only; `resolve_proposals` passes
|
|
134
|
+
`nil` as the sender leaf of such proposals, and `apply_proposals` must not treat an external Remove
|
|
135
|
+
as touching the sender. An `ExternalSender` API for the sending side (sign a proposal with no
|
|
136
|
+
group membership) is a small separate class.
|
|
137
|
+
|
|
138
|
+
**Test.** An external signer removes Bob; a non-member sends its own Add; an external Update is
|
|
139
|
+
rejected.
|
|
140
|
+
|
|
141
|
+
**Done as.** `Struct::ExternalSenders` (the extension data, with `.extension(list)`), `Group#external_senders`,
|
|
142
|
+
`#validate_non_member_content!` and `#sender_signature_key` for `external` and `new_member_proposal`;
|
|
143
|
+
`resolve_proposals` gives such proposals a `nil` sender. `Melos::ExternalSender` signs proposals with
|
|
144
|
+
no group state (`create_add_proposal`, `create_remove_proposal`, `create_psk_proposal`,
|
|
145
|
+
`create_group_context_extensions_proposal`); `Client#create_new_member_proposal` sends a client's own
|
|
146
|
+
Add. Authorization (12.1.8) is the `external_proposal_validator:` group option, accepting by default.
|
|
147
|
+
Tests in `test/test_external_senders.rb`.
|
|
148
|
+
|
|
149
|
+
## 8. Persistence of client and group state (M) — done
|
|
150
|
+
|
|
151
|
+
**RFC.** None, but 6.3.1 requires persistent ratchet state to avoid nonce reuse, so a client that
|
|
152
|
+
restarts without it is unsafe.
|
|
153
|
+
|
|
154
|
+
**Have.** All state lives in instance variables of `Client`, `Group`, `EpochSecrets`, `SecretTree`,
|
|
155
|
+
`PrivateTree`, `RatchetTree`; the public tree already round-trips through `raw`.
|
|
156
|
+
|
|
157
|
+
**Build.** `Group#to_h` / `Group.from_h` (and the same for `Client`) producing plain Hashes of binary
|
|
158
|
+
strings and integers, including the secret tree ratchet positions, pending proposals (as
|
|
159
|
+
`AuthenticatedContent.raw`), pending updates (4) and retained epochs (6). Serialization format is the
|
|
160
|
+
application's choice (Marshal, JSON with hex, MessagePack); provide the Hash and one JSON helper.
|
|
161
|
+
Encryption at rest is out of scope and should be stated.
|
|
162
|
+
|
|
163
|
+
**Test.** Save and restore both members between every step of the round-trip test; messages
|
|
164
|
+
encrypted before and after a restore decrypt.
|
|
165
|
+
|
|
166
|
+
**Done as.** `Group#to_h(include_external_psks:)` / `Group.from_h(hash, external_psks:, **hooks)` and
|
|
167
|
+
`Client#to_h` / `Client.from_h(hash, **hooks)`, built on `to_h` / `from_h` of `EpochSecrets`,
|
|
168
|
+
`SecretTree` and its `Ratchet`s, `KeyPackageBundle`, and `PrivateTree#to_a`. The Hashes have Symbol
|
|
169
|
+
keys and binary String values, plus a `format:` version. Data maps are arrays of pairs, so keys keep
|
|
170
|
+
their types. `Melos::Persistence` gives JSON with hex strings (`dump_client`, `load_client`,
|
|
171
|
+
`dump_group`, `load_group`); Marshal works on the Hash as it is. The procs (`credential_validator:`,
|
|
172
|
+
`external_proposal_validator:`) are passed again on load. A `StagedCommit` is not part of the state:
|
|
173
|
+
merge or discard it before saving. Tests in `test/test_persistence.rb`.
|
|
174
|
+
|
|
175
|
+
## 9. X.509 credentials (M, application-dependent) — RFC 5.3, 5.3.1, 13.3 — done
|
|
176
|
+
|
|
177
|
+
**RFC.** The AS validates credentials; for X.509 the end-entity certificate's public key MUST equal the
|
|
178
|
+
leaf's `signature_key`, and the chain is verified by the application's policy.
|
|
179
|
+
|
|
180
|
+
**Have.** `Struct::Credential` parses `certificates`; the default `credential_validator` accepts basic
|
|
181
|
+
credentials only.
|
|
182
|
+
|
|
183
|
+
**Build.** `Melos::Credential::X509` helper: parse `cert_data` with `OpenSSL::X509::Certificate`, check
|
|
184
|
+
the key matches `signature_key`, verify the chain against a caller-supplied store, check validity
|
|
185
|
+
dates; offered as an alternative validator the application opts into. Capabilities default gains
|
|
186
|
+
credential type 2 only when the validator is installed.
|
|
187
|
+
|
|
188
|
+
**Test.** A self-signed chain generated in the test; a certificate whose key differs from the leaf's
|
|
189
|
+
is rejected.
|
|
190
|
+
|
|
191
|
+
**Done as.** `Melos::Credential::X509.new(store:, time:, identity_check:, accept_basic:)` is a callable
|
|
192
|
+
for `credential_validator:`: end-entity key equals the holder's `signature_key`, the chain verifies with
|
|
193
|
+
`OpenSSL::X509::StoreContext` (validity dates included, at `time:` or now), the application's
|
|
194
|
+
`identity_check:` for reference identifiers and successor policy (5.3.1); `#last_error` says why a
|
|
195
|
+
check failed. `.create_credential(certificates)` builds the credential. `Client.new` takes
|
|
196
|
+
`credential:`, `signature_private_key:` and `credential_types:` (what its leaves' capabilities list;
|
|
197
|
+
basic plus its own by default, so a basic client must opt in to X.509 to join a group using it,
|
|
198
|
+
13.3). Also, 5.3.1: the credentials of an `external_senders` extension now go through the validator
|
|
199
|
+
when the extension is set, on creation, join and external join. Tests in `test/test_x509.rb`.
|
|
200
|
+
|
|
201
|
+
## 10. Resumption PSKs, ReInit and subgroup branching (M/L) — RFC 8.4, 11.2, 11.3, 12.1.5, 12.4.3.1 — done
|
|
202
|
+
|
|
203
|
+
**RFC.** ReInit: a proposal (alone in its commit) ends the group; the committer creates a new group
|
|
204
|
+
with the proposed version, suite, id and extensions, and welcomes everyone with a resumption PSK of
|
|
205
|
+
usage `reinit` for the old group's last epoch; joiners verify the new group's parameters against the
|
|
206
|
+
proposal and that membership is preserved. Branching: a member creates a subgroup of existing
|
|
207
|
+
members with a resumption PSK of usage `branch`; joiners verify suite, version, epoch 1 and that
|
|
208
|
+
every leaf matches one in the old group. Resumption PSKs of these usages are invalid anywhere else.
|
|
209
|
+
|
|
210
|
+
**Have.** `Struct::ReInit` parses; `resumption_psks` by epoch are kept; `psk_secret_for` handles
|
|
211
|
+
resumption PSKs by epoch but ignores `usage` and `psk_group_id` (`TODO` at group.rb:560);
|
|
212
|
+
`from_welcome` rejects resumption PSKs in a Welcome (`TODO` at group.rb:134); `apply_proposals`
|
|
213
|
+
rejects ReInit as unsupported.
|
|
214
|
+
|
|
215
|
+
**Build.** `Client` keeps the resumption PSKs of groups it left or that were reinitialized, keyed by
|
|
216
|
+
group id and epoch. `Group#create_reinit_proposal`, ReInit handling in `stage`/`merge_commit` (the
|
|
217
|
+
group becomes inactive with a `pending_reinit`), `Client#create_reinit_group(old_group)` which creates
|
|
218
|
+
the new group and the Welcome with the PSK, `Client#create_branch(old_group, members)`, and the
|
|
219
|
+
joiner-side checks of 11.2, 11.3 and 12.4.3.1 in `from_welcome`. Needs 3 (the branch commit has
|
|
220
|
+
only Adds and a PSK) and benefits from 2.
|
|
221
|
+
|
|
222
|
+
**Test.** Reinit a three-member group to another cipher suite; branch Alice and Carol out of
|
|
223
|
+
Alice, Bob and Carol; a `reinit` PSK in an ordinary commit is rejected.
|
|
224
|
+
|
|
225
|
+
**Done as.** `PreSharedKeyID.create_resumption`; `Group#create_resumption_psk_proposal` (usage
|
|
226
|
+
application, this group or another the client knows), `#create_reinit_proposal`; a merged ReInit
|
|
227
|
+
sets `pending_reinit` and makes the group inactive. `Client#reinit_group(old_group, key_packages)`
|
|
228
|
+
(on a client of the ReInit's suite) and `Client#branch_group(old_group, key_packages, group_id:)`
|
|
229
|
+
create the new group in epoch 0 and make its first commit, with the Adds and the reinit/branch PSK
|
|
230
|
+
(`Group#create_resumption_commit`, the only place such a PSK is accepted). `Group.from_welcome` takes
|
|
231
|
+
`resumption_psk_lookup:`, `resumed_group_lookup:` and `member_matcher:` (identical credentials by
|
|
232
|
+
default) and runs the 11.2, 11.3 and 12.4.3.1 checks; `Client#join_group` supplies them, with
|
|
233
|
+
`resumed_groups:` for old groups held by a client of another suite. A client archives the resumption
|
|
234
|
+
PSKs of a group it replaces; groups keep `max_resumption_psks:` epochs (default 32, 8.6). Branch
|
|
235
|
+
membership is checked against the old group's current tree. Tests in `test/test_resumption.rb`.
|
|
236
|
+
|
|
237
|
+
## 11. External commits (L) — RFC 12.4.3.2, 8.3, 12.1.6 — done
|
|
238
|
+
|
|
239
|
+
**RFC.** A member publishes a GroupInfo with an `external_pub` extension; a joiner builds a commit
|
|
240
|
+
with `sender_type = new_member_commit`, an ExternalInit proposal carrying the HPKE `kem_output`,
|
|
241
|
+
optionally a Remove of its old self, and a path from the leaf it takes; members derive the next
|
|
242
|
+
`init_secret` from the external secret, assign the joiner the leftmost blank leaf, and verify the
|
|
243
|
+
signature with the path leaf's key.
|
|
244
|
+
|
|
245
|
+
**Have.** `Struct::ExternalInit`, `Struct::ExternalPub`, `Struct::GroupInfo` parse and build;
|
|
246
|
+
`EpochSecrets#external_secret` is derived; `stage` rejects non-member committers and ExternalInit
|
|
247
|
+
(`TODO` at group.rb:409).
|
|
248
|
+
|
|
249
|
+
**Build.** `Group#group_info(external_pub: true)` deriving the external key pair from
|
|
250
|
+
`external_secret` (8.3); `Client#join_by_external_commit(group_info, ratchet_tree:)` producing the
|
|
251
|
+
commit and a new `Group`; in `stage`, the `new_member_commit` branch: leaf assignment, the external
|
|
252
|
+
init secret via `EpochSecrets#next` with an `init_secret:` override, the 12.2 external list rules,
|
|
253
|
+
signature from the path leaf. `validate_update_path!` must allow the joiner's leaf to be new.
|
|
254
|
+
Needs 2 and 3; shares the leaf-assignment code with Add.
|
|
255
|
+
|
|
256
|
+
**Test.** Carol joins Alice and Bob by external commit; a resync commit replaces an old Carol; an
|
|
257
|
+
external commit with a proposal by reference is rejected.
|
|
258
|
+
|
|
259
|
+
**Done as.** `Group#group_info(external_pub:, include_ratchet_tree:)` (the group now keeps the
|
|
260
|
+
epoch's confirmation tag, also persisted); `Crypto.external_key_pair`, `.external_init_sender`,
|
|
261
|
+
`.external_init_receiver` (8.3, checked against the key-schedule vectors' `external_pub`).
|
|
262
|
+
`Group.join_by_external_commit` builds a view of the epoch whose `EpochSecrets` holds only the
|
|
263
|
+
external init secret, so `stage` advances it like any other; `Client#join_by_external_commit(group_info,
|
|
264
|
+
remove:, psk_ids:)` merges and stores the new group. In `stage`, a `new_member_commit` sender gets the
|
|
265
|
+
12.4.3.2 checks, the 12.2 external list rules (`#validate_external_proposal_list!`), the leftmost
|
|
266
|
+
blank leaf (after a resync's Remove, which `#validate_resync!` limits to an earlier appearance by
|
|
267
|
+
`member_matcher:`), the external init secret, and `validate_update_path!(new_leaf: true)`. Tests in
|
|
268
|
+
`test/test_external_commits.rb`.
|
|
269
|
+
|
|
270
|
+
## 12. Interop testing (L) — done
|
|
271
|
+
|
|
272
|
+
**RFC.** None; the mls-implementations repository defines a gRPC interop harness
|
|
273
|
+
(`mls_client.proto`) that drives each implementation through a test runner.
|
|
274
|
+
|
|
275
|
+
**Have.** All test vectors pass, and the round-trip tests only pit melos against itself. The passive
|
|
276
|
+
vectors recorded from interop runs (`interop/passive`, in `test_vectors/interop-passive/`) pass too,
|
|
277
|
+
except 56 whose KeyPackages carry unlisted GREASE extensions, which melos rejects per RFC 10
|
|
278
|
+
(`test/test_passive_client_interop.rb`).
|
|
279
|
+
|
|
280
|
+
**Build.** A `melos-interop` executable implementing the gRPC `MLSClient` service with `grpc` and
|
|
281
|
+
`google-protobuf` gems (development dependencies only): state handles for groups, the
|
|
282
|
+
create/join/propose/commit/protect/unprotect operations mapped to `Client` and `Group`. Run the
|
|
283
|
+
upstream test runner against melos and at least one other implementation (OpenMLS has a ready
|
|
284
|
+
interop client). Expect this to surface issues that vectors cannot, particularly around 3, 6 and
|
|
285
|
+
7. Depends on nothing but gets more valuable after each item above lands; 7 and 11 are exercised by
|
|
286
|
+
the runner's scripts.
|
|
287
|
+
|
|
288
|
+
**Test.** The runner's own scripts; keep a record of which pass in this file.
|
|
289
|
+
|
|
290
|
+
**Done as.** `interop/melos_interop.rb` (the `MLSClient` service over `Client` and `Group`, all 34 RPCs)
|
|
291
|
+
and `bin/melos-interop`, with `grpc` / `grpc-tools` in the Gemfile's `interop` group and the generated
|
|
292
|
+
code in `interop/proto/`. `interop/build-test-runner.sh` builds the Go runner from a local
|
|
293
|
+
mls-implementations checkout with `interop/test-runner.patch` (two upstream bugs in assigning clients
|
|
294
|
+
to actors); `interop/run.rb` and `interop/summarize.rb` run and report. The record of what passes is
|
|
295
|
+
in [interop/README.md](../interop/README.md): every config but `deep_random` passes against melos
|
|
296
|
+
itself and against OpenMLS (5316/5316 mixed runs); against MLS++ the only failures are its KeyPackages
|
|
297
|
+
with unlisted GREASE extensions, which melos rejects. `test/test_interop_service.rb` covers the service
|
|
298
|
+
in `rake test`. Also from this: `CipherSuite.new` raises `UnsupportedError` for an unknown suite.
|
|
299
|
+
|
|
300
|
+
## Suggested sequence
|
|
301
|
+
|
|
302
|
+
~~2 → 1 → 3 → 4 → 5 → 6 → 7 → 8 → 10 → 11 → 9 → 12~~: all done.
|
data/docs/validation.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# RFC 9420 validation checklist
|
|
2
|
+
|
|
3
|
+
MUST-level requirements of RFC 9420 that apply to a client processing or producing messages,
|
|
4
|
+
mapped to the code; updated as validation lands (last: tier 5). Status:
|
|
5
|
+
|
|
6
|
+
- **done**: enforced today, with where.
|
|
7
|
+
- **partial**: enforced in some paths or weaker than the RFC asks.
|
|
8
|
+
- **missing**: not enforced.
|
|
9
|
+
- **n/a**: for features melos does not implement; none remain since external commits landed.
|
|
10
|
+
|
|
11
|
+
Items marked *(application)* are MUSTs the RFC places on the application or the Authentication
|
|
12
|
+
Service; melos should offer a hook or a documented default, not decide the policy.
|
|
13
|
+
|
|
14
|
+
## 1. Message framing and unprotect (Sections 6, 6.1, 6.2, 6.3)
|
|
15
|
+
|
|
16
|
+
| # | Requirement | RFC | Status | Code |
|
|
17
|
+
|---|---|---|---|---|
|
|
18
|
+
| 1.1 | Verify the signature with the key selected by sender_type | 6.1 | done | `Group#unprotect`, `#sender_signature_key`: member (leaf), external (external_senders entry), new_member_proposal (the Add's KeyPackage leaf), new_member_commit (the path's leaf) |
|
|
19
|
+
| 1.2 | external sender: content_type MUST be proposal, proposal_type MUST be one allowed for external senders | 6.1, 12.1.8 | done | `#validate_non_member_content!` with `EXTERNAL_PROPOSAL_TYPES` |
|
|
20
|
+
| 1.3 | new_member_commit: content_type MUST be commit; new_member_proposal: proposal of type add | 6.1 | done | `#validate_non_member_content!` |
|
|
21
|
+
| 1.4 | PublicMessage: check membership_tag for member senders | 6.2 | done | `PublicMessage#unprotect` returns nil, `Group#unprotect` raises |
|
|
22
|
+
| 1.5 | FramedContentAuthData valid: signature and, for commits, confirmation_tag | 6.1, 6.2, 6.3.1 | done | signature in `Group#unprotect`; tag in `Group#stage` |
|
|
23
|
+
| 1.6 | PrivateMessage padding MUST be all zero bytes; reject otherwise | 6.3.1 | done | `PrivateMessage#unprotect` via `PrivateMessageContent#padding_zero?` |
|
|
24
|
+
| 1.7 | SenderData.leaf_index MUST identify a non-blank leaf | 6.3.2 | partial | caught later by `#sender_signature_key` ("sender leaf is blank") after decryption; the RFC wants it checked when the sender data is parsed |
|
|
25
|
+
| 1.8 | Application data MUST be sent as PrivateMessage | 6 | done | `AuthenticatedContent#sign` raises on send; `#verify` returns false on receive |
|
|
26
|
+
| 1.9 | Proposal and Commit epoch MUST equal the current epoch | 12.1, 12.4.2 | done | `Group#unprotect` |
|
|
27
|
+
| 1.10 | Application messages from earlier epochs and out of order may be decrypted, within application-chosen bounds (9.1, 15.3); handshake messages stay current-epoch only | 9.1, 15.3 | done | `Group#unprotect` selects a `PastEpoch` (`max_past_epochs:`) for application PrivateMessages; `SecretTree::Ratchet` keeps skipped keys (`out_of_order_tolerance:`) and refuses jumps over `max_forward_distance:` |
|
|
28
|
+
| 1.11 | MLSMessage.version MUST be mls10 | 6 | done | `Group.check_message_version!` in `#unprotect`, `.from_welcome`, `#create_add_proposal` |
|
|
29
|
+
| 1.12 | AAD plus ciphertext MUST fit the AEAD limits | 6.3.1, 15.2 | missing *(application)* | no size accounting anywhere |
|
|
30
|
+
|
|
31
|
+
## 2. Proposals as received (Section 12.1)
|
|
32
|
+
|
|
33
|
+
| # | Requirement | RFC | Status | Code |
|
|
34
|
+
|---|---|---|---|---|
|
|
35
|
+
| 2.1 | Verify signature and epoch before caching | 12.1 | done | `Group#unprotect`, `#process_proposal` |
|
|
36
|
+
| 2.2 | Add: KeyPackage valid per 10.1 (see section 4) | 12.1.1 | done | `#apply_proposals` -> `#validate_key_package!` |
|
|
37
|
+
| 2.3 | Update: LeafNode valid for an Update per 7.3, source `update`, encryption_key differs from the replaced leaf | 12.1.2, 7.3 | done | `#apply_proposals` -> `#validate_leaf_node!(context: :update)`; sent by `#create_update_proposal` |
|
|
38
|
+
| 2.4 | Remove: `removed` MUST be a non-blank leaf | 12.1.3 | done | `#apply_proposals` (both sides), `#create_remove_proposal` |
|
|
39
|
+
| 2.5 | PreSharedKey: psk_nonce length MUST be KDF.Nh | 12.1.4 | done | `#psk_secret_for` |
|
|
40
|
+
| 2.6 | PreSharedKey: resumption with usage reinit or branch is invalid outside those operations | 12.1.4, 11.2, 11.3 | done | `#psk_secret_for` accepts them only in the initial commit of a resumed group (`#create_resumption_commit`), which no other member processes |
|
|
41
|
+
| 2.7 | ReInit: version MUST NOT be lower than the current one | 12.1.5 | done | `#validate_proposal_list!` |
|
|
42
|
+
| 2.8 | GroupContextExtensions: invalid if required_capabilities not supported by all members after the commit | 12.1.7, 11.1 | done | `#validate_members!` after the list is applied |
|
|
43
|
+
| 2.9 | External proposals MUST be PublicMessage; only add, remove, psk, reinit, gce from external senders; external_senders extension must be present; unauthorized external proposals are invalid | 12.1.8 | done | `#validate_non_member_content!`, `#sender_signature_key`; authorization is the `external_proposal_validator:` hook *(application)*, accepting by default |
|
|
44
|
+
| 2.10 | Unknown (non-default) proposal types MUST be supported by every member that processes the commit | 12.2, 13.2 | done | `#apply_proposals` rejects any type outside `KNOWN_PROPOSAL_TYPES` |
|
|
45
|
+
|
|
46
|
+
## 3. Proposal list validation (Section 12.2), on both creating and processing a Commit
|
|
47
|
+
|
|
48
|
+
`Group#validate_proposal_list!` runs in both `#create_commit` and `#stage`.
|
|
49
|
+
|
|
50
|
+
| # | Requirement | RFC | Status |
|
|
51
|
+
|---|---|---|---|
|
|
52
|
+
| 3.1 | Every individual proposal valid (sections 2 and 4) | 12.2 | done (sections 2, 4, 5) |
|
|
53
|
+
| 3.2 | No Update proposal by the committer | 12.2 | done |
|
|
54
|
+
| 3.3 | No Remove of the committer | 12.2 | done (`#stage`, `#create_commit`) |
|
|
55
|
+
| 3.4 | No two Update/Remove proposals for the same leaf | 12.2 | done |
|
|
56
|
+
| 3.5 | No two Adds for the same client (e.g. same signature key) | 12.2 | done (same signature key) |
|
|
57
|
+
| 3.6 | No Add of a client already in the group unless a Remove in the same list removes it | 12.2 | done (same signature key) |
|
|
58
|
+
| 3.7 | No two PreSharedKey proposals with the same PreSharedKeyID | 12.2 | done |
|
|
59
|
+
| 3.8 | At most one GroupContextExtensions proposal | 12.2 | done |
|
|
60
|
+
| 3.9 | ReInit MUST be alone in the list | 12.2 | done (`#create_commit` also leaves a pending ReInit out when other proposals are at hand, as 12.2 suggests) |
|
|
61
|
+
| 3.10 | No ExternalInit in a regular commit | 12.2 | done (`#apply_proposals` unless `external:`) |
|
|
62
|
+
| 3.11 | After applying, every leaf in the tree is valid per 7.3 | 12.2 | done: capabilities and key uniqueness of every remaining leaf (`#validate_members!`); signatures were verified when each leaf entered |
|
|
63
|
+
| 3.12 | Reject the Commit if the list is invalid | 12.2 | follows from the above |
|
|
64
|
+
| 3.13 | External commit list rules (exactly one ExternalInit, at most one Remove, PSKs only; a Remove only of an earlier appearance of the joiner) | 12.2 | done (`#validate_external_proposal_list!`, `#validate_resync!` with the `member_matcher:` hook *(application)*); also 12.4.3.2: a path, no references, signed by the path leaf, PublicMessage |
|
|
65
|
+
|
|
66
|
+
## 4. KeyPackage validation (Sections 10, 10.1), when adding and when processing an Add
|
|
67
|
+
|
|
68
|
+
| # | Requirement | RFC | Status | Code |
|
|
69
|
+
|---|---|---|---|---|
|
|
70
|
+
| 4.1 | cipher_suite and version match the GroupContext | 10.1 | done | `#apply_proposals` (Add) |
|
|
71
|
+
| 4.2 | leaf_node valid for a KeyPackage per 7.3 (section 5 below) | 10.1 | done | `#validate_key_package!` |
|
|
72
|
+
| 4.3 | Signature verifies with the leaf's signature key | 10, 10.1 | done | `#validate_key_package!` |
|
|
73
|
+
| 4.4 | leaf_node.encryption_key MUST differ from init_key | 10.1 | done | `#validate_key_package!` |
|
|
74
|
+
| 4.5 | leaf_node_source MUST be key_package | 10 | done | `#validate_leaf_node!(context: :key_package)` |
|
|
75
|
+
| 4.6 | Extensions in KeyPackage.extensions and leaf_node.extensions MUST be listed in leaf_node.capabilities | 10 | done | `#validate_key_package!`, `#validate_capabilities!` |
|
|
76
|
+
| 4.7 | KeyPackage.version MUST equal the enclosing MLSMessage.version | 10 | done | `Group#create_add_proposal` |
|
|
77
|
+
| 4.8 | Unknown capabilities values and unknown extensions MUST be ignored | 13.4 | done by construction | nothing inspects them yet; keep it that way when 4.6 is added |
|
|
78
|
+
| 4.9 | Sender: init_key MUST be unique among the client's KeyPackages | 10 | done | fresh random key per `KeyPackageBundle.generate` |
|
|
79
|
+
| 4.10 | Sender: capabilities MUST list every supported value and MUST NOT list default proposal/extension types | 7.2 | done | `Melos::Capabilities#set_default` lists no proposal or extension types |
|
|
80
|
+
|
|
81
|
+
## 5. LeafNode validation (Section 7.3), for Add, Update, the Commit path leaf, and every leaf when joining
|
|
82
|
+
|
|
83
|
+
Not checked on purpose: that a leaf's `capabilities.cipher_suites` lists the group's cipher suite. 7.3
|
|
84
|
+
asks only that a leaf be "compatible with the group's parameters", and other implementations leave the
|
|
85
|
+
suite out (every suite-7 vector in mls-implementations' `interop/passive` does). An added KeyPackage's
|
|
86
|
+
own `cipher_suite` must still match the group's (4.1).
|
|
87
|
+
|
|
88
|
+
| # | Requirement | RFC | Status | Code |
|
|
89
|
+
|---|---|---|---|---|
|
|
90
|
+
| 5.1 | Credential valid per 5.3.1 (Authentication Service), for leaves and external senders | 7.3, 5.3.1, 12.1.8.1 | done (hook) | `credential_validator:` option; default accepts basic credentials only; `Melos::Credential::X509` checks X.509 chains and the key match of 5.3; `#validate_external_senders!` |
|
|
91
|
+
| 5.2 | Signature valid with signature_key (with group_id and leaf_index for update/commit sources) | 7.3 | done | `#validate_leaf_node!` |
|
|
92
|
+
| 5.3 | If GroupContext has required_capabilities, its extensions, proposals and credential types MUST be in the leaf's capabilities | 7.3, 11.1, 13.4 | done | `#validate_capabilities!` |
|
|
93
|
+
| 5.4 | Credential type supported by all members; leaf supports every credential type in use | 7.3, 13.3 | done | `#validate_leaf_node!`, `#validate_members!` |
|
|
94
|
+
| 5.5 | Lifetime: sender MUST check current time is within lifetime when sending a leaf (Add of a KeyPackage); receiver RECOMMENDED | 7.3 | done | `#validate_leaf_node!(sending: true)` from `#create_add_proposal` and `#create_commit` |
|
|
95
|
+
| 5.6 | Application MUST define a maximum total lifetime and reject longer ones | 7.2 | done (option) | `max_leaf_node_lifetime:`; no default limit because the interop vectors use the full uint64 range |
|
|
96
|
+
| 5.7 | Every non-default extension in the leaf MUST be listed in capabilities.extensions; credential type MUST be in capabilities.credentials | 7.2, 7.3 | done | `#validate_capabilities!` |
|
|
97
|
+
| 5.8 | leaf_node_source matches the context: key_package / update (and new encryption_key) / commit | 7.3 | done | `#validate_leaf_node!` |
|
|
98
|
+
| 5.9 | signature_key and encryption_key unique among members | 7.3, 16.7 | done | `#validate_leaf_node!`, `#validate_members!`, `#validate_tree!` |
|
|
99
|
+
| 5.10 | Each GroupContext extension (non-default) MUST be supported by a new member's capabilities | 13.4 | done | `#validate_capabilities!` |
|
|
100
|
+
|
|
101
|
+
## 6. Commit processing (Sections 12.4, 12.4.2, 7.5, 7.6, 7.9.2)
|
|
102
|
+
|
|
103
|
+
| # | Requirement | RFC | Status | Code |
|
|
104
|
+
|---|---|---|---|---|
|
|
105
|
+
| 6.1 | Epoch, membership tag or decryption, signature | 12.4.2 | done | `Group#unprotect` |
|
|
106
|
+
| 6.2 | Proposal list valid (section 3) | 12.4.2 | done | `#validate_proposal_list!` in `#stage` and `#create_commit` |
|
|
107
|
+
| 6.3 | All PreSharedKey proposals available | 12.4.2 | done | `#psk_secret_for` raises |
|
|
108
|
+
| 6.4 | Path MUST be present if the list is empty or has a path-required type | 12.4 | done | `Group#stage` |
|
|
109
|
+
| 6.5 | Path leaf valid per 7.3 with leaf_node_source commit | 12.4.2 | done | `#validate_update_path!` -> `#validate_leaf_node!(context: :commit)` |
|
|
110
|
+
| 6.6 | Path leaf encryption_key MUST differ from the committer's current leaf | 12.4.2 | done | `#validate_update_path!` |
|
|
111
|
+
| 6.7 | None of the UpdatePath public keys appear in any node of the new tree | 12.4.2 | done | `#validate_update_path!` |
|
|
112
|
+
| 6.8 | Recompute the committer's leaf parent_hash and verify it matches the supplied leaf | 7.9.2 | done | `#validate_update_path!` via `RatchetTree#verify_parent_hash_of_path` |
|
|
113
|
+
| 6.9 | Each UpdatePathNode's encrypted_path_secret length MUST equal the copath resolution excluding new leaves | 7.6 | done | `#validate_update_path!` checks every node |
|
|
114
|
+
| 6.10 | Confirmation tag verifies against the new epoch | 12.4.2 | done | `Group#stage` |
|
|
115
|
+
| 6.11 | A Commit that removes us: no further sending, delete state (SHOULD) | 12.4.2 | done | `#stage` returns `removes_us`, `#merge_commit` makes the group inactive; last epoch's secrets are kept for late messages |
|
|
116
|
+
| 6.12 | After a ReInit commit the group MUST NOT be used; wait for the Welcome | 12.4.2 | done | `#merge_commit` makes the group inactive with `pending_reinit`; `Client#reinit_group` creates the successor |
|
|
117
|
+
| 6.13 | A member that observed proposals MUST commit before sending application data | 12.4 | done | `#create_application_message` |
|
|
118
|
+
| 6.14 | Generating a Commit MUST NOT modify state; Welcome MUST NOT be delivered until the Commit is accepted | 14 | done / *(application)* | `#create_commit` returns a `StagedCommit`; delivery is the caller's |
|
|
119
|
+
| 6.15 | After processing a path, outdated key material MUST be deleted | 7.5, 9.2 | done | `EpochSecrets#discard_consumed!`, `PrivateTree#prune!` in `#merge_commit`; retained past epochs keep only their secret tree and sender data secret. Ruby cannot zeroize strings |
|
|
120
|
+
|
|
121
|
+
## 7. Joining via Welcome (Sections 12.4.3, 12.4.3.1, 12.4.3.3, 13.4)
|
|
122
|
+
|
|
123
|
+
| # | Requirement | RFC | Status | Code |
|
|
124
|
+
|---|---|---|---|---|
|
|
125
|
+
| 7.1 | Find the entry for one of our KeyPackages; error if none or if cipher suites differ | 12.4.3.1 | done | `Client#join_group` finds the entry; `Group.from_welcome` compares the KeyPackage's cipher_suite with the Welcome's |
|
|
126
|
+
| 7.2 | Error if a PSK in GroupSecrets is unknown | 12.4.3.1 | done | `Group.from_welcome` |
|
|
127
|
+
| 7.3 | A resumption PSK with usage reinit or branch MUST be the only such PSK; GroupInfo epoch MUST be 1; reinit/branch consistency checks | 12.4.3.1, 11.2, 11.3 | done | `Group.from_welcome`, `#validate_resumption!`; "same member" is the `member_matcher:` hook *(application)*, identical credentials by default; branch membership is checked against the old group's current tree |
|
|
128
|
+
| 7.4 | GroupInfo signature with the signer leaf's key; error if blank or invalid | 12.4.3 | done | `Group.from_welcome` |
|
|
129
|
+
| 7.5 | group_id MUST be unique among the groups the client is in | 12.4.3 | done | `Client#ensure_group_id_free!` on create and join |
|
|
130
|
+
| 7.6 | GroupInfo cipher_suite matches the KeyPackage's | 12.4.3.1 | done | see 7.1 |
|
|
131
|
+
| 7.7 | Tree hash matches GroupContext.tree_hash | 12.4.3.1, 12.4.3.3 | done | `Group.from_welcome` |
|
|
132
|
+
| 7.8 | Every non-blank parent node is parent-hash valid | 12.4.3.1, 7.9.2 | done | `#validate_tree!` via `RatchetTree#parent_hash_valid?` |
|
|
133
|
+
| 7.9 | Every non-blank leaf valid per 7.3 | 12.4.3.1 | done | `#validate_tree!` -> `#validate_leaf_node!(context: :tree)` |
|
|
134
|
+
| 7.10 | unmerged_leaves: each entry is a non-blank descendant leaf; every non-blank node between also lists it; parent encryption keys unique in the tree | 12.4.3.1 | done | `#validate_tree!` |
|
|
135
|
+
| 7.11 | Our leaf is the one identical to the KeyPackage's LeafNode | 12.4.3.1 | done | `Group.from_welcome` matches the whole LeafNode |
|
|
136
|
+
| 7.12 | Derived private keys MUST correspond to the public keys in the nodes | 12.4.3.1 | done | `#validate_joined_state!` via `PrivateTree#consistent?` |
|
|
137
|
+
| 7.13 | Confirmation tag verifies with the derived confirmation key | 12.4.3.1 | done | `Group.from_welcome` |
|
|
138
|
+
| 7.14 | Joiner MUST support every GroupContext extension, else the GroupInfo is invalid | 13.4 | done | our own leaf through `#validate_tree!`; a non-default extension we do not list is rejected |
|
|
139
|
+
| 7.15 | Unknown GroupInfo.extensions MUST be ignored | 12.4.3, 13.4 | done | only ratchet_tree is looked up |
|
|
140
|
+
| 7.16 | ratchet_tree extension: last node non-blank, pad to 2^(d+1)-1 | 12.4.3.3 | done | `RatchetTree.parse`, `#initialize` |
|
|
141
|
+
| 7.17 | Download the tree before processing if not in the Welcome | 12.4.3.1 | done | `ratchet_tree:` argument; error if neither |
|
|
142
|
+
|
|
143
|
+
## 8. Sending side
|
|
144
|
+
|
|
145
|
+
| # | Requirement | RFC | Status | Code |
|
|
146
|
+
|---|---|---|---|---|
|
|
147
|
+
| 8.1 | Fresh random 4-byte reuse guard, included in SenderData | 6.3.1 | done | `PrivateMessage.protect` |
|
|
148
|
+
| 8.2 | psk_nonce fresh random of length KDF.Nh | 8.4, 12.1.4 | done | `Group#create_psk_proposal` |
|
|
149
|
+
| 8.3 | Proposal list valid when creating a commit | 12.2, 12.4.1 | done | `#validate_proposal_list!` |
|
|
150
|
+
| 8.4 | Welcome MUST cover every new member; psks in proposal order | 12.4.1 | done | `#create_welcome` |
|
|
151
|
+
| 8.5 | Creator MUST pick the best version/cipher suite supported by all added members | 11 | partial | one suite per group; 4.1 covers the check that an added KeyPackage matches it |
|
|
152
|
+
| 8.6 | Adding a member: its capabilities MUST cover each GroupContext extension and required_capabilities | 13.4, 11.1 | done | `#validate_key_package!` on `#create_add_proposal` |
|
|
153
|
+
| 8.7 | Lifetime of a KeyPackage leaf checked against the current time when sending an Add | 7.3 | done | see 5.5 |
|
|
154
|
+
| 8.8 | Capabilities content (see 4.10) | 7.2 | done | `Melos::Capabilities` |
|
|
155
|
+
|
|
156
|
+
## 9. Wire format
|
|
157
|
+
|
|
158
|
+
| # | Requirement | RFC | Status | Code |
|
|
159
|
+
|---|---|---|---|---|
|
|
160
|
+
| 9.1 | Variable-length vector headers MUST use the minimum length; prefix 3 is invalid | 2.1.2 | done | `Melos::Vec.parse_stream`; truncated input raises `ArgumentError` too |
|
|
161
|
+
| 9.2 | Any list of extensions MUST NOT contain two of the same type | 13.4 | done | `Extension.check_unique_types!` on join, creation, GroupContextExtensions proposals and Adds; the commit path leaf is covered by tier 3 |
|
|
162
|
+
| 9.3 | version fields (MLSMessage, KeyPackage, GroupContext) are mls10 | 6, 8.1, 10 | done | `Group` entry points, see 1.11, 4.1, 4.7 |
|
|
163
|
+
| 9.4 | Node hash input optional present iff node non-blank | 7.8 | done by construction | `RatchetTree#tree_hash` |
|
|
164
|
+
|
|
165
|
+
## Suggested order
|
|
166
|
+
|
|
167
|
+
1. ~~**Cheap and self-contained**: 1.6 padding, 1.11/9.3 version fields, 9.2 duplicate extensions, 2.4 blank Remove, 2.5 nonce length, 2.10 unknown proposal types, 4.10 Capabilities bug, 6.13 commit-before-send, 6.11 detect our own removal.~~ Done in aee3c38, plus 3.3, 4.1, 4.7 and the 9.1 vector checks.
|
|
168
|
+
2. ~~**Commit integrity**: 6.5 to 6.9 (path leaf validation, key uniqueness, parent hash check, per-node ciphertext counts), then the proposal list rules 3.2 to 3.8 and 3.11, shared by `create_commit` and `stage`.~~ Done.
|
|
169
|
+
3. ~~**KeyPackage and LeafNode validation**: sections 4 and 5 as one `LeafNode` validator parameterized by context (key_package / update / commit / tree), used by Add processing, commit path processing and join; includes signature, source, extension and capability checks, key uniqueness. Credential validation and maximum lifetime become hooks with defaults.~~ Done.
|
|
170
|
+
4. ~~**Join integrity**: 7.8 to 7.12 and 7.14 on top of the validator from step 3.~~ Done.
|
|
171
|
+
5. ~~**Client-level**: 7.5 group_id uniqueness, 7.1 KeyPackage suite check.~~ Done.
|
|
172
|
+
6. **Later, with the features they belong to**: ~~external senders (1.2, 2.9)~~, ~~resumption PSK rules (2.6, 7.3), ReInit, external commits~~, ~~old-epoch application messages (1.10), deletion schedule (6.15)~~.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class Melos::Capabilities
|
|
2
|
+
attr_accessor :versions, :cipher_suites, :extensions, :proposals, :credentials
|
|
3
|
+
|
|
4
|
+
# credentials: the credential types this client can validate in other members' leaves (13.3); a client
|
|
5
|
+
# that accepts X.509 credentials (Melos::Credential::X509) lists 2 as well as 1
|
|
6
|
+
def initialize(credentials: [Melos::Constants::CredentialType::BASIC])
|
|
7
|
+
set_default
|
|
8
|
+
@credentials = credentials
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def set_default
|
|
12
|
+
@versions = [1]
|
|
13
|
+
@cipher_suites = [1, 2, 3, 4, 5, 6, 7]
|
|
14
|
+
@extensions = [] # 7.2: likewise the default extension types
|
|
15
|
+
@proposals = [] # 7.2: the default proposal types (add .. group_context_extensions) MUST NOT be listed
|
|
16
|
+
@credentials = [1]
|
|
17
|
+
end
|
|
18
|
+
end
|