rotfile

package
v0.0.0-...-d56d81e Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: 0BSD Imports: 5 Imported by: 0

Documentation

Overview

Package rotfile provides functions that securely encrypt and decrypt data in rotfiles.

For a description of the rotfile file format, see the "doc" directory in the repository.

Index

Constants

View Source
const (
	KeySize = chacha20poly1305.KeySize
)

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(in []byte, key []byte) ([]byte, error)

Decrypt is the inverse operation of Encrypt.

If message authentication failed (for example, because the key is incorrect, or because the input was tampered with after encryption), then IsMessageAuthenticationFailed(err) will return true.

func Encrypt

func Encrypt(plaintext []byte, key []byte) ([]byte, error)

Encrypt encrypts plaintext using the XChaCha20-Poly1305 AEAD. A nonce required for encryption is generated internally and is included in the returned bytes. The returned bytes can be provided to func Decrypt to retrieve the original plaintext.

The key length must equal KeySize.

func EncryptedLen

func EncryptedLen(plaintextLen int) int

EncryptedLen returns the expected length of the ciphertext (from func Encrypt) for a plaintext of the given length.

func IsMessageAuthenticationFailed

func IsMessageAuthenticationFailed(err error) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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