crypto

package
v0.0.0-...-a60e539 Latest Latest
Warning

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

Go to latest
Published: May 20, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Overhead includes the nonce size and the auth tag size.
	Overhead = chacha20poly1305.NonceSizeX + poly1305.TagSize
	// ChunkOverhead is the normal overhead plus the header for each chunk.
	ChunkOverhead = Overhead + 8
)

Variables

This section is empty.

Functions

func NewCrypto

func NewCrypto(password []byte) (*Crypto, *KeyStore, error)

NewCrypto returns a crypto wrapper for the given key.

Types

type Crypto

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

Crypto represents a wrapper for AES de- and encryption.

func ExistingCrypto

func ExistingCrypto(password []byte, ks *KeyStore) (*Crypto, error)

ExistingCrypto returns a crypto wrapper for the given key.

func (Crypto) OpenBytes

func (c Crypto) OpenBytes(ciphertext, data []byte) ([]byte, error)

OpenBytes decrypts the contents of an io.Reader to an io.Writer.

func (Crypto) SealBytes

func (c Crypto) SealBytes(plaintext, data []byte) []byte

SealBytes takes the plaintext and encrypts its contents and the ciphertext.

type KeyStore

type KeyStore struct {
	KDFSalt  []byte // 16 byte
	KeyNonce []byte // 12 byte
	Key      []byte // 48 byte (32 bytes key, 16 bytes auth)
}

KeyStore holds all information necessary to derive a key from the users password and decrypt the data key.

func UpdatePassword

func UpdatePassword(oldPwd, newPwd []byte, ks *KeyStore) (*KeyStore, error)

UpdatePassword re-encrypts the archive key with the new password.

Jump to

Keyboard shortcuts

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