73 lines
2.3 KiB
Text
73 lines
2.3 KiB
Text
|
the Elixir version uses an ASN.1 based format, but the support in other
|
||
|
languages (besides C) for ASN.1 is surprisingly bad.
|
||
|
So I'll resort to a hard-coded format. Again.
|
||
|
|
||
|
----
|
||
|
|
||
|
InitMessage ::=
|
||
|
capabilities:ShortList<u32(big-endian)>
|
||
|
|
||
|
(* the InitMessage is the first thing sent on a newly established connection.
|
||
|
* both sides are expected to send the capabilities they support
|
||
|
* then wait for the other side to send theirs (meaning they don't
|
||
|
* block each other during this), and then use just the capabilities
|
||
|
* which both peers support *)
|
||
|
|
||
|
ProtoMessage ::=
|
||
|
algorithm:SigAlgo
|
||
|
pubkeylen:u16(big-endian)
|
||
|
length:u16(big-endian)
|
||
|
data:[length]u8=ProtoMsgKind<pubkeylen>
|
||
|
|
||
|
ProtoMsgKind<pubkeylen> ::=
|
||
|
(* xfer *) [0x00] XferSlice<pubkeylen>
|
||
|
| (* summary-pull *) [0x01] SummaryList<pubkeylen>
|
||
|
| (* summary-ihave *) [0x02] SummaryList<pubkeylen>
|
||
|
|
||
|
(* after the initial capabilities are sent, both sides are expected to send
|
||
|
* summaries for all public keys they know + all available slices for these
|
||
|
* pubkeys *)
|
||
|
|
||
|
ShortList<T> ::= length:u16(big-endian) data:[length]T
|
||
|
XSList<T> ::= length:u8 data:[length]T
|
||
|
|
||
|
(* "raw" summary header overhead = 41 bytes, per 65535 slices *)
|
||
|
SummaryList<pubkeylen> ::=
|
||
|
data:[*]Slice<pubkeylen> (* uses all remaining space in the packet *)
|
||
|
|
||
|
Slice<pubkeylen> ::=
|
||
|
pubkey:[pubkeylen]u8
|
||
|
start:u64
|
||
|
length:u16
|
||
|
|
||
|
XferSlice<pubkeylen> ::=
|
||
|
pubkey:[pubkeylen]u8
|
||
|
siglen:u16(big-endian)
|
||
|
start:u64
|
||
|
data:[*]XferBlob<siglen> (* uses all remaining space in the packet *)
|
||
|
|
||
|
XferBlob<siglen> ::=
|
||
|
signature:[siglen]u8 (* signature gets calculated over `blid ++ data` *)
|
||
|
ttl:u8
|
||
|
data:XferInner
|
||
|
|
||
|
XferInner ::=
|
||
|
(* normal *) [0x00] XferNormal
|
||
|
| (* prune *) [0x01] (* empty; NOTE: this packet indicates that
|
||
|
* all packets before it should be deleted on all servers;
|
||
|
* used for data protection/privacy compliance;
|
||
|
* although it is possible to delete such packets after a grace period
|
||
|
* (e.g. 1 year) during which every peer should've had a chance to retrieve
|
||
|
* it, doing that is discouraged *)
|
||
|
|
||
|
XferNormal ::=
|
||
|
attrs:ShortList<KeyValuePair>
|
||
|
data:ShortList<u8>
|
||
|
|
||
|
KeyValuePair ::=
|
||
|
key:XSList<u8>
|
||
|
value:ShortList<u8>
|
||
|
|
||
|
SigAlgo ::=
|
||
|
(* ed25519 *) [0x65, 0x64, 0xff, 0x13]
|