secure

package module
v0.0.0-...-8071ed1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2019 License: BSD-3-Clause Imports: 5 Imported by: 0

README

Go Challenge 2 Build Status GoDoc

Securing data transmission using NaCl.

More information here

Note: This is an updated version based on evaluator feedback. The original is here

Installation/Usage

go get -u github.com/jboverfelt/secure

To build the included command, change to the cmd/challenge2 directory and run go build

Tests were split up into two files, one for the library and one for the command

Documentation

Index

Constants

View Source
const KeySize = 32

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

View Source
const MaxMessageSize = 32 * 1024

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

View Source
const NonceSize = 24

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

Variables

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

ErrDecrypt means that there was a problem during decryption

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

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

View Source
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

Functions

This section is empty.

Types

type Reader

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

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

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

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

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

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

Write encrypts a plaintext stream using box.Seal

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL