shared

package
v0.0.0-...-3d01529 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2015 License: ISC Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RootDirectory    = ".acdbackup"
	TokenFilename    = "acd-token.json"
	KeysFilename     = "keys.json"
	PasswordFilename = "password"
)
View Source
const (
	Version = 1

	KeySize   = 32
	NonceSize = 24
)

internal metadata

Variables

View Source
var (
	CompNone = [4]byte{'n', 'o', 'n', 'e'}
	CompGZIP = [4]byte{'g', 'z', 'i', 'p'}
)

Functions

func CreateNewKeys

func CreateNewKeys(filename string) error

func DefaultKeysFilename

func DefaultKeysFilename() (string, error)

func DefaultPasswordFilename

func DefaultPasswordFilename() (string, error)

func FileNaClEncrypt

func FileNaClEncrypt(filename string, compress bool,
	key *[KeySize]byte) ([]byte, error)

func LoadKeys

func LoadKeys(filename string, keys *Keys) error

func NaClNonce

func NaClNonce() (*[NonceSize]byte, error)

func PromptPassword

func PromptPassword(save bool) ([]byte, error)

func ReadPassword

func ReadPassword() ([]byte, error)

func WritePassword

func WritePassword(password []byte) error

Types

type Header struct {
	Version     int               // header version
	Compression [4]byte           // payload compression
	Size        uint64            // payload size
	Digest      [sha256.Size]byte // payload digest
	MimeType    string            // MIME type
}

func FileNaClDecrypt

func FileNaClDecrypt(filename string, key *[KeySize]byte) (*Header, []byte,
	error)

func NaClDecrypt

func NaClDecrypt(body []byte, key *[KeySize]byte) (*Header, []byte, error)

type Keys

type Keys struct {
	MD    [KeySize]byte // uploaded metadata key
	Data  [KeySize]byte // uploaded data key
	Dedup [KeySize]byte // hmac key for dedup collisions
}

func KeysDecrypt

func KeysDecrypt(password []byte, N, r, p int,
	blob []byte) (*Keys, error)

KeysDecrypt decrypts keys from a blob. This function relies on secretbox's property that it'll fail decryption due to authenticators. As such it does not carry a digest to validate the contents.

func (*Keys) Encrypt

func (k *Keys) Encrypt(password []byte, N, r, p int) ([]byte, error)

Encrypt returns an encrypted Keys blob. The format of the blob is [salt][nonce][encrypted keys]

Jump to

Keyboard shortcuts

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