Updated go.mod deps

Signed-off-by: Russ Magee <rmagee@gmail.com>
This commit is contained in:
Russ Magee 2020-02-06 19:02:34 -08:00
parent 1b964a4066
commit 58652ce935
4 changed files with 26 additions and 6 deletions

2
go.mod
View file

@ -3,7 +3,7 @@ module blitter.com/go/xs
go 1.12 go 1.12
require ( 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/goutmp v1.0.2
blitter.com/go/herradurakex v1.0.0 blitter.com/go/herradurakex v1.0.0
blitter.com/go/kyber v0.0.0-20200130200857-6f2021cb88d9 blitter.com/go/kyber v0.0.0-20200130200857-6f2021cb88d9

2
go.sum
View file

@ -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.0/go.mod h1:tdME2J3O4agaDAYIYNQzzuB28yVGnPSMmV3a/ucSU84=
blitter.com/go/cryptmt v1.0.1 h1:NAi4FrZqo52bhPJopYw1jbausj1NnHEWELaINC60Nk0= 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.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 h1:jBqtp6pDwSbF4QEC3DjNfyaS8Nv5dFCOyaTfSbbb7TU=
blitter.com/go/goutmp v1.0.1/go.mod h1:gtlbjC8xGzMk/Cf0BpnVltSa3awOqJ+B5WAxVptTMxk= blitter.com/go/goutmp v1.0.1/go.mod h1:gtlbjC8xGzMk/Cf0BpnVltSa3awOqJ+B5WAxVptTMxk=
blitter.com/go/goutmp v1.0.2 h1:oCc/dt9TlTOP2kvmX1Y7J/wSQUhywjcyF101jXuLxZ8= blitter.com/go/goutmp v1.0.2 h1:oCc/dt9TlTOP2kvmX1Y7J/wSQUhywjcyF101jXuLxZ8=

View file

@ -1,6 +1,6 @@
// Package CryptMT - implementation of cryptMTv1 stream cipher // Package CryptMT - implementation of cryptMTv1 stream cipher
// (but with mtwist64 as base accum) // (but with mtwist64 as base accum)
// https://eprint.iacr.org/2005/165.pdf // https://eprint.iacr.org/2005/165.pdf
package cryptmt package cryptmt
// TODO rlm: according to go docs, stream ciphers do not implement the // TODO rlm: according to go docs, stream ciphers do not implement the
@ -11,11 +11,14 @@ package cryptmt
import ( import (
"errors" "errors"
"io"
mtwist "blitter.com/go/mtwist" mtwist "blitter.com/go/mtwist"
) )
type Cipher struct { type Cipher struct {
r io.Reader
w io.Writer
accum uint64 accum uint64
m *mtwist.MT19937_64 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 // New creates and returns a Cipher. The key argument should be the
// CryptMT key, 64 bytes. // CryptMT key, 64 bytes.
func New(key []byte) (c *Cipher) { func New(r io.Reader, w io.Writer, key []byte) (c *Cipher) {
c = &Cipher{m: mtwist.New()} c = &Cipher{m: mtwist.New(), r: r, w: w}
c.m.SeedFullState(key) c.m.SeedFullState(key)
c.accum = 1 c.accum = 1
// from paper, discard first 64 bytes of output // from paper, discard first 64 bytes of output
@ -39,6 +42,21 @@ func New(key []byte) (c *Cipher) {
return c 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 // 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. // cipher's key stream. Dst and src must overlap entirely or not at all.
// //

2
vendor/modules.txt vendored
View file

@ -3,7 +3,7 @@ blitter.com/go/chacha20
blitter.com/go/chacha20/internal/api blitter.com/go/chacha20/internal/api
blitter.com/go/chacha20/internal/hardware blitter.com/go/chacha20/internal/hardware
blitter.com/go/chacha20/internal/ref 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/cryptmt
# blitter.com/go/goutmp v1.0.2 # blitter.com/go/goutmp v1.0.2
blitter.com/go/goutmp blitter.com/go/goutmp