Documentation
¶
Overview ¶
Package cipher implements symmetric encryption helpers for keyrings. The underlying cryptography is implemented by chacha20poly1305.
Index ¶
- Constants
- func DecryptWithKey(key, data, extra []byte) ([]byte, error)
- func EncryptWithKey(key, data, extra []byte) (int, []byte, error)
- func GenerateAndEncryptKey(accessKey []byte, n int) (plain, encrypted []byte, _ error)
- func GenerateKey(keyBytes int) []byte
- func KeyFingerprintString(key []byte) string
- func KeyFromPassphrase(passphrase string, n int, salt []byte) (_key, _salt []byte)
Constants ¶
const KeyLen = chacha20poly1305.KeySize
KeyLen defines the key length in bytes of an encryption key.
Variables ¶
This section is empty.
Functions ¶
func DecryptWithKey ¶
DecryptWithKey decrypts data using a cipher.AEAD over chacha20poly1305 with the specified key and extra data.
func EncryptWithKey ¶
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 ¶
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 ¶
GenerateKey generates a cryptographically random key of the specified length in bytes.
func KeyFingerprintString ¶ added in v0.2.6
KeyFingerprintString reports a human-readable cryptographic fingerprint for a key.
func KeyFromPassphrase ¶
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.