crypto

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 21 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 memguard.LockedBuffer, 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 struct {
	// contains filtered or unexported fields
}

func AssymmetricEncryptionKeyFromBytes

func AssymmetricEncryptionKeyFromBytes(key []byte) (AsymmetricEncryptionKey, error)

func GenerateAsymmetric added in v0.1.4

func GenerateAsymmetric() (AsymmetricEncryptionKey, error)

func (AsymmetricEncryptionKey) PublicBytes added in v0.1.4

func (key AsymmetricEncryptionKey) PublicBytes() []byte

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 {
	AccountKey               *SymmetricEncryptionKey
	AsymmetricEncyryptionKey AsymmetricEncryptionKey
	OrganizationKeys         map[string]string
}

func NewKeyring

func NewKeyring(accountKey *SymmetricEncryptionKey) Keyring

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()

type MasterKey

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

func DeriveMasterKey

func DeriveMasterKey(password memguard.LockedBuffer, 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 SymmetricEncryptionKey

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

func SymmetricEncryptionKeyFromBytes

func SymmetricEncryptionKeyFromBytes(key []byte) (SymmetricEncryptionKey, error)

func (SymmetricEncryptionKey) Bytes

func (key SymmetricEncryptionKey) Bytes() []byte

Jump to

Keyboard shortcuts

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