Documentation ¶
Overview ¶
Taken and adapted from: - https://github.com/schollz/croc/blob/8dc5bd6e046194d0c5b1dc34b0fd1602f8f6c7ad/src/crypt/crypt.go#L1 - https://github.com/blend/go-sdk/blob/29e67762ae016aba504d9de96bd99cd4b23728f7/crypto/stream.go#L23
Index ¶
Constants ¶
const NonceLength = 12
Variables ¶
This section is empty.
Functions ¶
func DeriveKey ¶ added in v0.3.0
DeriveKey uses scrypt to generated a fixed size key for further encryption/decryption steps aka. to initialise the block cipher. After minimal research I chose scrypt over pbkdf2 as apparently scrypt contains pbkdf2? Which is a good thing I guess. The parameters below are taken from example test in the scrypt package.
Types ¶
type StreamDecrypter ¶ added in v0.3.0
type StreamDecrypter struct {
// contains filtered or unexported fields
}
StreamDecrypter is a decrypter for a stream of data with authentication
func NewStreamDecrypter ¶ added in v0.3.0
NewStreamDecrypter creates a new stream decrypter
func (*StreamDecrypter) Authenticate ¶ added in v0.3.0
func (s *StreamDecrypter) Authenticate(hash []byte) error
Authenticate verifies that the hash of the stream is correct. This should only be called after processing is finished
type StreamEncrypter ¶ added in v0.3.0
type StreamEncrypter struct {
// contains filtered or unexported fields
}
StreamEncrypter implements the Reader interface to be used in streaming scenarios.
func NewStreamEncrypter ¶ added in v0.3.0
func NewStreamEncrypter(key []byte, dest io.Writer) (*StreamEncrypter, error)
NewStreamEncrypter initializes a stream encrypter.
func (*StreamEncrypter) Hash ¶ added in v0.3.0
func (s *StreamEncrypter) Hash() []byte
Hash should be called after the whole payload was read. It returns the SHA-256 hash of the payload.
func (*StreamEncrypter) InitializationVector ¶ added in v0.3.0
func (s *StreamEncrypter) InitializationVector() []byte