cryptos

package
v0.0.0-...-45c2084 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AedCipherUnknown = AedCipherByte(iota)
	AES256GCM
)
View Source
const (
	DeriveUnknown = DeriveByte(iota)
	Pbkdf2Sha256
)
View Source
const (
	HashUnknown = HashByte(iota)
	SHA256
	SHA512
)
View Source
const (
	MacUnknown = MacByte(iota)
	HmacSha256
)
View Source
const (
	PubCipherUnknown = PubCipherByte(iota)
	Rsa4096Sha256
	Rsa2048Sha256
	Rsa1024Sha256
)

Variables

View Source
var (
	ErrBrokenSize      = errors.New("ERR_BROKEN_SIZE")
	ErrBrokenSignature = errors.New("ERR_BROKEN_SIGNATURE")
)

Functions

func AedCipherSizes

func AedCipherSizes(byte AedCipherByte) (key, iv, block int)

func ConstantTimeByteEq

func ConstantTimeByteEq(a, b []byte) bool

func DeriveSaltSize

func DeriveSaltSize(byte DeriveByte) int

func HashCrypto

func HashCrypto(byte HashByte) crypto.Hash

func HashSize

func HashSize(byte HashByte) int

func MacSize

func MacSize(byte MacByte) int

func SecureRand

func SecureRand(buff []byte) error

func SecureRandSize

func SecureRandSize(size int) ([]byte, error)

Types

type AedCipherByte

type AedCipherByte byte

type AesAedCipher

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

func (*AesAedCipher) Decrypt

func (a *AesAedCipher) Decrypt(input, addon []byte) ([]byte, error)

Decrypt decrypts & verifies of data

func (*AesAedCipher) Encrypt

func (a *AesAedCipher) Encrypt(input, addon []byte) []byte

Encrypt encrypts and signs data

func (*AesAedCipher) Init

func (a *AesAedCipher) Init(key, iv []byte) (IAedCipher, error)

type Derive

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

func (*Derive) Derive

func (d *Derive) Derive(password, salt []byte, iterations, len int) []byte

Derive implements IDerive

type DeriveByte

type DeriveByte byte

type DeriveFN

type DeriveFN func(password, salt []byte, iterations, keyLen int, h func() hash.Hash) []byte

type Hash

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

func (*Hash) Byte

func (h *Hash) Byte() HashByte

func (*Hash) HashSum

func (h *Hash) HashSum(input []byte) []byte

func (*Hash) New

func (h *Hash) New() hash.Hash

type HashByte

type HashByte byte

type IAedCipher

type IAedCipher interface {
	Encrypt(plaintext, addon []byte) []byte
	Decrypt(ciphertext, addon []byte) ([]byte, error)
	Init(key, iv []byte) (IAedCipher, error)
}

IAedCipher interface for block cypher with authentication algorithms

func NewAedCipher

func NewAedCipher(byte AedCipherByte) IAedCipher

func NewAesAedCipher

func NewAesAedCipher(keySize, ivSize int) IAedCipher

type IDerive

type IDerive interface {
	Derive(password, salt []byte, iterations, len int) []byte
}

IDerive interface for key derivation functions

func NewDerive

func NewDerive(byte DeriveByte) IDerive

type IHash

type IHash interface {
	New() hash.Hash
	Byte() HashByte
	HashSum(input []byte) []byte
}

func NewHash

func NewHash(byte HashByte) IHash

type IMac

type IMac interface {
	Init(key []byte) IMac
	Write(data []byte) (int, error)
	Sum() []byte
	HashSum(input []byte) []byte
	Reset()
}

IMac interface for Message Authentication Code

func NewMac

func NewMac(byte MacByte) IMac

type IPubCipher

type IPubCipher interface {
	GeneratePair() (priv []byte, pub []byte, err error)
	Encrypt(pub []byte, data []byte) ([]byte, error)
	Decrypt(priv []byte, data []byte) ([]byte, error)
	Sign(priv []byte, data []byte) ([]byte, error)
	Verify(pub []byte, data []byte, sig []byte) error
}

func NewPubCipher

func NewPubCipher(byte PubCipherByte) IPubCipher

type Mac

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

func (*Mac) HashSum

func (m *Mac) HashSum(input []byte) []byte

func (*Mac) Init

func (m *Mac) Init(key []byte) IMac

func (*Mac) Reset

func (m *Mac) Reset()

func (*Mac) Sum

func (m *Mac) Sum() []byte

func (*Mac) Write

func (m *Mac) Write(data []byte) (int, error)

type MacByte

type MacByte byte

type MacNewFN

type MacNewFN func(h func() hash.Hash, key []byte) hash.Hash

type PubCipherByte

type PubCipherByte byte

type RsaCipher

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

func (*RsaCipher) Decrypt

func (r *RsaCipher) Decrypt(priv []byte, data []byte) ([]byte, error)

func (*RsaCipher) Encrypt

func (r *RsaCipher) Encrypt(pub []byte, data []byte) ([]byte, error)

func (*RsaCipher) GeneratePair

func (r *RsaCipher) GeneratePair() (priv, pub []byte, err error)

func (*RsaCipher) Sign

func (r *RsaCipher) Sign(priv []byte, data []byte) ([]byte, error)

func (*RsaCipher) Verify

func (r *RsaCipher) Verify(pub []byte, data []byte, sig []byte) error

Jump to

Keyboard shortcuts

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