mirror of https://gogs.blitter.com/RLabs/xs
Updated go.mod deps
Signed-off-by: Russ Magee <rmagee@gmail.com>
This commit is contained in:
parent
1b964a4066
commit
58652ce935
2
go.mod
2
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
|
||||
|
|
2
go.sum
2
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=
|
||||
|
|
|
@ -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.
|
||||
//
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue