From 58652ce935a78acf954419c932abc56ed2fd4e96 Mon Sep 17 00:00:00 2001 From: Russ Magee Date: Thu, 6 Feb 2020 19:02:34 -0800 Subject: [PATCH] Updated go.mod deps Signed-off-by: Russ Magee --- go.mod | 2 +- go.sum | 2 ++ vendor/blitter.com/go/cryptmt/cryptmt.go | 26 ++++++++++++++++++++---- vendor/modules.txt | 2 +- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 2bce810..6309a93 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module blitter.com/go/xs go 1.12 require ( - blitter.com/go/cryptmt v1.0.1 + blitter.com/go/cryptmt v1.0.2 blitter.com/go/goutmp v1.0.2 blitter.com/go/herradurakex v1.0.0 blitter.com/go/kyber v0.0.0-20200130200857-6f2021cb88d9 diff --git a/go.sum b/go.sum index ce9ef5f..32142b8 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ blitter.com/go/cryptmt v1.0.0 h1:n+cNP/ReZrNe/w5FbD8DSfv0Wpj48nxhmMoLEk4hPXs= blitter.com/go/cryptmt v1.0.0/go.mod h1:tdME2J3O4agaDAYIYNQzzuB28yVGnPSMmV3a/ucSU84= blitter.com/go/cryptmt v1.0.1 h1:NAi4FrZqo52bhPJopYw1jbausj1NnHEWELaINC60Nk0= blitter.com/go/cryptmt v1.0.1/go.mod h1:tdME2J3O4agaDAYIYNQzzuB28yVGnPSMmV3a/ucSU84= +blitter.com/go/cryptmt v1.0.2 h1:ZcLhQk7onUssXyQwG3GdXDXctCVnNL+b7aFuvwOdKXc= +blitter.com/go/cryptmt v1.0.2/go.mod h1:tdME2J3O4agaDAYIYNQzzuB28yVGnPSMmV3a/ucSU84= blitter.com/go/goutmp v1.0.1 h1:jBqtp6pDwSbF4QEC3DjNfyaS8Nv5dFCOyaTfSbbb7TU= blitter.com/go/goutmp v1.0.1/go.mod h1:gtlbjC8xGzMk/Cf0BpnVltSa3awOqJ+B5WAxVptTMxk= blitter.com/go/goutmp v1.0.2 h1:oCc/dt9TlTOP2kvmX1Y7J/wSQUhywjcyF101jXuLxZ8= diff --git a/vendor/blitter.com/go/cryptmt/cryptmt.go b/vendor/blitter.com/go/cryptmt/cryptmt.go index 6888667..3a627ed 100644 --- a/vendor/blitter.com/go/cryptmt/cryptmt.go +++ b/vendor/blitter.com/go/cryptmt/cryptmt.go @@ -1,6 +1,6 @@ // Package CryptMT - implementation of cryptMTv1 stream cipher -// (but with mtwist64 as base accum) -// https://eprint.iacr.org/2005/165.pdf +// (but with mtwist64 as base accum) +// https://eprint.iacr.org/2005/165.pdf package cryptmt // TODO rlm: according to go docs, stream ciphers do not implement the @@ -11,11 +11,14 @@ package cryptmt import ( "errors" + "io" mtwist "blitter.com/go/mtwist" ) type Cipher struct { + r io.Reader + w io.Writer accum uint64 m *mtwist.MT19937_64 } @@ -28,8 +31,8 @@ func (c *Cipher) yield() (r byte) { // New creates and returns a Cipher. The key argument should be the // CryptMT key, 64 bytes. -func New(key []byte) (c *Cipher) { - c = &Cipher{m: mtwist.New()} +func New(r io.Reader, w io.Writer, key []byte) (c *Cipher) { + c = &Cipher{m: mtwist.New(), r: r, w: w} c.m.SeedFullState(key) c.accum = 1 // from paper, discard first 64 bytes of output @@ -39,6 +42,21 @@ func New(key []byte) (c *Cipher) { return c } +func (c *Cipher) Read(p []byte) (n int, err error) { + n, err = c.r.Read(p) + if err == nil { + for idx := 0; idx < n; idx++ { + p[idx] = p[idx] ^ c.yield() + } + } + return n, err +} + +func (c *Cipher) Write(p []byte) (n int, err error) { + n, err = c.w.Write(p) + return n, err +} + // XORKeyStream XORs each byte in the given slice with a byte from the // cipher's key stream. Dst and src must overlap entirely or not at all. // diff --git a/vendor/modules.txt b/vendor/modules.txt index 48f0fc9..69badde 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -3,7 +3,7 @@ blitter.com/go/chacha20 blitter.com/go/chacha20/internal/api blitter.com/go/chacha20/internal/hardware blitter.com/go/chacha20/internal/ref -# blitter.com/go/cryptmt v1.0.1 +# blitter.com/go/cryptmt v1.0.2 blitter.com/go/cryptmt # blitter.com/go/goutmp v1.0.2 blitter.com/go/goutmp