Documentation
¶
Index ¶
- func DecryptAESGCM(ciphertext, key []byte) ([]byte, error)
- func DecryptAESGCMWithAAD(ciphertext, key, additionalData []byte) ([]byte, error)
- func DeriveKey(master []byte, info string) ([]byte, error)
- func EncryptAESGCM(plaintext, key []byte) ([]byte, error)
- func EncryptAESGCMWithAAD(plaintext, key, additionalData []byte) ([]byte, error)
- func GenerateRSAKey(bits int) (*rsa.PrivateKey, error)
- func MarshalPrivateKeyPEM(key *rsa.PrivateKey) []byte
- func MarshalPublicKeyPEM(key *rsa.PublicKey) ([]byte, error)
- func ParsePrivateKeyPEM(data []byte) (*rsa.PrivateKey, error)
- func RandomBytes(n int) ([]byte, error)
- func RandomHex(n int) (string, error)
- func RandomString(n int) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptAESGCM ¶
DecryptAESGCM reverses EncryptAESGCM.
func DecryptAESGCMWithAAD ¶
DecryptAESGCMWithAAD reverses EncryptAESGCMWithAAD. It returns an error if the ciphertext was tampered with or additionalData does not match.
func DeriveKey ¶
DeriveKey derives a 32-byte subkey from a master secret for a specific use (e.g. "key-encryption"), using HKDF-SHA256. Domain separation means a single configured secret cannot be silently reused across two cryptographic contexts: the same master yields independent keys for different info labels.
func EncryptAESGCM ¶
EncryptAESGCM encrypts plaintext with AES-256-GCM. The nonce is prepended to the returned ciphertext.
func EncryptAESGCMWithAAD ¶
EncryptAESGCMWithAAD encrypts plaintext with AES-256-GCM, additionally authenticating (but not encrypting) additionalData. Binding AAD — e.g. a key id and use-type — to a stored ciphertext makes it tamper-evident and prevents a row from being swapped for another key's ciphertext: decryption fails unless the exact same AAD is supplied.
func GenerateRSAKey ¶
func GenerateRSAKey(bits int) (*rsa.PrivateKey, error)
func MarshalPrivateKeyPEM ¶
func MarshalPrivateKeyPEM(key *rsa.PrivateKey) []byte
func ParsePrivateKeyPEM ¶
func ParsePrivateKeyPEM(data []byte) (*rsa.PrivateKey, error)
func RandomBytes ¶
func RandomString ¶
Types ¶
This section is empty.