Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
7 changes: 7 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ExpandedNodes": [
""
],
"SelectedNode": "\\C:\\Users\\offic\\source\\repos\\R0oTy\\wireguard-go",
"PreviewInSolutionExplorer": false
}
Binary file added .vs/slnx.sqlite
Binary file not shown.
9 changes: 5 additions & 4 deletions device/noise-protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -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):])
Expand All @@ -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[:])
Expand Down