@@ -14,7 +14,6 @@ import (
1414
1515 "golang.org/x/crypto/blake2s"
1616 "golang.org/x/crypto/chacha20poly1305"
17- "golang.org/x/crypto/poly1305"
1817
1918 "golang.zx2c4.com/wireguard/tai64n"
2019)
@@ -61,13 +60,13 @@ const (
6160)
6261
6362const (
64- MessageInitiationSize = 148 // size of handshake initiation message
65- MessageResponseSize = 92 // size of response message
66- MessageCookieReplySize = 64 // size of cookie reply message
67- MessageTransportHeaderSize = 16 // size of data preceding content in transport message
68- MessageTransportSize = MessageTransportHeaderSize + poly1305 . TagSize // size of empty transport
69- MessageKeepaliveSize = MessageTransportSize // size of keepalive
70- MessageHandshakeSize = MessageInitiationSize // size of largest handshake related message
63+ MessageInitiationSize = 148 // size of handshake initiation message
64+ MessageResponseSize = 92 // size of response message
65+ MessageCookieReplySize = 64 // size of cookie reply message
66+ MessageTransportHeaderSize = 16 // size of data preceding content in transport message
67+ MessageTransportSize = MessageTransportHeaderSize + chacha20poly1305 . Overhead // size of empty transport
68+ MessageKeepaliveSize = MessageTransportSize // size of keepalive
69+ MessageHandshakeSize = MessageInitiationSize // size of largest handshake related message
7170)
7271
7372const (
@@ -86,8 +85,8 @@ type MessageInitiation struct {
8685 Type uint32
8786 Sender uint32
8887 Ephemeral NoisePublicKey
89- Static [NoisePublicKeySize + poly1305 . TagSize ]byte
90- Timestamp [tai64n .TimestampSize + poly1305 . TagSize ]byte
88+ Static [NoisePublicKeySize + chacha20poly1305 . Overhead ]byte
89+ Timestamp [tai64n .TimestampSize + chacha20poly1305 . Overhead ]byte
9190 MAC1 [blake2s .Size128 ]byte
9291 MAC2 [blake2s .Size128 ]byte
9392}
@@ -97,7 +96,7 @@ type MessageResponse struct {
9796 Sender uint32
9897 Receiver uint32
9998 Ephemeral NoisePublicKey
100- Empty [poly1305 . TagSize ]byte
99+ Empty [chacha20poly1305 . Overhead ]byte
101100 MAC1 [blake2s .Size128 ]byte
102101 MAC2 [blake2s .Size128 ]byte
103102}
@@ -113,7 +112,7 @@ type MessageCookieReply struct {
113112 Type uint32
114113 Receiver uint32
115114 Nonce [chacha20poly1305 .NonceSizeX ]byte
116- Cookie [blake2s .Size128 + poly1305 . TagSize ]byte
115+ Cookie [blake2s .Size128 + chacha20poly1305 . Overhead ]byte
117116}
118117
119118var errMessageLengthMismatch = errors .New ("message length mismatch" )
0 commit comments