Documentation
¶
Overview ¶
Package crypto provides error constructors for encryption and key management.
Index ¶
- func CiphertextTooShort() error
- func CreateCipher(cause error) error
- func CreateGCM(cause error) error
- func Decrypt(cause error) error
- func DecryptFailed() error
- func EncryptFailed(cause error) error
- func GenerateKey(cause error) error
- func GenerateNonce(cause error) error
- func InvalidKeySize(got, want int) error
- func LoadKey(cause error, keyPath string) error
- func MkdirKeyDir(cause error) error
- func NoKeyAt(path string) error
- func ReadKey(cause error) error
- func SaveKey(cause error) error
- func WriteKey(cause error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CiphertextTooShort ¶
func CiphertextTooShort() error
CiphertextTooShort returns an error when ciphertext is shorter than the nonce size.
Returns:
- error: "ciphertext too short"
func CreateCipher ¶
CreateCipher wraps a failure to create an AES cipher.
Parameters:
- cause: the underlying crypto error.
Returns:
- error: "create cipher: <cause>"
func CreateGCM ¶
CreateGCM wraps a failure to create a GCM instance.
Parameters:
- cause: the underlying crypto error.
Returns:
- error: "create GCM: <cause>"
func Decrypt ¶
Decrypt wraps a decryption failure with cause.
Parameters:
- cause: the underlying decryption error.
Returns:
- error: "decrypt: <cause>"
func DecryptFailed ¶
func DecryptFailed() error
DecryptFailed returns an error indicating decryption failure.
Returns:
- error: "decryption failed: wrong key?"
func EncryptFailed ¶
EncryptFailed wraps an encryption failure.
Parameters:
- cause: the underlying error from crypto.Encrypt.
Returns:
- error: "encrypt: <cause>"
func GenerateKey ¶
GenerateKey wraps a failure to generate a random key.
Parameters:
- cause: the underlying IO error.
Returns:
- error: "generate key: <cause>"
func GenerateNonce ¶
GenerateNonce wraps a failure to generate a random nonce.
Parameters:
- cause: the underlying IO error.
Returns:
- error: "generate nonce: <cause>"
func InvalidKeySize ¶
InvalidKeySize returns an error when a key file has the wrong size.
Parameters:
- got: actual key size in bytes.
- want: expected key size in bytes.
Returns:
- error: "invalid key size: got N bytes, want M"
func LoadKey ¶
LoadKey classifies a key-loading failure.
If the underlying error is os.ErrNotExist, returns NoKeyAt(keyPath). Otherwise wraps the cause as a generic load-key error.
Parameters:
- cause: the underlying error from crypto.LoadKey
- keyPath: the resolved key path that was checked
Returns:
- error: NoKeyAt or "load key: <cause>"
func MkdirKeyDir ¶
MkdirKeyDir wraps a failure to create the key directory.
Parameters:
- cause: the underlying OS error
Returns:
- error: "failed to create key dir: <cause>"
func NoKeyAt ¶
NoKeyAt returns an error indicating a missing encryption key.
Parameters:
- path: the resolved key path that was checked.
Returns:
- error: "encrypted scratchpad found but no key at <path>"
func ReadKey ¶
ReadKey wraps a failure to read a key file.
Parameters:
- cause: the underlying read error.
Returns:
- error: "read key: <cause>"
Types ¶
This section is empty.