]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
Don't use modules
authorJason A. Donenfeld <Jason@zx2c4.com>
Mon, 12 Feb 2018 19:10:44 +0000 (20:10 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Mon, 12 Feb 2018 19:13:03 +0000 (20:13 +0100)
Feel free to revert this if you have a strong feeling about it. But so
far as I can see, it adds a lot of complexity for basically no upsides.

cookie.go
device.go
noise-protocol.go
ratelimiter.go [moved from internal/ratelimiter/ratelimiter.go with 99% similarity]
ratelimiter_test.go [moved from internal/ratelimiter/ratelimiter_test.go with 99% similarity]
tai64n.go [moved from internal/tai64n/tai64n.go with 91% similarity]
tai64n_test.go [moved from internal/tai64n/tai64n_test.go with 84% similarity]
xchacha20.go [moved from internal/xchacha20poly1305/xchacha20.go with 98% similarity]
xchacha20_test.go [moved from internal/xchacha20poly1305/xchacha20_test.go with 96% similarity]

index 72455a46f05cdf5d4343cec787a553aa7f2c339d..95729019d556342edde90ac219ecf40e9de081e1 100644 (file)
--- a/cookie.go
+++ b/cookie.go
@@ -3,7 +3,6 @@ package main
 import (
        "crypto/hmac"
        "crypto/rand"
-       "git.zx2c4.com/wireguard-go/internal/xchacha20poly1305"
        "golang.org/x/crypto/blake2s"
        "golang.org/x/crypto/chacha20poly1305"
        "sync"
@@ -158,7 +157,7 @@ func (st *CookieChecker) CreateReply(
                return nil, err
        }
 
-       xchacha20poly1305.Encrypt(
+       XChaCha20Poly1305Encrypt(
                reply.Cookie[:0],
                &reply.Nonce,
                cookie[:],
@@ -202,7 +201,7 @@ func (st *CookieGenerator) ConsumeReply(msg *MessageCookieReply) bool {
 
        var cookie [blake2s.Size128]byte
 
-       _, err := xchacha20poly1305.Decrypt(
+       _, err := XChaCha20Poly1305Decrypt(
                cookie[:0],
                &msg.Nonce,
                msg.Cookie[:],
index 9f93f2144b8e19a4e64d8080fd436bd02ed1ccf2..632494889760ab3d4b520c2c6d8789fd0df8df71 100644 (file)
--- a/device.go
+++ b/device.go
@@ -1,7 +1,6 @@
 package main
 
 import (
-       "git.zx2c4.com/wireguard-go/internal/ratelimiter"
        "runtime"
        "sync"
        "sync/atomic"
@@ -51,7 +50,7 @@ type Device struct {
 
        rate struct {
                underLoadUntil atomic.Value
-               limiter        ratelimiter.Ratelimiter
+               limiter        Ratelimiter
        }
 
        pool struct {
index df08a0ab46213f1abf180c35d66affa1e1277a2f..31ae55b16a1e0a5391b0c25a1bd5273cb45e3f19 100644 (file)
@@ -2,7 +2,6 @@ package main
 
 import (
        "errors"
-       "git.zx2c4.com/wireguard-go/internal/tai64n"
        "golang.org/x/crypto/blake2s"
        "golang.org/x/crypto/chacha20poly1305"
        "golang.org/x/crypto/poly1305"
@@ -59,7 +58,7 @@ type MessageInitiation struct {
        Sender    uint32
        Ephemeral NoisePublicKey
        Static    [NoisePublicKeySize + poly1305.TagSize]byte
-       Timestamp [tai64n.TimestampSize + poly1305.TagSize]byte
+       Timestamp [TimestampSize + poly1305.TagSize]byte
        MAC1      [blake2s.Size128]byte
        MAC2      [blake2s.Size128]byte
 }
@@ -100,7 +99,7 @@ type Handshake struct {
        remoteStatic              NoisePublicKey           // long term key
        remoteEphemeral           NoisePublicKey           // ephemeral public key
        precomputedStaticStatic   [NoisePublicKeySize]byte // precomputed shared secret
-       lastTimestamp             tai64n.Timestamp
+       lastTimestamp             Timestamp
        lastInitiationConsumption time.Time
 }
 
@@ -207,7 +206,7 @@ func (device *Device) CreateMessageInitiation(peer *Peer) (*MessageInitiation, e
 
        // encrypt timestamp
 
-       timestamp := tai64n.Now()
+       timestamp := TimestampNow()
        func() {
                var key [chacha20poly1305.KeySize]byte
                KDF2(
@@ -272,7 +271,7 @@ func (device *Device) ConsumeMessageInitiation(msg *MessageInitiation) *Peer {
 
        // verify identity
 
-       var timestamp tai64n.Timestamp
+       var timestamp Timestamp
        var key [chacha20poly1305.KeySize]byte
 
        handshake.mutex.RLock()
similarity index 99%
rename from internal/ratelimiter/ratelimiter.go
rename to ratelimiter.go
index 006900a647b601f4d4abf22d6722f05efc88c1cc..168a743e49d02f328fa9550986edbdce637ad762 100644 (file)
@@ -1,4 +1,4 @@
-package ratelimiter
+package main
 
 /* Copyright (C) 2015-2017 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. */
 
similarity index 99%
rename from internal/ratelimiter/ratelimiter_test.go
rename to ratelimiter_test.go
index 37339ee296edceb916d7538791ade2557c7c2dc8..9b0abfdcb3c8e541384170b2ff29132d48b01b24 100644 (file)
@@ -1,4 +1,4 @@
-package ratelimiter
+package main
 
 import (
        "net"
similarity index 91%
rename from internal/tai64n/tai64n.go
rename to tai64n.go
index da5257c1f7ff700c5ce1699b7e1e45592c6cdd09..8c5ebe0d9de499e4fc05304484288a0b39717fa4 100644 (file)
+++ b/tai64n.go
@@ -1,4 +1,4 @@
-package tai64n
+package main
 
 import (
        "bytes"
@@ -11,7 +11,7 @@ const base = uint64(4611686018427387914)
 
 type Timestamp [TimestampSize]byte
 
-func Now() Timestamp {
+func TimestampNow() Timestamp {
        var tai64n Timestamp
        now := time.Now()
        secs := base + uint64(now.Unix())
similarity index 84%
rename from internal/tai64n/tai64n_test.go
rename to tai64n_test.go
index 389b65cd961aba093b23c3057f13dafa6a12f078..a9e22b046642b92165469c16f5a0e4b182ee7156 100644 (file)
@@ -1,4 +1,4 @@
-package tai64n
+package main
 
 import (
        "testing"
@@ -9,10 +9,10 @@ import (
  * as used by WireGuard.
  */
 func TestMonotonic(t *testing.T) {
-       old := Now()
+       old := TimestampNow()
        for i := 0; i < 10000; i++ {
                time.Sleep(time.Nanosecond)
-               next := Now()
+               next := TimestampNow()
                if !next.After(old) {
                        t.Error("TAI64N, not monotonically increasing on nano-second scale")
                }
similarity index 98%
rename from internal/xchacha20poly1305/xchacha20.go
rename to xchacha20.go
index a6e59f0cf990d3712aa5c25639a3b2916c37813a..8e7d99fcaa1df11739bf2930691a77b8001a9073 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a license that can be
 // found in the LICENSE file.
 
-package xchacha20poly1305
+package main
 
 import (
        "encoding/binary"
@@ -138,7 +138,7 @@ func hChaCha20(out *[32]byte, nonce []byte, key *[32]byte) {
        binary.LittleEndian.PutUint32(out[28:], v15)
 }
 
-func Encrypt(
+func XChaCha20Poly1305Encrypt(
        dst []byte,
        nonceFull *[24]byte,
        plaintext []byte,
@@ -153,7 +153,7 @@ func Encrypt(
        return aead.Seal(dst, nonce[:], plaintext, additionalData)
 }
 
-func Decrypt(
+func XChaCha20Poly1305Decrypt(
        dst []byte,
        nonceFull *[24]byte,
        plaintext []byte,
similarity index 96%
rename from internal/xchacha20poly1305/xchacha20_test.go
rename to xchacha20_test.go
index 5d5b78fd2a548b46709032145a9ba639076e26f9..0f41cf8c799fe3581db7206fcbe84c79e47b7859 100644 (file)
@@ -1,4 +1,4 @@
-package xchacha20poly1305
+package main
 
 import (
        "encoding/hex"
@@ -60,7 +60,7 @@ func TestXChaCha20(t *testing.T) {
 
                        // test encryption
 
-                       ct := Encrypt(
+                       ct := XChaCha20Poly1305Encrypt(
                                nil,
                                &nonceArray,
                                pt,
@@ -74,7 +74,7 @@ func TestXChaCha20(t *testing.T) {
 
                        // test decryption
 
-                       ptp, err := Decrypt(
+                       ptp, err := XChaCha20Poly1305Decrypt(
                                nil,
                                &nonceArray,
                                ct,