signing

package
v0.0.0-...-93fbde9 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package signing defines the various signing Algorithms supported by the gormcrypto package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAlgo

func RegisterAlgo(name string, creator func(map[string]interface{}) Algorithm)

RegisterAlgo adds an Algorithm to the internal algos map so it can be used in YAML configs

func SupportedAlgos

func SupportedAlgos() []string

SupportedAlgos returns a list of registered Algorithms that can be used in YAML configs

Types

type Algorithm

type Algorithm interface {
	// Name identifies the Algorithm as a string for exporting configurations
	Name() string
	// Config converts an Algorthim's internal configuration into a map for export
	Config() map[string]interface{}
	// Sign generates a signature for the provided data that can be used to verify whether that data has been altered.
	Sign([]byte) ([]byte, error)
	// Verify checks whether a given piece of data has been altered since it was signed.
	Verify([]byte, []byte) (bool, error)
}

Algorithm defines an interface that signing types must implement to be usable with gormcrypto. A type implementing signing.Algorithm will supplement a value's' serialized representation with a cryptographic signature, or verify the same. The types implemented here wrap the Go standard (and extended) library's various (non-deprecated) crypto packages.

func FromYaml

func FromYaml(name string, config map[string]interface{}) Algorithm

FromYaml configures an Algorithm automatically based on a name and a configuration map

type ECDSA

type ECDSA struct {
	Algorithm
	// contains filtered or unexported fields
}

ECDSA supports ECDSA

func NewECDSA

func NewECDSA(privateKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey) *ECDSA

NewECDSA creates a new ECDSA value

func (ECDSA) Config

func (s ECDSA) Config() map[string]interface{}

Config converts an Algorthim's internal configuration into a map for export

func (ECDSA) Name

func (ECDSA) Name() string

Name identifies the Algorithm as a string for exporting configurations

func (*ECDSA) Sign

func (s *ECDSA) Sign(plain []byte) ([]byte, error)

Sign ::: ECDSA

func (*ECDSA) Verify

func (s *ECDSA) Verify(plain []byte, signature []byte) (bool, error)

Verify ::: ECDSA

type ED25519

type ED25519 struct {
	Algorithm
	// contains filtered or unexported fields
}

ED25519 supports ED25519

func NewED25519

func NewED25519(privateKey *ed25519.PrivateKey, publicKey *ed25519.PublicKey) *ED25519

NewED25519 creates a new ED25519 value

func NewED25519FromSeed

func NewED25519FromSeed(seed string) *ED25519

NewED25519FromSeed creates a new ED25519FromSeed value

func (ED25519) Config

func (s ED25519) Config() map[string]interface{}

Config converts an Algorthim's internal configuration into a map for export

func (ED25519) Name

func (ED25519) Name() string

Name identifies the Algorithm as a string for exporting configurations

func (*ED25519) Sign

func (s *ED25519) Sign(plain []byte) ([]byte, error)

Sign ::: ED25519

func (*ED25519) Verify

func (s *ED25519) Verify(plain []byte, signature []byte) (bool, error)

Verify ::: ED25519

Jump to

Keyboard shortcuts

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