encryption

package
v0.0.0-...-ad95247 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlgorithmArgon2ID          = "argon2id"
	AlgorithmPbkdf2            = "pbkdf2"
	AlgorithmNone              = "none"
	AlgorithmXChaCha20Poly1305 = "xchacha20-poly1305"
	AlgorithmAesGcm            = "aes-gcm"
)

Variables

View Source
var DefaultArgon2Params = Argon2Params{
	Iterations: 3,
	Memory:     64 * 1024,
	Threads:    2,
}
View Source
var DefaultPbkdf2Params = Pbkdf2Params{
	Iterations: 210_000,
}
View Source
var ErrNoSealer = errors.New("can't seal identity without sealer")

Functions

func CipherTextDecoder

func CipherTextDecoder() ports.CipherTextDecoder

func GenericIdentityOpener

func GenericIdentityOpener() ports.IdentityOpener

func GenericKeyValidator

func GenericKeyValidator() ports.KeyValidator

Types

type AesGcm

type AesGcm struct {
}

func (AesGcm) Algorithm

func (AesGcm) Algorithm() string

func (AesGcm) KeyLength

func (g AesGcm) KeyLength() int

func (AesGcm) Open

func (AesGcm) Open(sealed, key, nonce []byte) (plainText []byte, err error)

func (AesGcm) Seal

func (AesGcm) Seal(plainText, key []byte) (sealed, nonce []byte, err error)

type Argon2IDKeyDeriver

type Argon2IDKeyDeriver struct {
	Argon2Params
}

func (*Argon2IDKeyDeriver) Algorithm

func (*Argon2IDKeyDeriver) Algorithm() string

func (*Argon2IDKeyDeriver) GenerateKey

func (a *Argon2IDKeyDeriver) GenerateKey(password, existingSalt []byte, keyLength int) (key, salt []byte)

type Argon2Params

type Argon2Params struct {
	Iterations uint32
	Memory     uint32
	Threads    uint8
}

func (*Argon2Params) MarshalText

func (p *Argon2Params) MarshalText() (text []byte, err error)

MarshalText implements encoding.TextMarshaler.

func (*Argon2Params) UnmarshalText

func (p *Argon2Params) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type CipherTextDecoderFunc

type CipherTextDecoderFunc func(text []byte) (*ports.CipherTextDecoderResult, error)

func (CipherTextDecoderFunc) Decode

type DefaultCipherTextEncoder

type DefaultCipherTextEncoder struct {
}

func (DefaultCipherTextEncoder) EncodeCipherText

func (DefaultCipherTextEncoder) EncodeCipherText(cipherText, salt, nonce []byte, deriver ports.KeyDeriver, cipher ports.Cipher) []byte

func (DefaultCipherTextEncoder) EncodeHash

func (DefaultCipherTextEncoder) EncodeHash(hash, salt []byte, deriver ports.KeyDeriver) []byte

type GenericIdentitySealer

type GenericIdentitySealer struct {
	Deriver ports.KeyDeriver
	Cipher  ports.Cipher
	Encoder ports.CipherTextEncoder
}

func NewGenericIdentitySealer

func NewGenericIdentitySealer(
	sealer ports.Cipher,
	deriver ports.KeyDeriver,
	encoder ports.CipherTextEncoder,
) (*GenericIdentitySealer, error)

func (GenericIdentitySealer) KeyLength

func (g GenericIdentitySealer) KeyLength() int

func (GenericIdentitySealer) SealIdentity

func (g GenericIdentitySealer) SealIdentity(identity *age.X25519Identity, key []byte) ([]byte, error)

type IdentityOpenerFunc

type IdentityOpenerFunc func(cipherText, key []byte) (*age.X25519Identity, error)

func (IdentityOpenerFunc) OpenIdentity

func (f IdentityOpenerFunc) OpenIdentity(cipherText, key []byte) (*age.X25519Identity, error)

type KeyValidatorFunc

type KeyValidatorFunc func(hashed, key []byte, keyLength int) error

func (KeyValidatorFunc) Validate

func (f KeyValidatorFunc) Validate(hashed, key []byte, keyLength int) error

type Pbkdf2KeyDeriver

type Pbkdf2KeyDeriver struct {
	Pbkdf2Params
}

func (*Pbkdf2KeyDeriver) Algorithm

func (*Pbkdf2KeyDeriver) Algorithm() string

func (*Pbkdf2KeyDeriver) GenerateKey

func (p *Pbkdf2KeyDeriver) GenerateKey(password, existingSalt []byte, keyLength int) (key, salt []byte)

type Pbkdf2Params

type Pbkdf2Params struct {
	Iterations int
}

func (*Pbkdf2Params) MarshalText

func (p *Pbkdf2Params) MarshalText() (text []byte, err error)

func (*Pbkdf2Params) UnmarshalText

func (p *Pbkdf2Params) UnmarshalText(text []byte) error

type XChaCha20Poly1305

type XChaCha20Poly1305 struct {
}

func (XChaCha20Poly1305) Algorithm

func (XChaCha20Poly1305) Algorithm() string

func (XChaCha20Poly1305) KeyLength

func (p XChaCha20Poly1305) KeyLength() int

func (XChaCha20Poly1305) Open

func (XChaCha20Poly1305) Open(sealed, key, nonce []byte) (plainText []byte, err error)

func (XChaCha20Poly1305) Seal

func (XChaCha20Poly1305) Seal(plainText, key []byte) (sealed, nonce []byte, err error)

Jump to

Keyboard shortcuts

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