continued work on encryption
This commit is contained in:
parent
4e1d5b36b2
commit
880e2f06b3
14 changed files with 362 additions and 39 deletions
|
|
@ -3,6 +3,7 @@ package crypto
|
|||
import (
|
||||
"crypto/cipher"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"golang.org/x/crypto/chacha20poly1305"
|
||||
|
|
@ -23,6 +24,7 @@ type reader struct {
|
|||
|
||||
err error
|
||||
nonce [NonceSize]byte
|
||||
cn int64
|
||||
}
|
||||
|
||||
func newReader(key []byte, src cryptoReader) (*reader, error) {
|
||||
|
|
@ -33,6 +35,7 @@ func newReader(key []byte, src cryptoReader) (*reader, error) {
|
|||
return &reader{
|
||||
a: aead,
|
||||
src: src,
|
||||
cn: -1,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +87,9 @@ func (r *reader) readChunk() (last bool, err error) {
|
|||
// The last chunk can be short.
|
||||
in = in[:n]
|
||||
last = true
|
||||
fmt.Println("last nonce", r.nonce)
|
||||
setLastChunkFlag(&r.nonce)
|
||||
fmt.Println("last nonce flag", r.nonce)
|
||||
case err != nil:
|
||||
return false, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue