identity

package
v0.0.0-...-4f831cf Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(ciphertext, passphrase []byte) ([]byte, error)

func Encrypt

func Encrypt(data []byte, encrAlg EncrAlg, name string,
	passphrase []byte, kdfAlg KDFAlg) ([]byte, error)

Types

type EncrAlg

type EncrAlg int
const (
	EncrAES128GCM EncrAlg = 0
)

func (EncrAlg) KeyLen

func (e EncrAlg) KeyLen() int

func (EncrAlg) String

func (e EncrAlg) String() string

type EncryptedKey

type EncryptedKey struct {
	Magic     uint32
	Version   byte
	Name      string
	Salt      []byte
	KDFAlg    KDFAlg
	EncrAlg   EncrAlg
	Encrypted []byte
}

type KDFAlg

type KDFAlg int
const (
	KDFPBKDF24096SHA256 KDFAlg = 0
)

func (KDFAlg) String

func (k KDFAlg) String() string

type Key

type Key interface {
	Name() string
	Type() KeyType
	Size() int
	ID() string
	Marshal() ([]byte, error)
}

func Unmarshal

func Unmarshal(data []byte) (Key, error)

type KeyData

type KeyData struct {
	Name string
	Type KeyType
	Data []byte
}

type KeyInfo

type KeyInfo struct {
	ID   string
	Name string
}

type KeyType

type KeyType int
const (
	KeyRSAPrivateKey KeyType = 0
	KeyRSAPublicKey          = 1
)

func (KeyType) String

func (t KeyType) String() string

type PrivateKey

type PrivateKey interface {
	Key
	Decrypt(ciphertext []byte) ([]byte, error)
	PublicKey() PublicKey
}

func GetNull

func GetNull() (PrivateKey, error)

func NewRSAKey

func NewRSAKey(name string, bits int) (PrivateKey, error)

func UnmarshalPrivateKey

func UnmarshalPrivateKey(data []byte) (PrivateKey, error)

func UnmarshalRSAPrivateKey

func UnmarshalRSAPrivateKey(data *KeyData) (PrivateKey, error)

type PublicKey

type PublicKey interface {
	Key
	Encrypt(msg []byte) ([]byte, error)
}

func UnmarshalPublicKey

func UnmarshalPublicKey(data []byte) (PublicKey, error)

func UnmarshalRSAPublicKey

func UnmarshalRSAPublicKey(data *KeyData) (PublicKey, error)

type Storage

type Storage struct {
	Dir string
}

func NewStorage

func NewStorage(user *user.User) *Storage

func (*Storage) List

func (s *Storage) List() ([]KeyInfo, error)

func (*Storage) Load

func (s *Storage) Load(id string, passphrase []byte) (Key, error)

func (*Storage) Open

func (s *Storage) Open() error

func (*Storage) Save

func (s *Storage) Save(key Key, passphrase []byte) error

Jump to

Keyboard shortcuts

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