app

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Copyright © 2024 Thomas von Dein

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	ArgonMem      uint32 = 64 * 1024
	ArgonIter     uint32 = 5
	ArgonParallel uint8  = 2
	ArgonSaltLen  int    = 16
	ArgonKeyLen   uint32 = 32
	B64SaltLen    int    = 16 //22
)
View Source
const BucketData string = "data"
View Source
const MaxValueWidth int = 60

Variables

View Source
var File_app_dbentry_proto protoreflect.FileDescriptor

Functions

func AskForPassword added in v0.0.2

func AskForPassword() ([]byte, error)

called from interactive thread, hides input and returns clear text password

func Decrypt added in v0.0.2

func Decrypt(pass []byte, cipherb []byte) ([]byte, error)

Do the reverse

func Encrypt added in v0.0.2

func Encrypt(pass []byte, attr *DbAttr) error

Encrypt clear text given in attr using ChaCha20 and auhtenticate using the mac Poly1305. The cipher text will be put into attr, thus modifying it.

The cipher text consists of: password-salt) + (12 byte nonce + ciphertext + 16 byte mac)

func Exists

func Exists[K comparable, V any](m map[K]V, v K) bool

look if a key in a map exists, generic variant

func GetDbFile added in v0.1.3

func GetDbFile(file string) string

func GetRandom added in v0.0.2

func GetRandom(size int, capacity int) ([]byte, error)

Retrieve a random chunk of given size

Types

type BucketInfo added in v0.0.5

type BucketInfo struct {
	Name     string
	Keys     int
	Size     int
	Sequence uint64
	Stats    bolt.BucketStats
}

type DB

type DB struct {
	Debug  bool
	Dbfile string
	Bucket string
	DB     *bolt.DB
}

func New

func New(file string, bucket string, debug bool) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) Del

func (db *DB) Del(attr *DbAttr) error

func (*DB) Get

func (db *DB) Get(attr *DbAttr) (*DbEntry, error)

func (*DB) Getall added in v0.1.0

func (db *DB) Getall(attr *DbAttr) (DbEntries, error)

func (*DB) Import

func (db *DB) Import(attr *DbAttr) (string, error)

func (*DB) Info added in v0.0.5

func (db *DB) Info() (*DbInfo, error)

func (*DB) List

func (db *DB) List(attr *DbAttr, fulltext bool) (DbEntries, error)

func (*DB) Open

func (db *DB) Open() error

func (*DB) Set

func (db *DB) Set(attr *DbAttr) error

type DbAttr

type DbAttr struct {
	Key       string
	Preview   string
	Val       []byte
	Args      []string
	Tags      []string
	File      string
	Encrypted bool
	Binary    bool

	// conf flags, needed for incoming rest requests
	Fulltext bool
}

func (*DbAttr) GetFileValue

func (attr *DbAttr) GetFileValue() error

func (*DbAttr) ParseKV

func (attr *DbAttr) ParseKV() error

check if value is to be read from a file or stdin, setup preview text according to flags, lowercase key

type DbEntries

type DbEntries []*DbEntry

type DbEntry

type DbEntry struct {
	Id        string                 `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"`
	Key       string                 `protobuf:"bytes,2,opt,name=Key,proto3" json:"Key,omitempty"`
	Preview   string                 `protobuf:"bytes,3,opt,name=Preview,proto3" json:"Preview,omitempty"`
	Tags      []string               `protobuf:"bytes,4,rep,name=Tags,proto3" json:"Tags,omitempty"`
	Created   *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=Created,proto3" json:"Created,omitempty"`
	Size      uint64                 `protobuf:"varint,6,opt,name=Size,proto3" json:"Size,omitempty"`
	Encrypted bool                   `protobuf:"varint,7,opt,name=Encrypted,proto3" json:"Encrypted,omitempty"`
	Binary    bool                   `protobuf:"varint,8,opt,name=Binary,proto3" json:"Binary,omitempty"`
	Value     string                 `protobuf:"bytes,9,opt,name=Value,proto3" json:"Value,omitempty"`
	// contains filtered or unexported fields
}

func (*DbEntry) Descriptor deprecated added in v0.1.0

func (*DbEntry) Descriptor() ([]byte, []int)

Deprecated: Use DbEntry.ProtoReflect.Descriptor instead.

func (*DbEntry) GetBinary added in v0.1.0

func (x *DbEntry) GetBinary() bool

func (*DbEntry) GetCreated added in v0.1.0

func (x *DbEntry) GetCreated() *timestamppb.Timestamp

func (*DbEntry) GetEncrypted added in v0.1.0

func (x *DbEntry) GetEncrypted() bool

func (*DbEntry) GetId added in v0.1.0

func (x *DbEntry) GetId() string

func (*DbEntry) GetKey added in v0.1.0

func (x *DbEntry) GetKey() string

func (*DbEntry) GetPreview added in v0.1.0

func (x *DbEntry) GetPreview() string

func (*DbEntry) GetSize added in v0.1.0

func (x *DbEntry) GetSize() uint64

func (*DbEntry) GetTags added in v0.1.0

func (x *DbEntry) GetTags() []string

func (*DbEntry) GetValue added in v0.1.0

func (x *DbEntry) GetValue() string

func (*DbEntry) ProtoMessage added in v0.1.0

func (*DbEntry) ProtoMessage()

func (*DbEntry) ProtoReflect added in v0.1.0

func (x *DbEntry) ProtoReflect() protoreflect.Message

func (*DbEntry) Reset added in v0.1.0

func (x *DbEntry) Reset()

func (*DbEntry) String added in v0.1.0

func (x *DbEntry) String() string

func (*DbEntry) Taglist added in v0.2.1

func (entry *DbEntry) Taglist() string

type DbInfo added in v0.0.5

type DbInfo struct {
	Buckets []BucketInfo
	Path    string
}

type DbTag

type DbTag struct {
	Keys []string `json:"key"`
}

type Key added in v0.0.2

type Key struct {
	Salt []byte
	Key  []byte
}

func DeriveKey added in v0.0.2

func DeriveKey(password []byte, salt []byte) (*Key, error)

We're using the Argon2id key derivation algorithm to derive a secure key from the given password. This is important, because users might use unsecure passwords. The resulting encrypted data might of course easily be decrypted using brute force methods if a weak password was used, but that would cost, because of the key derivation. It does several rounds of hash calculations which take a considerable amount of cpu time. For our legal user that's no problem because it's being executed only once, but an attacker has to do it in a forever loop, which will take a lot of time.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳