Documentation
¶
Overview ¶
Package secretdropvault provides AES-256-GCM encryption with HKDF-SHA256 key derivation. It is the cryptographic engine behind SecretDrop — a one-time secret sharing service.
Security model:
- A random 256-bit key is generated per secret.
- HKDF-SHA256 derives a unique encryption key per recipient (bound to their email).
- AES-256-GCM provides authenticated encryption with a random nonce.
- The random key is carried only in the URL fragment (never sent to the server).
- Email addresses are stored as SHA-256 hashes (never in plaintext).
Index ¶
- Constants
- func DecodeKey(encoded string) ([]byte, error)
- func Decrypt(key, ciphertext, nonce []byte) ([]byte, error)
- func DeriveKey(randomKey []byte, info string) ([]byte, error)
- func EncodeKey(key []byte) string
- func Encrypt(key, plaintext []byte) (ciphertext, nonce []byte, err error)
- func GenerateRandomKey() ([]byte, error)
- func GenerateToken() (string, error)
- func HashEmail(email string) string
Constants ¶
const ( // KeySize is the AES-256 key size in bytes. KeySize = 32 // TokenSize is the number of random bytes used to generate a token. TokenSize = 16 )
Variables ¶
This section is empty.
Functions ¶
func DeriveKey ¶
DeriveKey uses HKDF-SHA256 to derive a KeySize-byte key from the input key material and an info string (typically the recipient's email address).
func Encrypt ¶
Encrypt encrypts plaintext using AES-256-GCM with the given key. Returns ciphertext (with appended authentication tag) and nonce.
func GenerateRandomKey ¶
GenerateRandomKey creates a cryptographically secure random key of KeySize bytes.
func GenerateToken ¶
GenerateToken creates a random token encoded as base64url (no padding). The token is TokenSize random bytes, base64url-encoded.
Types ¶
This section is empty.