|
|
@@ -0,0 +1,129 @@ |
|
|
|
Nachrichtaufbau: |
|
|
|
================ |
|
|
|
|
|
|
|
u32 src_id // inserted by server |
|
|
|
u32 dest_id // 0: to all |
|
|
|
u16 size // min: 4 |
|
|
|
u8 payload[size] |
|
|
|
|
|
|
|
payload[0]: type |
|
|
|
KEY_LENGTH=32 |
|
|
|
|
|
|
|
Payloads: |
|
|
|
========= |
|
|
|
|
|
|
|
0-31 system messages (plaintext) |
|
|
|
|
|
|
|
0 reserved |
|
|
|
1 PING |
|
|
|
size: 4 |
|
|
|
u8 type, pad1, pad2, pad3; |
|
|
|
2 PONG |
|
|
|
size: 4 |
|
|
|
u8 type, pad1, pad2, pad3; |
|
|
|
3 ERROR |
|
|
|
size: 4+len |
|
|
|
u8 type, severity; |
|
|
|
u16 code; |
|
|
|
u8 msg[len]; |
|
|
|
|
|
|
|
32-63 server side messages (currently plaintext) |
|
|
|
|
|
|
|
32 INIT // first msg from server to new connection |
|
|
|
size: 4 + 4*count |
|
|
|
u8 type, pad1; |
|
|
|
u16 count; // including own; own id is in dest_id |
|
|
|
u32 ids[count]; |
|
|
|
33 JOIN // sent by server; joining id is src_id |
|
|
|
size: 4 |
|
|
|
u8 type, pad1, pad2, pad3; |
|
|
|
34 EXIT // sent by server; exiting id is src_id |
|
|
|
size: 4 |
|
|
|
u8 type, pad1, pad2, pad3; |
|
|
|
|
|
|
|
64-95 initial setup messages (plaintext) |
|
|
|
|
|
|
|
64 DH_SETUP // setup secure channel client->client |
|
|
|
size: 4 + ? |
|
|
|
u8 type, cryptotype, pad2, pad3; |
|
|
|
remainder impl-dependend |
|
|
|
65 DH_RETURN |
|
|
|
size: 4 + ? |
|
|
|
u8 type, cryptotype, pad2, pad3; |
|
|
|
remainder impl-dependend |
|
|
|
|
|
|
|
96-127 client-client setup messages (DH or old KEY encrypted) |
|
|
|
|
|
|
|
96 AUTHORIZE |
|
|
|
T.B.D. |
|
|
|
97 KEY_CURRENT |
|
|
|
size: 4 + KEY_LENGTH |
|
|
|
u8 type, pad1, pad2, pad3; |
|
|
|
u8 key[KEY_LENGTH]; |
|
|
|
98 KEY_NEW |
|
|
|
size: 4 + KEY_LENGTH |
|
|
|
u8 type, pad1, pad2, pad3; |
|
|
|
u8 key[KEY_LENGTH]; |
|
|
|
|
|
|
|
128-159 main messages (shared KEY encrypted) |
|
|
|
|
|
|
|
128 MSG |
|
|
|
size: 4 + ? |
|
|
|
u8 type, pad1; |
|
|
|
u16 generation; // which key generation is used. Increasing monotonously, until overflow |
|
|
|
u8 msg[]; |
|
|
|
|
|
|
|
160-255 reserved |
|
|
|
|
|
|
|
|
|
|
|
Funktionalität: |
|
|
|
=============== |
|
|
|
|
|
|
|
- Server: Pakete an alle weiterleiten (dest_id==0) bzw. an nur einen Client (dest_id) |
|
|
|
Bei Verbindungsaufbau: Liste aller Clients (Nummern) und eigene Nr (Zufallszahl), JOIN an alle |
|
|
|
Bei Verbindungsverlust: EXIT an alle |
|
|
|
|
|
|
|
- Client: Eigentliche Funktionalität |
|
|
|
|
|
|
|
|
|
|
|
Funktionsweise: |
|
|
|
|
|
|
|
Client: Neue Verbindung |
|
|
|
- warten auf INIT |
|
|
|
Liste der Clients merken |
|
|
|
- Jetzt nur Kommunikation mit zufälligem Client |
|
|
|
- -> DH_SETUP |
|
|
|
<- DH_RETURN -> client-client DH_KEY |
|
|
|
<- KEY_CURRENT (mit DH_KEY verschlüsselt) |
|
|
|
-> KEY_NEW an alle (mit KEY_CURRENT verschlüsselt) |
|
|
|
- Wenn an irgendeiner Stelle Timeout -> nochmal von vorne mit neuem Client |
|
|
|
|
|
|
|
Nachrichten: |
|
|
|
- JOIN |
|
|
|
Liste der Clients updaten |
|
|
|
- EXIT |
|
|
|
Liste der Clients updaten |
|
|
|
- DH_SETUP |
|
|
|
siehe oben -> DH_RETURN, KEY_CURRENT |
|
|
|
- KEY_NEW |
|
|
|
Alter KEY xor KEY_NEW -> neuer KEY, generation++ |
|
|
|
- MSG |
|
|
|
generation prüfen, wenn > aktueller, warten auf KEY_NEW etc. (Zwischenspeichern, TODO) |
|
|
|
entschlüsseln, MAC prüfen, anzeigen |
|
|
|
- ERROR |
|
|
|
code + msg ausgeben, |
|
|
|
severity >= 64 Key neu aushandeln (TODO), |
|
|
|
>= 96 Verbindung neu aufbauen (TODO), |
|
|
|
>= 128 Exit |
|
|
|
|
|
|
|
Nachricht schicken: |
|
|
|
MSG erstellen, Plaintext mit KEY verschlüsseln + MAC, generation einfügen |
|
|
|
|
|
|
|
|
|
|
|
Was fehlt / mögliche Fehler und Sicherheitsprobleme: |
|
|
|
==================================================== |
|
|
|
|
|
|
|
- Keine Authentisierung - jeder kann reingrätschen |
|
|
|
- server side messages derzeit plaintext |
|
|
|
- keine Validierung (Zertifikate) |
|
|
|
- ... |