crypt

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const KeySize = 4096

Variables

This section is empty.

Functions

func CreateFile added in v0.7.3

func CreateFile(path string) (dbFile *os.File, err error)

CreateFiles creates the temporary directory and database file

func Decrypt

func Decrypt(data []byte, priv *rsa.PrivateKey) ([]byte, error)

DEPRECATED: use age instead Decrypt decrypts the given data using the given private key

func GetPrivateKeyPath

func GetPrivateKeyPath(conf *cfg.Config) (string, error)

func GetPublicKeyPath

func GetPublicKeyPath(conf *cfg.Config) (string, error)

GetPublicKeyPath returns the absolute path to the public key

Types

type Keys

type Keys struct {
	Identifier uuid.UUID
	Private    *age.X25519Identity
	Public     *age.X25519Recipient
}

Keys holds the information used for volatile identification of a particular user

func GenerateKeys

func GenerateKeys() (k Keys, e error)

@function GenerateKeys @description Generates a (volatile) public and private key pair to be used for intermediary encryption in the frontend @returns Keys, error NOTE: should probably also expect some persistent key based identification to be passed as a parameter to make impersonation harder

type Storage added in v0.7.3

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

cryptoStorage is a helper struct to create an instance of SQLite-cypher that implements fiber.Storage interface.

func CreateStorage added in v0.7.3

func CreateStorage(dbFile, secret string) (conn *Storage, err error)

CreateStorage creates a SQLite-cypher encrypted storage for X25519 keys It needs to be called inside main function so that the temporary directory it uses is not discarded upon return.

func (*Storage) Close added in v0.7.3

func (s *Storage) Close() error

Close closes the storage.

func (*Storage) Conn added in v0.7.3

func (s *Storage) Conn() *sql.DB

func (*Storage) Delete added in v0.7.3

func (s *Storage) Delete(key string) error

Delete deletes a key in the storage.

func (*Storage) Get added in v0.7.3

func (s *Storage) Get(key string) ([]byte, error)

Get returns the value of a key in the storage.

func (*Storage) Reset added in v0.7.3

func (s *Storage) Reset() error

Reset resets the storage, removing all keys.

func (*Storage) Set added in v0.7.3

func (s *Storage) Set(key string, val []byte, exp time.Duration) error

Set sets the value of a key in the storage. If the key does not exist, it will be created.

Jump to

Keyboard shortcuts

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