crypto

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHash         = xerror.InvalidInput(xerror.PasswordHash)
	ErrIncompatibleVersion = xerror.Unsupported(xerror.PasswordHash)
)
View Source
var (
	ErrCredentialKeyUnavailable = xerror.New(xerror.KindInternal, "CREDENTIAL_KEY_UNAVAILABLE", "credential encryption key unavailable")
	ErrCredentialCiphertext     = xerror.New(xerror.KindInternal, "CREDENTIAL_CIPHERTEXT_INVALID", "credential ciphertext invalid")
	ErrCredentialScope          = xerror.New(xerror.KindInternal, "CREDENTIAL_SCOPE_INVALID", "credential encryption scope invalid")
	ErrCredentialKeyring        = xerror.New(xerror.KindInternal, "CREDENTIAL_KEYRING_INVALID", "credential encryption keyring invalid")
)

Functions

This section is empty.

Types

type AES256

type AES256 interface {
	Encrypt(plaintext []byte) ([]byte, error)
	Decrypt(ciphertext []byte) ([]byte, error)
}

AES256 is the interface for AES-256-GCM encryption/decryption.

func NewAES256

func NewAES256(key []byte) (AES256, error)

NewAES256 creates a new AES256 encrypter with the given key. The key must be 32 bytes (256 bits).

type CredentialCipher

type CredentialCipher interface {
	Seal(CredentialScope, []byte) ([]byte, error)
	Open(CredentialScope, []byte) ([]byte, error)
}

CredentialCipher protects persisted product secrets. Queued email tokens and short-lived execution envelopes have separate keys and lifecycles.

type CredentialKeyring

type CredentialKeyring struct {
	// contains filtered or unexported fields
}

CredentialKeyring encrypts with one key and decrypts with explicitly retained keys. The optional legacy key reads pre-versioning records only.

func NewCredentialKeyring

func NewCredentialKeyring(current string, keys map[string][]byte, legacyKey []byte) (*CredentialKeyring, error)

func (*CredentialKeyring) CurrentKeyID

func (r *CredentialKeyring) CurrentKeyID() string

func (*CredentialKeyring) Open

func (r *CredentialKeyring) Open(scope CredentialScope, ciphertext []byte) ([]byte, error)

func (*CredentialKeyring) Rekey

func (r *CredentialKeyring) Rekey(scope CredentialScope, ciphertext []byte) ([]byte, bool, error)

Rekey authenticates even current-key records. Unchanged records retain their original bytes so a resumable sweep can skip writes and preserve revisions.

func (*CredentialKeyring) Seal

func (r *CredentialKeyring) Seal(scope CredentialScope, plaintext []byte) ([]byte, error)

type CredentialScope

type CredentialScope struct {
	Tenant        string
	Resource      string
	Purpose       string
	SchemaVersion uint32
}

CredentialScope comes from the expected database record, never the ciphertext. SchemaVersion identifies the plaintext contract independently of the cipher format.

type Hasher

type Hasher interface {
	Hash(input string) (string, error)
	CompareHash(input, hash string) (bool, error)
}

Hasher is the interface that wraps the basic Hash and Check methods

func NewArgon2

func NewArgon2() Hasher

func NewArgon2WithParams

func NewArgon2WithParams(
	memory, iterations uint32,
	parallelism uint8,
	saltLength, keyLength uint32,
) Hasher

NewArgon2WithParams creates a new Argon2 hasher with custom parameters

Jump to

Keyboard shortcuts

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