keystore

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPermMode = 0o700

Variables

View Source
var ErrOutOfBound = errors.New("requested key slice is out of the key's bounds")
View Source
var ErrPackageExists = errors.New("this package already exists")

Functions

func MakeKeyName

func MakeKeyName(keyType KeyType, keyDirection KeyDirection) string

func SafeClose

func SafeClose(obj Closable)

Types

type Closable

type Closable interface {
	Close()
}

type Key

type Key struct {
	*gofile.BufferedFile
	KeyType      KeyType
	KeyDirection KeyDirection
	Pos          *KeyPosition
	// contains filtered or unexported fields
}

func NewKey

func NewKey(pack *KeyPack, packId uuid.UUID, keyType KeyType, keyDirection KeyDirection) (key *Key, err error)

func (*Key) ExportShared

func (k *Key) ExportShared(dest string) (err error)

func (*Key) GenerateKey

func (k *Key) GenerateKey(length int64) (err error)

Generates new key parts

func (*Key) ImportShared

func (k *Key) ImportShared(src string) (err error)

func (*Key) Length

func (k *Key) Length() (length int64, err error)

type KeyDirection

type KeyDirection int
const (
	KeyIn KeyDirection = iota
	KeyOut
)

func (KeyDirection) String

func (k KeyDirection) String() string

type KeyPack

type KeyPack struct {
	PackId     uuid.UUID
	IdIn       *Key
	IdOut      *Key
	PayloadIn  *Key
	PayloadOut *Key
	// contains filtered or unexported fields
}

KeyPack contains all the keys needed for a chat - id key, payload key etc

func (*KeyPack) Close

func (p *KeyPack) Close()

func (*KeyPack) ExportShared

func (p *KeyPack) ExportShared(dest string) (err error)

func (*KeyPack) GenerateKey

func (p *KeyPack) GenerateKey(keySize int64) (err error)

generates new key part of the same size for all of the keys

func (*KeyPack) ImportShared

func (p *KeyPack) ImportShared(src string) (err error)

type KeyPosition

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

func NewKeyPosition

func NewKeyPosition(filePath string, perm fs.FileMode) (pos *KeyPosition, err error)

func (*KeyPosition) Take

func (p *KeyPosition) Take(dataSize int64) (pos int64, err error)

Takes the size of data you want to de/encode and returns the position, from which you can use the reserved key part

type KeyStore

type KeyStore struct {
	Packs map[uuid.UUID]*KeyPack
	// contains filtered or unexported fields
}

func NewKeyStore

func NewKeyStore(keystoreDirPath string, bufferSize int64) (store *KeyStore, err error)

func (*KeyStore) AddKeyPack

func (k *KeyStore) AddKeyPack(packId uuid.UUID) (pack *KeyPack, err error)

Creates a new key pack and stores it, so that can be easily accessed later

func (*KeyStore) Close

func (k *KeyStore) Close()

func (*KeyStore) GetKeyPack

func (k *KeyStore) GetKeyPack(packId uuid.UUID) (pack *KeyPack, ok bool)

func (*KeyStore) ImportKeyPack

func (k *KeyStore) ImportKeyPack(src string) (pack *KeyPack, err error)

func (*KeyStore) RemoveKeyPack

func (k *KeyStore) RemoveKeyPack(packId uuid.UUID)

func (*KeyStore) TryDecodePackId

func (k *KeyStore) TryDecodePackId(idKeyPos int64, encId []byte) (id uuid.UUID, ok bool)

Returns right pack id, using its encoded variant

type KeyType

type KeyType int
const (
	KeyPayload KeyType = iota
	KeyId
)

func (KeyType) String

func (k KeyType) String() string

Jump to

Keyboard shortcuts

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