secure: github.com/jboverfelt/secure Index | Files

package secure

import "github.com/jboverfelt/secure"

Index

Package Files

secure.go

Constants

const KeySize = 32

Size (in bytes) of the key for NaCl box seal/open

const MaxMessageSize = 32 * 1024

Size (in bytes) of the max message size supported by this package

const NonceSize = 24

Size (in bytes) of the nonce for NaCl box seal/open

Variables

var ErrDecrypt = errors.New("decrypt error")

ErrDecrypt means that there was a problem during decryption

var ErrEncWrite = errors.New("failed to write complete encrypted message")

ErrEncWrite means that a complete encrypted message was unable to be written

var ErrNonceSize = errors.New("not enough bytes read for nonce")

ErrNonceSize means that the source of randomness did not provide enough bytes for a complete nonce

type Reader Uses

type Reader struct {
    // contains filtered or unexported fields
}

A Reader is an io.Reader that can be used to read streams of encrypted data that was encrypted using the Writer from this package. The Reader will decrypt and return the plaintext from the provided io.Reader.

func NewReader Uses

func NewReader(r io.Reader, priv, pub *[KeySize]byte) Reader

NewReader instantiates a new secure Reader priv and pub should be keys generated with box.GenerateKey

func (Reader) Read Uses

func (s Reader) Read(p []byte) (int, error)

Read decrypts a stream encrypted with box.Seal. It expects the nonce used to be prepended to the ciphertext

type Writer Uses

type Writer struct {
    // contains filtered or unexported fields
}

A Writer is an io.Writer which will encrypt the provided data and write it to the provided wrapped io.Writer

func NewWriter Uses

func NewWriter(w io.Writer, priv, pub *[KeySize]byte) Writer

NewWriter instantiates a new secure Writer priv and pub should be keys generated with box.GenerateKey

func (Writer) Write Uses

func (s Writer) Write(p []byte) (int, error)

Write encrypts a plaintext stream using box.Seal

Package secure imports 5 packages (graph). Updated 2016-07-18. Refresh now. Tools for package owners.