Documentation
¶
Overview ¶
Package cipher implements Families 5 and 6. Family 5: encrypt(), decrypt() — AES-256-GCM, ChaCha20-Poly1305. Family 6: encrypt_det(), decrypt_det() — AES-256-SIV.
Nonce is generated internally by DRBG on every encrypt call. Caller cannot supply nonce. Output is always a CryptoEnvelope struct.
Index ¶
- Constants
- func Decrypt(key []byte, env *envelope.Envelope, context string, algorithm string) ([]byte, error)
- func DecryptDet(key []byte, ciphertext []byte, context string) ([]byte, error)
- func Encrypt(key []byte, plaintext []byte, context string, algorithm string) (*envelope.Envelope, error)
- func EncryptDet(key []byte, plaintext []byte, context string) ([]byte, error)
Constants ¶
const ( AlgorithmAES256GCM = "AES-256-GCM" AlgorithmChaCha20Poly1305 = "ChaCha20-Poly1305" AlgorithmAES256SIV = "AES-256-SIV" )
Algorithm identifiers.
Variables ¶
This section is empty.
Functions ¶
func Decrypt ¶
Decrypt decrypts an Envelope using key and algorithm. Family 5: decrypt(key []byte, envelope Envelope, context string, algorithm string) ([]byte, error)
func DecryptDet ¶
DecryptDet decrypts AES-256-SIV ciphertext. Family 6: decrypt_det(key []byte, ciphertext []byte, context string) ([]byte, error)
func Encrypt ¶
func Encrypt(key []byte, plaintext []byte, context string, algorithm string) (*envelope.Envelope, error)
Encrypt encrypts plaintext using key and algorithm, returning an Envelope. Family 5: encrypt(key []byte, plaintext []byte, context string, algorithm string) (Envelope, error)
Supported algorithms: AES-256-GCM, ChaCha20-Poly1305. context is bound as AAD and must match at decrypt. Nonce is generated internally.
func EncryptDet ¶
EncryptDet encrypts plaintext using AES-256-SIV (deterministic encryption). Family 6: encrypt_det(key []byte, plaintext []byte, context string) ([]byte, error)
Key must be 64 bytes (two AES-256 keys). Same key + same plaintext + same context always produces same ciphertext.
Types ¶
This section is empty.