crypto

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptWith

func DecryptWith(s EncString, key SymmetricEncryptionKey) ([]byte, error)

func DecryptWithAsymmetric

func DecryptWithAsymmetric(s []byte, asymmetrickey AsymmetricEncryptionKey) ([]byte, error)

func EncryptWithAsymmetric

func EncryptWithAsymmetric(s []byte, asymmbetrickey AsymmetricEncryptionKey) ([]byte, error)

func InitKeyringFromMasterKey

func InitKeyringFromMasterKey(keyring *Keyring, accountKey EncString, accountPrivateKey EncString, orgKeys map[string]string, masterKey MasterKey) error

func InitKeyringFromMasterPassword

func InitKeyringFromMasterPassword(keyring *Keyring, accountKey EncString, accountPrivateKey EncString, orgKeys map[string]string, password []byte, email string, kdfConfig KDFConfig) error

func InitKeyringFromUserSymmetricKey

func InitKeyringFromUserSymmetricKey(keyring *Keyring, accountSymmetricKey SymmetricEncryptionKey, accountPrivateKey EncString, orgKeys map[string]string) error

Types

type AsymmetricEncryptionKey

type AsymmetricEncryptionKey interface {
	PublicBytes() []byte
	PrivateBytes() ([]byte, error)
}

func GenerateAsymmetric added in v0.1.4

func GenerateAsymmetric(useMemguard bool) (AsymmetricEncryptionKey, error)

type EncString

type EncString struct {
	Type        EncStringType
	IV, CT, MAC []byte
}

func EncryptWith

func EncryptWith(data []byte, typ EncStringType, key SymmetricEncryptionKey) (EncString, error)

func (EncString) IsNull

func (s EncString) IsNull() bool

func (EncString) MarshalText

func (s EncString) MarshalText() ([]byte, error)

func (*EncString) UnmarshalText

func (s *EncString) UnmarshalText(data []byte) error

type EncStringType

type EncStringType int
const (
	AesCbc256_B64                     EncStringType = 0
	AesCbc128_HmacSha256_B64          EncStringType = 1
	AesCbc256_HmacSha256_B64          EncStringType = 2
	Rsa2048_OaepSha256_B64            EncStringType = 3
	Rsa2048_OaepSha1_B64              EncStringType = 4
	Rsa2048_OaepSha256_HmacSha256_B64 EncStringType = 5
	Rsa2048_OaepSha1_HmacSha256_B64   EncStringType = 6
)

func (EncStringType) HasMAC

func (t EncStringType) HasMAC() bool

type KDFConfig

type KDFConfig struct {
	Type        KDFType
	Iterations  uint32
	Memory      uint32
	Parallelism uint32
}

type KDFType

type KDFType int
const (
	PBKDF2   KDFType = 0
	Argon2ID KDFType = 1
)

type Keyring

type Keyring struct {
	AsymmetricEncyryptionKey AsymmetricEncryptionKey
	IsMemguard               bool
	OrganizationKeys         map[string]string
	// contains filtered or unexported fields
}

func NewMemguardKeyring added in v0.2.0

func NewMemguardKeyring(accountKey *MemguardSymmetricEncryptionKey) Keyring

func NewMemoryKeyring added in v0.2.0

func NewMemoryKeyring(accountKey *MemorySymmetricEncryptionKey) Keyring

func (*Keyring) GetAccountKey added in v0.2.0

func (keyring *Keyring) GetAccountKey() SymmetricEncryptionKey

func (*Keyring) GetSymmetricKeyForOrganization

func (keyring *Keyring) GetSymmetricKeyForOrganization(uuid string) (SymmetricEncryptionKey, error)

func (Keyring) IsLocked

func (keyring Keyring) IsLocked() bool

func (*Keyring) Lock

func (keyring *Keyring) Lock()

func (*Keyring) UnlockWithAccountKey added in v0.2.0

func (keyring *Keyring) UnlockWithAccountKey(accountKey SymmetricEncryptionKey)

type MasterKey

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

func DeriveMasterKey

func DeriveMasterKey(password []byte, email string, kdfConfig KDFConfig) (MasterKey, error)

func MasterKeyFromBytes added in v0.1.4

func MasterKeyFromBytes(key []byte) MasterKey

func (MasterKey) GetBytes

func (masterKey MasterKey) GetBytes() []byte

type MemguardAsymmetricEncryptionKey added in v0.2.0

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

func MemguardAssymmetricEncryptionKeyFromBytes added in v0.2.0

func MemguardAssymmetricEncryptionKeyFromBytes(key []byte) (MemguardAsymmetricEncryptionKey, error)

func (MemguardAsymmetricEncryptionKey) PrivateBytes added in v0.2.0

func (key MemguardAsymmetricEncryptionKey) PrivateBytes() ([]byte, error)

func (MemguardAsymmetricEncryptionKey) PublicBytes added in v0.2.0

func (key MemguardAsymmetricEncryptionKey) PublicBytes() []byte

type MemguardSymmetricEncryptionKey added in v0.2.0

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

func MemguardSymmetricEncryptionKeyFromBytes added in v0.2.0

func MemguardSymmetricEncryptionKeyFromBytes(key []byte) (MemguardSymmetricEncryptionKey, error)

func (MemguardSymmetricEncryptionKey) Bytes added in v0.2.0

func (key MemguardSymmetricEncryptionKey) Bytes() []byte

func (MemguardSymmetricEncryptionKey) EncryptionKeyBytes added in v0.2.0

func (key MemguardSymmetricEncryptionKey) EncryptionKeyBytes() ([]byte, error)

func (MemguardSymmetricEncryptionKey) MacKeyBytes added in v0.2.0

func (key MemguardSymmetricEncryptionKey) MacKeyBytes() ([]byte, error)

type MemoryAsymmetricEncryptionKey added in v0.2.0

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

func MemoryAssymmetricEncryptionKeyFromBytes added in v0.2.0

func MemoryAssymmetricEncryptionKeyFromBytes(key []byte) (MemoryAsymmetricEncryptionKey, error)

func (MemoryAsymmetricEncryptionKey) PrivateBytes added in v0.2.0

func (key MemoryAsymmetricEncryptionKey) PrivateBytes() ([]byte, error)

func (MemoryAsymmetricEncryptionKey) PublicBytes added in v0.2.0

func (key MemoryAsymmetricEncryptionKey) PublicBytes() []byte

type MemorySymmetricEncryptionKey added in v0.2.0

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

func MemorySymmetricEncryptionKeyFromBytes added in v0.2.0

func MemorySymmetricEncryptionKeyFromBytes(key []byte) (MemorySymmetricEncryptionKey, error)

func (MemorySymmetricEncryptionKey) Bytes added in v0.2.0

func (key MemorySymmetricEncryptionKey) Bytes() []byte

func (MemorySymmetricEncryptionKey) EncryptionKeyBytes added in v0.2.0

func (key MemorySymmetricEncryptionKey) EncryptionKeyBytes() ([]byte, error)

func (MemorySymmetricEncryptionKey) MacKeyBytes added in v0.2.0

func (key MemorySymmetricEncryptionKey) MacKeyBytes() ([]byte, error)

type SymmetricEncryptionKey

type SymmetricEncryptionKey interface {
	Bytes() []byte
	EncryptionKeyBytes() ([]byte, error)
	MacKeyBytes() ([]byte, error)
}

Jump to

Keyboard shortcuts

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