geheim

package module
v1.22.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2022 License: MIT Imports: 23 Imported by: 1

README

geheim

Go Reference

the cipher utility

Documentation

Index

Constants

View Source
const (
	DefaultCipher = AES_256
	DefaultMode   = CTR
	DefaultKDF    = Argon2
	DefaultMAC    = HMAC
	DefaultMD     = SHA_256
	DefaultSec    = 10
)
View Source
const (
	MinSec = 0
	MaxSec = 20
)
View Source
const (
	CipherDesc = "cipher"
	ModeDesc   = "stream mode"
	KDFDesc    = "key derivation"
	MACDesc    = "message authentication"
	MDDesc     = "message digest"
	SecDesc    = "security level"
)
View Source
const HeaderVersion = headerVer7

Variables

View Source
var CipherNames = map[Cipher]string{
	AES_256:  "AES-256",
	ChaCha20: "ChaCha20",
}
View Source
var ErrSigVer = errors.New("signature verification failed")
View Source
var KDFNames = map[KDF]string{
	PBKDF2: "PBKDF2",
	Argon2: "Argon2",
	Scrypt: "Scrypt",
}
View Source
var MACNames = map[MAC]string{
	HMAC: "HMAC",
}
View Source
var MDNames = map[MD]string{
	SHA3_224:    "SHA3-224",
	SHA3_256:    "SHA3-256",
	SHA3_384:    "SHA3-384",
	SHA3_512:    "SHA3-512",
	SHA_224:     "SHA-224",
	SHA_256:     "SHA-256",
	SHA_384:     "SHA-384",
	SHA_512:     "SHA-512",
	SHA_512_224: "SHA-512/224",
	SHA_512_256: "SHA-512/256",
	BLAKE2b_256: "BLAKE2b-256",
	BLAKE2b_384: "BLAKE2b-384",
	BLAKE2b_512: "BLAKE2b-512",
}
View Source
var ModeNames = map[Mode]string{
	CTR: "CTR",
	CFB: "CFB",
	OFB: "OFB",
}

Functions

func Decrypt

func Decrypt(r io.Reader, w io.Writer, pass []byte, printFn PrintFunc) (sign []byte, err error)

func DecryptVerify added in v1.3.1

func DecryptVerify(r io.Reader, w io.Writer, pass []byte, signex []byte, printFn PrintFunc) (sign []byte, err error)

func Encrypt

func Encrypt(r io.Reader, w io.Writer, pass []byte, cipher Cipher, mode Mode, kdf KDF, mac MAC, md MD, sec int, printFn PrintFunc) (sign []byte, err error)

func FormatSize added in v1.6.10

func FormatSize(n int64) string

func GetCipherString added in v1.4.0

func GetCipherString() string

func GetKDFString added in v1.4.0

func GetKDFString() string

func GetMACString added in v1.4.0

func GetMACString() string

func GetMDString added in v1.4.0

func GetMDString() string

func GetModeString added in v1.3.0

func GetModeString() string

func GetSecIterMemory added in v1.5.3

func GetSecIterMemory(sec int) (int, int64, int)

func Validate added in v1.6.10

func Validate(cipher Cipher, mode Mode, kdf KDF, mac MAC, md MD, sec int) (err error)

Types

type Cipher added in v1.4.0

type Cipher uint8
const (
	AES_256 Cipher = 1 + iota
	ChaCha20
)
type Header interface {
	Version() int
	Read(io.Reader) error
	Write(io.Writer) error
	Get() (cipher Cipher, mode Mode, kdf KDF, mac MAC, md MD, sec int, salt, iv []byte)
	Set(cipher Cipher, mode Mode, kdf KDF, mac MAC, md MD, sec int, salt, iv []byte)
}

type KDF added in v1.4.0

type KDF uint8
const (
	PBKDF2 KDF = 1 + iota
	Argon2
	Scrypt
)

type MAC added in v1.4.0

type MAC uint8
const (
	HMAC MAC = 1 + iota
)

type MD added in v1.4.0

type MD uint8
const (
	SHA3_224 MD = 1 + iota
	SHA3_256
	SHA3_384
	SHA3_512
	SHA_224
	SHA_256
	SHA_384
	SHA_512
	SHA_512_224
	SHA_512_256
	BLAKE2b_256
	BLAKE2b_384
	BLAKE2b_512
)

type Meta added in v1.6.4

type Meta struct {
	Padding uint32
	Version uint32
}

func NewMeta added in v1.6.4

func NewMeta(version uint32) *Meta

func (*Meta) Header added in v1.6.4

func (m *Meta) Header() (Header, error)

func (*Meta) Legacy added in v1.22.0

func (m *Meta) Legacy() bool

func (*Meta) Read added in v1.6.4

func (m *Meta) Read(r io.Reader) error

func (*Meta) Write added in v1.6.4

func (m *Meta) Write(w io.Writer) error

type Mode

type Mode uint8
const (
	CTR Mode = 1 + iota
	CFB
	OFB
)

type PrintFunc

type PrintFunc func(version int, cipher Cipher, mode Mode, kdf KDF, mac MAC, md MD, sec int, pass, salt, iv, keyCipher, keyMAC []byte) error

func NewPrintFunc added in v1.6.11

func NewPrintFunc(w io.Writer) PrintFunc

type ProgressWriter added in v1.19.1

type ProgressWriter struct {
	TotalBytes int64
	// contains filtered or unexported fields
}

func (*ProgressWriter) Progress added in v1.19.1

func (w *ProgressWriter) Progress(done <-chan struct{}, d time.Duration)

func (*ProgressWriter) Write added in v1.19.1

func (w *ProgressWriter) Write(p []byte) (n int, err error)

type StreamMode added in v1.22.0

type StreamMode func(cipher.Block, []byte) cipher.Stream

Directories

Path Synopsis
cmd
ghm
xp

Jump to

Keyboard shortcuts

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