tlockvault

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenTypeTOTP = iota
	TokenTypeHOTP
)

Token types

Variables

View Source
var ERR_FOLDER_EMPTY = errors.New("Folder name cannot be empty")

Error representing that the folder name is empty

View Source
var ERR_FOLDER_EXISTS = errors.New("Folder with that name already exists")

Error representing that the folder with that name already exists

View Source
var ERR_PASSWORD_INVALID = errors.New("Wrong password, please try again")

Error represents that the password is invalid

View Source
var ERR_TOKEN_EMPTY = errors.New("Secret value cannot be empty")

Error representing that the token secret is empty

View Source
var ERR_TOKEN_EXISTS = errors.New("Token with that secret already exists")

Error representing that the secret already exists

View Source
var ERR_TOKEN_INVALID = errors.New("Secret is invalid, are you sure it is typed correctly?")

Error representing that the secret is invalid

View Source
var ERR_VAULT_DELETED = errors.New("The vault does not exist, did you delete it?")

Error represents the vault may be been moved or deleted

View Source
var SALT_SIZE = 32

Size of the salt

Functions

func Decrypt

func Decrypt(password string, data []byte) ([]byte, error)

Decrypts the given piece of encrypted byte array It returns an error if decryption fails, because of the invalid key

func Encrypt

func Encrypt(password string, data []byte) ([]byte, error)

Encrypts the given piece of byte array

func GenerateKey

func GenerateKey(password string, salt []byte) ([]byte, []byte, error)

Derives a new key from the password to use it for cryptographic purposes using argon2id You can pass salt which will be used, or let the function generate one for you It returns (key, salt, error)

Types

type Folder

type Folder struct {
	// Name of the folder
	Name string

	// Tokens
	Tokens []Token
}

Folder

type Token

type Token struct {
	// Type
	Type TokenType

	// Issuer name
	Issuer string

	// Account name
	Account string

	// Secret
	Secret string

	// Initial counter [only in case of HOTP based tokens]
	InitialCounter int

	// Period [only in case of TOTP based tokens]
	Period int

	// Digits
	Digits int

	// Hasing function
	HashingAlgorithm otp.Algorithm

	// Usage counter [only in case of HOTP based tokens]
	UsageCounter int
}

Token

type TokenType

type TokenType int

Token Type

type Vault

type Vault struct {
	// All the folders and their data
	Folders []Folder
	// contains filtered or unexported fields
}

Vault securely stores all the tokens inside of the file for tlock

func Initialize

func Initialize(at, password string) (*Vault, error)

Initializes a new instance of the vault at the given path

func Load

func Load(path, password string) (*Vault, error)

Loads a new vault instance Loads a vault instance from the given path

func (*Vault) AddFolder

func (vault *Vault) AddFolder(name string) error

Adds a new folder to the vault

func (*Vault) AddToken

func (vault *Vault) AddToken(folder string, uri string) error

Adds a new token to the given folder from token URI

func (*Vault) AddTokenFromToken

func (vault *Vault) AddTokenFromToken(folder string, token Token) error

Adds a new token to the given folder

func (*Vault) ChangePassword

func (vault *Vault) ChangePassword(password string)

Updates the password for the vault

func (*Vault) DeleteFolder

func (vault *Vault) DeleteFolder(name string)

Deletes a folder by its name

func (*Vault) DeleteToken

func (vault *Vault) DeleteToken(folder string, token Token)

Deletes a token in the given folder

func (*Vault) GetTokens

func (vault *Vault) GetTokens(folder string) []Token

Returns all the tokens inside of a folder

func (*Vault) IncreaseCounter

func (vault *Vault) IncreaseCounter(folder string, token Token)

Move a token to the given folder

func (*Vault) MoveFolderDown

func (vault *Vault) MoveFolderDown(name string) bool

Moves the folder down

func (*Vault) MoveFolderUp

func (vault *Vault) MoveFolderUp(name string) bool

Moves the folder up

func (*Vault) MoveToken

func (vault *Vault) MoveToken(token Token, fromFolder, toFolder string)

Move a token to the given folder

func (*Vault) MoveTokenDown

func (vault *Vault) MoveTokenDown(folder string, token Token) bool

Moves the token down

func (*Vault) MoveTokenUp

func (vault *Vault) MoveTokenUp(folder string, token Token) bool

Moves the token up

func (*Vault) PostInit

func (vault *Vault) PostInit()

Stuff to run after the vault is initialized

func (*Vault) RenameFolder

func (vault *Vault) RenameFolder(old, newName string) error

Renames the folder to a new name

func (*Vault) ReplaceToken

func (vault *Vault) ReplaceToken(fromFolder string, token, newToken Token) error

Replace a token in the given folder

func (Vault) ValidateToken

func (vault Vault) ValidateToken(secret string) (string, error)

Validates if the token is fit to be used It is checked on the basis of the fact that it can be used to generate a secret And no other token with the same secret exist

Jump to

Keyboard shortcuts

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