cipher

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package cipher implements symmetric encryption helpers for keyrings. The underlying cryptography is implemented by chacha20poly1305.

Index

Constants

KeyLen defines the key length in bytes of an encryption key.

Variables

This section is empty.

Functions

func DecryptWithKey

func DecryptWithKey(key, data, extra []byte) ([]byte, error)

DecryptWithKey decrypts data using a cipher.AEAD over chacha20poly1305 with the specified key and extra data.

func EncryptWithKey

func EncryptWithKey(key, data, extra []byte) (int, []byte, error)

EncryptWithKey encrypts data using a cipher.AEAD over chacha20poly1305 with the specified key and extra data. It returns the length of the AEAD nonce along with the encrypted result. The nonce occupies a prefix of the encrypted result.

func GenerateAndEncryptKey

func GenerateAndEncryptKey(accessKey []byte, n int) (plain, encrypted []byte, _ error)

GenerateAndEncryptKey generates a cryptographically-random key of the specified length and encrypts it with the specified access key. The plaintext and ciphertext of the key are both returned.

func GenerateKey

func GenerateKey(keyBytes int) []byte

GenerateKey generates a cryptographically random key of the specified length in bytes.

func KeyFingerprintString added in v0.2.6

func KeyFingerprintString(key []byte) string

KeyFingerprintString reports a human-readable cryptographic fingerprint for a key.

func KeyFromPassphrase

func KeyFromPassphrase(passphrase string, n int, salt []byte) (_key, _salt []byte)

KeyFromPassphrase returns a cryptographic key of n bytes, derived via argon2.IDKey from the specified passphrase and a random salt. If salt == nil, a new random salt is generated and returned; otherwise the provided value is used in the KDF. The key and the salt are returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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