crypto

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknown      = errors.New(`unknown`)
	ErrTypeRequired = errors.New(`type required`)

	DefaultConfig = &Config{
		Type:    ecdsa.Module,
		Options: ecdsa.DefaultOpts,
	}

	DefaultSuite, _ = NewSuiteByConfig(DefaultConfig, false)
)

Functions

func RandomBytes

func RandomBytes(length int) ([]byte, error)

RandomBytes returns slice of random bytes of presented size

Types

type Config added in v0.10.0

type Config struct {
	Type    string            `yaml:"type"`
	Options map[string]string `yaml:"options"`
}

type Suite added in v0.10.0

type Suite interface {
	// Sign is used for signing message by presented private key
	Sign(msg []byte, key interface{}) ([]byte, error)
	// Verify is used for verifying signature for presented message and public key
	Verify(publicKey interface{}, msg, sig []byte) error
	// Hash is used for hashing presented data
	Hash(data []byte) []byte
	// NewPrivateKey generates new private key
	NewPrivateKey() (interface{}, error)
	// GetSignatureAlgorithm returns signature algorithm
	GetSignatureAlgorithm() x509.SignatureAlgorithm
}

Suite describes common cryptographic operations

func NewSuite added in v0.10.0

func NewSuite(name string, opts map[string]string) (Suite, error)

func NewSuiteByConfig added in v0.10.0

func NewSuiteByConfig(config *Config, useDefault bool) (Suite, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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