From d85214252a08036fd2603bc00abf3ec5a5488caf Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 14 Feb 2018 14:39:43 +0100 Subject: [PATCH] Update deps --- Gopkg.lock | 10 +- .../github.com/aead/chacha20/chacha/chacha.go | 6 +- .../aead/chacha20/chacha/chacha_go17_amd64.go | 6 +- vendor/github.com/jedisct1/dlog/dlog.go | 8 +- .../github.com/jedisct1/xsecretbox/Gopkg.lock | 27 ++++ .../github.com/jedisct1/xsecretbox/Gopkg.toml | 11 ++ .../github.com/jedisct1/xsecretbox/glide.yaml | 6 - .../jedisct1/xsecretbox/sharedkey.go | 130 +----------------- 8 files changed, 58 insertions(+), 146 deletions(-) create mode 100644 vendor/github.com/jedisct1/xsecretbox/Gopkg.lock create mode 100644 vendor/github.com/jedisct1/xsecretbox/Gopkg.toml delete mode 100644 vendor/github.com/jedisct1/xsecretbox/glide.yaml diff --git a/Gopkg.lock b/Gopkg.lock index c49c2bdf..2fc1778d 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -23,7 +23,7 @@ branch = "master" name = "github.com/aead/chacha20" packages = ["chacha"] - revision = "8d6ce0550041f9d97e7f15ec27ed489f8bbbb0fb" + revision = "c8d29375923a8e1d2a0f0dc0fc1d8a0aba5b97ba" [[projects]] branch = "master" @@ -80,7 +80,7 @@ branch = "master" name = "github.com/jedisct1/dlog" packages = ["."] - revision = "9025b39d3d9a4e268e01f536c71c6177518fc461" + revision = "52c32ac39e436cd9295a4629a91f0613ce67052f" [[projects]] branch = "master" @@ -92,7 +92,7 @@ branch = "master" name = "github.com/jedisct1/xsecretbox" packages = ["."] - revision = "13d65f1d301904c28ff6c3256169cc60dd99c9dd" + revision = "88b1956e8d9a013c98dda528d3a5b77f168b057f" [[projects]] branch = "master" @@ -130,7 +130,7 @@ "poly1305", "salsa20/salsa" ] - revision = "1875d0a70c90e57f11972aefd42276df65e895b9" + revision = "650f4a345ab4e5b245a3034b110ebc7299e68186" [[projects]] branch = "master" @@ -142,7 +142,7 @@ "ipv4", "ipv6" ] - revision = "2fb46b16b8dda405028c50f7c7f0f9dd1fa6bfb1" + revision = "f5dfe339be1d06f81b22525fe34671ee7d2c8904" [[projects]] branch = "master" diff --git a/vendor/github.com/aead/chacha20/chacha/chacha.go b/vendor/github.com/aead/chacha20/chacha/chacha.go index 8c387a97..5e81b3bf 100644 --- a/vendor/github.com/aead/chacha20/chacha/chacha.go +++ b/vendor/github.com/aead/chacha20/chacha/chacha.go @@ -55,7 +55,7 @@ func setup(state *[64]byte, nonce, key []byte) (err error) { copy(hNonce[:], nonce[:16]) copy(tmpKey[:], key) - hChaCha20(&tmpKey, &hNonce, &tmpKey) + HChaCha20(&tmpKey, &hNonce, &tmpKey) copy(Nonce[8:], nonce[16:]) initialize(state, tmpKey[:], &Nonce) @@ -174,3 +174,7 @@ func (c *Cipher) SetCounter(ctr uint64) { } c.off = 0 } + +// HChaCha20 generates 32 pseudo-random bytes from a 128 bit nonce and a 256 bit secret key. +// It can be used as a key-derivation-function (KDF). +func HChaCha20(out *[32]byte, nonce *[16]byte, key *[32]byte) { hChaCha20(out, nonce, key) } diff --git a/vendor/github.com/aead/chacha20/chacha/chacha_go17_amd64.go b/vendor/github.com/aead/chacha20/chacha/chacha_go17_amd64.go index 9ff41cf2..c6697657 100644 --- a/vendor/github.com/aead/chacha20/chacha/chacha_go17_amd64.go +++ b/vendor/github.com/aead/chacha20/chacha/chacha_go17_amd64.go @@ -9,7 +9,7 @@ package chacha func init() { useSSE2 = true useSSSE3 = supportsSSSE3() - useAVX2 = supportsAVX2() + useAVX2 = supportsAVX2() && false // disable until #16 is fixed } // This function is implemented in chacha_amd64.s @@ -53,7 +53,7 @@ func hChaCha20(out *[32]byte, nonce *[16]byte, key *[32]byte) { hChaCha20AVX(out, nonce, key) } else if useSSSE3 { hChaCha20SSSE3(out, nonce, key) - } else if useSSE2 { // on amd64 this is always true - neccessary for testing generic on amd64 + } else if useSSE2 { // on amd64 this is always true - necessary for testing generic on amd64 hChaCha20SSE2(out, nonce, key) } else { hChaCha20Generic(out, nonce, key) @@ -65,7 +65,7 @@ func xorKeyStream(dst, src []byte, block, state *[64]byte, rounds int) int { return xorKeyStreamAVX2(dst, src, block, state, rounds) } else if useSSSE3 { return xorKeyStreamSSSE3(dst, src, block, state, rounds) - } else if useSSE2 { // on amd64 this is always true - neccessary for testing generic on amd64 + } else if useSSE2 { // on amd64 this is always true - necessary for testing generic on amd64 return xorKeyStreamSSE2(dst, src, block, state, rounds) } return xorKeyStreamGeneric(dst, src, block, state, rounds) diff --git a/vendor/github.com/jedisct1/dlog/dlog.go b/vendor/github.com/jedisct1/dlog/dlog.go index e5e37943..a9bc9811 100644 --- a/vendor/github.com/jedisct1/dlog/dlog.go +++ b/vendor/github.com/jedisct1/dlog/dlog.go @@ -49,8 +49,8 @@ const ( ) const ( - FloodDelay = 5 * time.Second - FloodMinRepeats = 3 + floodDelay = 5 * time.Second + floodMinRepeats = 3 ) var SeverityName = []string{ @@ -195,9 +195,9 @@ func logf(severity Severity, format string, args ...interface{}) { _globals.Lock() defer _globals.Unlock() if _globals.lastMessage == message { - if time.Since(_globals.lastOccurrence) < FloodDelay { + if time.Since(_globals.lastOccurrence) < floodDelay { _globals.occurrences++ - if _globals.occurrences > FloodMinRepeats { + if _globals.occurrences > floodMinRepeats { return } } diff --git a/vendor/github.com/jedisct1/xsecretbox/Gopkg.lock b/vendor/github.com/jedisct1/xsecretbox/Gopkg.lock new file mode 100644 index 00000000..c28e0bde --- /dev/null +++ b/vendor/github.com/jedisct1/xsecretbox/Gopkg.lock @@ -0,0 +1,27 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + branch = "master" + name = "github.com/aead/chacha20" + packages = ["chacha"] + revision = "c8d29375923a8e1d2a0f0dc0fc1d8a0aba5b97ba" + +[[projects]] + branch = "master" + name = "github.com/aead/poly1305" + packages = ["."] + revision = "6cf43fdfd7a228cf3003ae23d10ddbf65e85997b" + +[[projects]] + branch = "master" + name = "golang.org/x/crypto" + packages = ["curve25519"] + revision = "650f4a345ab4e5b245a3034b110ebc7299e68186" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + inputs-digest = "42efe358588369a13a535de17e8c42779e327991c8cf9974d387db143ab2fd7f" + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/vendor/github.com/jedisct1/xsecretbox/Gopkg.toml b/vendor/github.com/jedisct1/xsecretbox/Gopkg.toml new file mode 100644 index 00000000..82d7e9b0 --- /dev/null +++ b/vendor/github.com/jedisct1/xsecretbox/Gopkg.toml @@ -0,0 +1,11 @@ +[[constraint]] + branch = "master" + name = "github.com/aead/chacha20" + +[[constraint]] + branch = "master" + name = "github.com/aead/poly1305" + +[[constraint]] + branch = "master" + name = "golang.org/x/crypto" diff --git a/vendor/github.com/jedisct1/xsecretbox/glide.yaml b/vendor/github.com/jedisct1/xsecretbox/glide.yaml deleted file mode 100644 index ccc49f33..00000000 --- a/vendor/github.com/jedisct1/xsecretbox/glide.yaml +++ /dev/null @@ -1,6 +0,0 @@ -package: . -import: -- package: github.com/aead/chacha20 - subpackages: - - chacha -- package: github.com/aead/poly1305 diff --git a/vendor/github.com/jedisct1/xsecretbox/sharedkey.go b/vendor/github.com/jedisct1/xsecretbox/sharedkey.go index 8f90e729..e1bd8e56 100644 --- a/vendor/github.com/jedisct1/xsecretbox/sharedkey.go +++ b/vendor/github.com/jedisct1/xsecretbox/sharedkey.go @@ -1,137 +1,12 @@ package xsecretbox import ( - "encoding/binary" "errors" + "github.com/aead/chacha20/chacha" "golang.org/x/crypto/curve25519" ) -func hChaCha20(inout *[32]byte) { - v00 := uint32(0x61707865) - v01 := uint32(0x3320646e) - v02 := uint32(0x79622d32) - v03 := uint32(0x6b206574) - v04 := binary.LittleEndian.Uint32(inout[0:]) - v05 := binary.LittleEndian.Uint32(inout[4:]) - v06 := binary.LittleEndian.Uint32(inout[8:]) - v07 := binary.LittleEndian.Uint32(inout[12:]) - v08 := binary.LittleEndian.Uint32(inout[16:]) - v09 := binary.LittleEndian.Uint32(inout[20:]) - v10 := binary.LittleEndian.Uint32(inout[24:]) - v11 := binary.LittleEndian.Uint32(inout[28:]) - v12 := uint32(0) - v13 := uint32(0) - v14 := uint32(0) - v15 := uint32(0) - for i := 0; i < 20; i += 2 { - v00 += v04 - v12 ^= v00 - v12 = (v12 << 16) | (v12 >> 16) - v08 += v12 - v04 ^= v08 - v04 = (v04 << 12) | (v04 >> 20) - v00 += v04 - v12 ^= v00 - v12 = (v12 << 8) | (v12 >> 24) - v08 += v12 - v04 ^= v08 - v04 = (v04 << 7) | (v04 >> 25) - v01 += v05 - v13 ^= v01 - v13 = (v13 << 16) | (v13 >> 16) - v09 += v13 - v05 ^= v09 - v05 = (v05 << 12) | (v05 >> 20) - v01 += v05 - v13 ^= v01 - v13 = (v13 << 8) | (v13 >> 24) - v09 += v13 - v05 ^= v09 - v05 = (v05 << 7) | (v05 >> 25) - v02 += v06 - v14 ^= v02 - v14 = (v14 << 16) | (v14 >> 16) - v10 += v14 - v06 ^= v10 - v06 = (v06 << 12) | (v06 >> 20) - v02 += v06 - v14 ^= v02 - v14 = (v14 << 8) | (v14 >> 24) - v10 += v14 - v06 ^= v10 - v06 = (v06 << 7) | (v06 >> 25) - v03 += v07 - v15 ^= v03 - v15 = (v15 << 16) | (v15 >> 16) - v11 += v15 - v07 ^= v11 - v07 = (v07 << 12) | (v07 >> 20) - v03 += v07 - v15 ^= v03 - v15 = (v15 << 8) | (v15 >> 24) - v11 += v15 - v07 ^= v11 - v07 = (v07 << 7) | (v07 >> 25) - v00 += v05 - v15 ^= v00 - v15 = (v15 << 16) | (v15 >> 16) - v10 += v15 - v05 ^= v10 - v05 = (v05 << 12) | (v05 >> 20) - v00 += v05 - v15 ^= v00 - v15 = (v15 << 8) | (v15 >> 24) - v10 += v15 - v05 ^= v10 - v05 = (v05 << 7) | (v05 >> 25) - v01 += v06 - v12 ^= v01 - v12 = (v12 << 16) | (v12 >> 16) - v11 += v12 - v06 ^= v11 - v06 = (v06 << 12) | (v06 >> 20) - v01 += v06 - v12 ^= v01 - v12 = (v12 << 8) | (v12 >> 24) - v11 += v12 - v06 ^= v11 - v06 = (v06 << 7) | (v06 >> 25) - v02 += v07 - v13 ^= v02 - v13 = (v13 << 16) | (v13 >> 16) - v08 += v13 - v07 ^= v08 - v07 = (v07 << 12) | (v07 >> 20) - v02 += v07 - v13 ^= v02 - v13 = (v13 << 8) | (v13 >> 24) - v08 += v13 - v07 ^= v08 - v07 = (v07 << 7) | (v07 >> 25) - v03 += v04 - v14 ^= v03 - v14 = (v14 << 16) | (v14 >> 16) - v09 += v14 - v04 ^= v09 - v04 = (v04 << 12) | (v04 >> 20) - v03 += v04 - v14 ^= v03 - v14 = (v14 << 8) | (v14 >> 24) - v09 += v14 - v04 ^= v09 - v04 = (v04 << 7) | (v04 >> 25) - } - binary.LittleEndian.PutUint32(inout[0:], v00) - binary.LittleEndian.PutUint32(inout[4:], v01) - binary.LittleEndian.PutUint32(inout[8:], v02) - binary.LittleEndian.PutUint32(inout[12:], v03) - binary.LittleEndian.PutUint32(inout[16:], v12) - binary.LittleEndian.PutUint32(inout[20:], v13) - binary.LittleEndian.PutUint32(inout[24:], v14) - binary.LittleEndian.PutUint32(inout[28:], v15) -} - // SharedKey computes a shared secret compatible with the one used by `crypto_box_xchacha20poly1305`` func SharedKey(secretKey [32]byte, publicKey [32]byte) ([32]byte, error) { var sharedKey [32]byte @@ -143,6 +18,7 @@ func SharedKey(secretKey [32]byte, publicKey [32]byte) ([32]byte, error) { if c == 0 { return sharedKey, errors.New("weak public key") } - hChaCha20(&sharedKey) + var nonce [16]byte + chacha.HChaCha20(&sharedKey, &nonce, &sharedKey) return sharedKey, nil }