crypto

package
v0.5.32 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyExists   = errors.New("a key already exists")
	ErrKeyTooSmall = errors.New("key is too small")
	ErrNotRSA      = errors.New("key is not an rsa key")
)

Functions

func HMAC

func HMAC(result, secret, seed []byte)

Types

type Decrypter

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

func NewDecrypter

func NewDecrypter(r io.Reader, secret [32]byte) *Decrypter

func (*Decrypter) Read

func (d *Decrypter) Read(p []byte) (int, error)

type Encrypter

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

func NewEncrypter

func NewEncrypter(w io.Writer, secret [32]byte) *Encrypter

func (*Encrypter) Write

func (d *Encrypter) Write(p []byte) (int, error)

type HMACReader

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

func NewHMACReader

func NewHMACReader(r io.Reader, h func() hash.Hash, secret []byte) *HMACReader

func NewSHA1HMACReader

func NewSHA1HMACReader(r io.Reader, secret []byte) *HMACReader

func (*HMACReader) Read

func (h *HMACReader) Read(b []byte) (n int, err error)

type HMACWriter

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

func NewHMACWriter

func NewHMACWriter(w io.Writer, h func() hash.Hash, secret []byte, buffer uint16) *HMACWriter

func NewSHA1HMACWriter

func NewSHA1HMACWriter(w io.Writer, secret []byte, buffer uint16) *HMACWriter

func (*HMACWriter) Flush

func (h *HMACWriter) Flush() error

func (*HMACWriter) Write

func (h *HMACWriter) Write(b []byte) (int, error)

type Key

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

func EnsureKey

func EnsureKey(file string, minBytes, desiredBytes int) (*Key, error)

func KeyFromFile

func KeyFromFile(file string, minBytes, desiredBytes int) (*Key, error)

func KeyFromReader

func KeyFromReader(r io.Reader, minBytes, desiredBytes int) (*Key, error)

func NewKey

func NewKey(minBytes, desiredBytes int) *Key

func (*Key) Decrypt

func (k *Key) Decrypt(data []byte) ([]byte, error)

func (*Key) Generate

func (k *Key) Generate() error

func (*Key) MarshalDER

func (k *Key) MarshalDER() ([]byte, error)

func (*Key) MarshalPEM

func (k *Key) MarshalPEM() ([]byte, error)

func (*Key) Public

func (k *Key) Public() (*PubKey, error)

func (*Key) Sign

func (k *Key) Sign(data []byte) ([]byte, error)

func (*Key) Size

func (k *Key) Size() int

func (*Key) UnmarshalDER

func (k *Key) UnmarshalDER(data []byte) error

func (*Key) UnmarshalPEM

func (k *Key) UnmarshalPEM(data []byte) error

type PubKey

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

func NewPubKey

func NewPubKey(minBytes int) *PubKey

func (*PubKey) Encrypt

func (k *PubKey) Encrypt(data []byte) ([]byte, error)

func (*PubKey) Fingerprint

func (k *PubKey) Fingerprint() [32]byte

func (*PubKey) FingerprintString

func (k *PubKey) FingerprintString() string

func (*PubKey) MarshalDER

func (k *PubKey) MarshalDER() []byte

func (*PubKey) MarshalPEM

func (k *PubKey) MarshalPEM() ([]byte, error)

func (*PubKey) MaxPayload

func (k *PubKey) MaxPayload() int

func (*PubKey) Size

func (k *PubKey) Size() int

func (*PubKey) UnmarshalDER

func (k *PubKey) UnmarshalDER(data []byte) error

func (*PubKey) UnmarshalPEM

func (k *PubKey) UnmarshalPEM(data []byte) error

func (*PubKey) Verify

func (k *PubKey) Verify(data, sig []byte) error

type ReadWriter

type ReadWriter struct {
	*Decrypter
	*Encrypter
}

Jump to

Keyboard shortcuts

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