crypto

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package crypto holds envelope encryption for mailbox credentials and password hashing.

Index

Constants

This section is empty.

Variables

View Source
var ErrDecrypt = errors.New("decrypt failed")

ErrDecrypt means a ciphertext was tampered with, moved between rows, or sealed under another key.

Functions

func HashPassword

func HashPassword(password string) (string, error)

HashPassword returns an argon2id hash in the standard encoded form.

func LoadMasterKey

func LoadMasterKey(value, keyFile, dataDir string) ([]byte, error)

LoadMasterKey returns the key-encryption key: from the base64 value, else from keyFile, else from <dataDir>/master.key, which is generated (mode 0600) on first run.

func Open

func Open(master []byte, rowID int64, secretEnc, dekEnc []byte) ([]byte, error)

Open reverses Seal. It returns ErrDecrypt for any mismatch of key, row or ciphertext.

func Seal

func Seal(master []byte, rowID int64, plaintext []byte) (secretEnc, dekEnc []byte, err error)

Seal encrypts plaintext under a fresh data key and wraps that key with the master key. rowID is bound into both ciphertexts, so they cannot be swapped between rows.

func VerifyPassword

func VerifyPassword(encoded, password string) bool

VerifyPassword reports whether password matches an encoded hash, in constant time.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL