diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json new file mode 100644 index 000000000..f8b488856 --- /dev/null +++ b/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": null +} \ No newline at end of file diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 000000000..d66744c6a --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,7 @@ +{ + "ExpandedNodes": [ + "" + ], + "SelectedNode": "\\C:\\Users\\offic\\source\\repos\\R0oTy\\wireguard-go", + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 000000000..fab9b1ac6 Binary files /dev/null and b/.vs/slnx.sqlite differ diff --git a/device/noise-protocol.go b/device/noise-protocol.go index 5cf1702b6..36656b7d8 100644 --- a/device/noise-protocol.go +++ b/device/noise-protocol.go @@ -117,14 +117,15 @@ type MessageCookieReply struct { } var errMessageLengthMismatch = errors.New("message length mismatch") +const xorKey uint32 = 0xBEEFDEAD func (msg *MessageInitiation) unmarshal(b []byte) error { if len(b) != MessageInitiationSize { return errMessageLengthMismatch } - msg.Type = binary.LittleEndian.Uint32(b) - msg.Sender = binary.LittleEndian.Uint32(b[4:]) + msg.Type = binary.LittleEndian.Uint32(b) ^ xorKey + msg.Sender = binary.LittleEndian.Uint32(b[4:]) ^ xorKey copy(msg.Ephemeral[:], b[8:]) copy(msg.Static[:], b[8+len(msg.Ephemeral):]) copy(msg.Timestamp[:], b[8+len(msg.Ephemeral)+len(msg.Static):]) @@ -139,8 +140,8 @@ func (msg *MessageInitiation) marshal(b []byte) error { return errMessageLengthMismatch } - binary.LittleEndian.PutUint32(b, msg.Type) - binary.LittleEndian.PutUint32(b[4:], msg.Sender) + binary.LittleEndian.PutUint32(b, msg.Type ^ xorKey) + binary.LittleEndian.PutUint32(b[4:], msg.Sender ^ xorKey) copy(b[8:], msg.Ephemeral[:]) copy(b[8+len(msg.Ephemeral):], msg.Static[:]) copy(b[8+len(msg.Ephemeral)+len(msg.Static):], msg.Timestamp[:])