]> Cypherpunks.ru repositories - govpn.git/commitdiff
Replace blake2b with golang.org/x/crypto implementation
authorSergey Matveev <stargrave@stargrave.org>
Sat, 29 Oct 2016 12:43:22 +0000 (15:43 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 29 Oct 2016 14:14:24 +0000 (17:14 +0300)
Just to have fewer repository dependencies.

.gitmodules
doc/installation.texi
doc/sources.texi
src/cypherpunks.ru/govpn/aont/oaep.go
src/cypherpunks.ru/govpn/handshake.go
src/cypherpunks.ru/govpn/identity.go
src/cypherpunks.ru/govpn/peer.go
src/cypherpunks.ru/govpn/verifier.go
src/github.com/dchest/blake2b [deleted submodule]
utils/makedist.sh

index bb2b1f83ab61d548a662c6536318abd69342dea4..82df1f7e8a594fcda48fccdf6d3c937b356e89fb 100644 (file)
@@ -7,9 +7,6 @@
 [submodule "src/golang.org/x/crypto"]
        path = src/golang.org/x/crypto
        url = https://go.googlesource.com/crypto
-[submodule "src/github.com/dchest/blake2b"]
-       path = src/github.com/dchest/blake2b
-       url = https://github.com/dchest/blake2b.git
 [submodule "src/github.com/go-yaml/yaml"]
        path = src/github.com/go-yaml/yaml
        url = https://github.com/go-yaml/yaml.git
index 01ac54b8e1cbc48aaf04a193ad7f7f08ac2c17dc..1443d7f95c8f752d3fd5e5d57a2b1694f9c956bb 100644 (file)
@@ -26,7 +26,6 @@ Included required libraries:
 @headitem Library @tab Platform @tab Licence
 @item @code{github.com/agl/ed25519} @tab All @tab BSD 3-Clause
 @item @code{github.com/bigeagle/water} @tab GNU/Linux @tab BSD 3-Clause
-@item @code{github.com/dchest/blake2b} @tab All @tab CC0 1.0
 @item @code{github.com/go-yaml/yaml} @tab All @tab LGPLv3 and MIT
 @item @code{golang.org/x/crypto} @tab All @tab BSD 3-Clause
 @end multitable
index 778a786a6600d67481b2eb5c123e4ab0c0e051e4..e7a13755b3fc8d9b44911ec4965e651fdbe66428 100644 (file)
@@ -25,7 +25,6 @@ repositories will be unavailable (they are seldom updated):
 @item @code{cypherpunks.ru/govpn} @tab @url{https://github.com/stargrave/govpn.git}
 @item @code{github.com/agl/ed25519} @tab @url{git://git.cypherpunks.ru/ed25519.git}
 @item @code{github.com/bigeagle/water} @tab @url{git://git.cypherpunks.ru/water.git}
-@item @code{github.com/dchest/blake2b} @tab @url{git://git.cypherpunks.ru/blake2b.git}
 @item @code{github.com/go-yaml/yaml} @tab @url{git://git.cypherpunks.ru/yaml.git}
 @item @code{golang.org/x/crypto} @tab @url{git://git.cypherpunks.ru/crypto.git}
 @end multitable
index 35d92fecf36c722404efae2c2f01f6485869565b..3d1a1c6731722eecef657ffa3a6e9074b7368d6e 100644 (file)
@@ -38,7 +38,7 @@ import (
        "crypto/subtle"
        "errors"
 
-       "github.com/dchest/blake2b"
+       "golang.org/x/crypto/blake2b"
        "golang.org/x/crypto/salsa20"
 )
 
@@ -56,7 +56,10 @@ var (
 func Encode(r *[RSize]byte, in []byte) ([]byte, error) {
        out := make([]byte, len(in)+HSize+RSize)
        copy(out, in)
-       h := blake2b.New256()
+       h, err := blake2b.New256(nil)
+       if err != nil {
+               return nil, err
+       }
        h.Write(r[:])
        h.Write(in)
        copy(out[len(in):], h.Sum(nil))
@@ -77,7 +80,10 @@ func Decode(in []byte) ([]byte, error) {
        if len(in) < HSize+RSize {
                return nil, errors.New("Too small input buffer")
        }
-       h := blake2b.New256()
+       h, err := blake2b.New256(nil)
+       if err != nil {
+               return nil, err
+       }
        h.Write(in[:len(in)-RSize])
        salsaKey := new([32]byte)
        for i, b := range h.Sum(nil)[:RSize] {
index 9c536b329371fe7a5a946229407285214dbd5e30..fb486f592aa86ff76417a4dcad8e732cd843878c 100644 (file)
@@ -27,7 +27,7 @@ import (
 
        "github.com/agl/ed25519"
        "github.com/agl/ed25519/extra25519"
-       "github.com/dchest/blake2b"
+       "golang.org/x/crypto/blake2b"
        "golang.org/x/crypto/curve25519"
        "golang.org/x/crypto/salsa20"
 )
@@ -136,7 +136,10 @@ func idTag(id *PeerId, timeSync int, data []byte) []byte {
        enc := make([]byte, 8)
        copy(enc, data)
        AddTimeSync(timeSync, enc)
-       mac := blake2b.NewMAC(8, id[:])
+       mac, err := blake2b.New256(id[:])
+       if err != nil {
+               panic(err)
+       }
        mac.Write(enc)
        mac.Sum(enc[:0])
        return enc
index 4dc74eed0e330f4a3ec73570e0c9d73b2503baee..ece2dfcf0bb2131fd4c4a48c8467d39230728837 100644 (file)
@@ -27,7 +27,7 @@ import (
        "sync"
        "time"
 
-       "github.com/dchest/blake2b"
+       "golang.org/x/crypto/blake2b"
 )
 
 const (
@@ -73,8 +73,12 @@ func (mc *MACCache) Update(peers *map[PeerId]*PeerConf) {
                        mc.cache[pid].ts = pc.TimeSync
                } else {
                        log.Println("Adding key", pid)
+                       mac, err := blake2b.New256(pid[:])
+                       if err != nil {
+                               panic(err)
+                       }
                        mc.cache[pid] = &MACAndTimeSync{
-                               mac: blake2b.NewMAC(8, pid[:]),
+                               mac: mac,
                                ts:  pc.TimeSync,
                        }
                }
index 5a620a9c76692d23536aa87d0c6fabc770795fac..213e8174786df4db45d72abfa40a20043851b9a4 100644 (file)
@@ -28,7 +28,7 @@ import (
        "sync/atomic"
        "time"
 
-       "github.com/dchest/blake2b"
+       "golang.org/x/crypto/blake2b"
        "golang.org/x/crypto/poly1305"
        "golang.org/x/crypto/salsa20"
 )
@@ -52,7 +52,10 @@ const (
 func newNonces(key *[32]byte, i uint64) chan *[NonceSize]byte {
        macKey := make([]byte, 32)
        salsa20.XORKeyStream(macKey, make([]byte, 32), make([]byte, 8), key)
-       mac := blake2b.NewMAC(NonceSize, macKey)
+       mac, err := blake2b.New256(macKey)
+       if err != nil {
+               panic(err)
+       }
        nonces := make(chan *[NonceSize]byte, NonceBucketSize*3)
        go func() {
                for {
index b68063b94823361f25bc5734d50cd7aa43a6502b..832fafe2dacf4981ee3ffc39e20aa5cde77d3a68 100644 (file)
@@ -23,6 +23,7 @@ import (
        "encoding/base64"
        "errors"
        "fmt"
+       "hash"
        "io/ioutil"
        "log"
        "os"
@@ -30,7 +31,7 @@ import (
 
        "cypherpunks.ru/balloon"
        "github.com/agl/ed25519"
-       "github.com/dchest/blake2b"
+       "golang.org/x/crypto/blake2b"
        "golang.org/x/crypto/ssh/terminal"
 )
 
@@ -54,10 +55,18 @@ func VerifierNew(s, t, p int, id *PeerId) *Verifier {
        return &Verifier{S: s, T: t, P: p, Id: id}
 }
 
+func blake2bKeyless() hash.Hash {
+       h, err := blake2b.New256(nil)
+       if err != nil {
+               panic(err)
+       }
+       return h
+}
+
 // Apply the password: create Ed25519 keypair based on it, save public
 // key in verifier.
 func (v *Verifier) PasswordApply(password string) *[ed25519.PrivateKeySize]byte {
-       r := balloon.H(blake2b.New256, []byte(password), v.Id[:], v.S, v.T, v.P)
+       r := balloon.H(blake2bKeyless, []byte(password), v.Id[:], v.S, v.T, v.P)
        defer SliceZero(r)
        src := bytes.NewBuffer(r)
        pub, prv, err := ed25519.GenerateKey(src)
diff --git a/src/github.com/dchest/blake2b b/src/github.com/dchest/blake2b
deleted file mode 160000 (submodule)
index 3c8c640..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 3c8c640cd7bea3ca78209d812b5854442ab92fed
index e5423e814638d8a33b0ab29a5e0b0199130f2a38..8ad291cb7ee55248149c3631c8f2b47797f4deb6 100755 (executable)
@@ -10,7 +10,6 @@ repos="
     src/cypherpunks.ru/balloon
     src/github.com/agl/ed25519
     src/github.com/bigeagle/water
-    src/github.com/dchest/blake2b
     src/github.com/go-yaml/yaml
     src/golang.org/x/crypto
 "
@@ -27,6 +26,7 @@ golang.org/x/crypto/CONTRIBUTORS
 golang.org/x/crypto/LICENSE
 golang.org/x/crypto/PATENTS
 golang.org/x/crypto/README
+golang.org/x/crypto/blake2b
 golang.org/x/crypto/curve25519
 golang.org/x/crypto/poly1305
 golang.org/x/crypto/salsa20