algorithms

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedKeyType = errors.New("the type of key provided is not supported by the algorithm")
View Source
var ErrVerificationFailed = errors.New("the signature could not be verified using the internally held key")

Functions

func Algorithms

func Algorithms() map[int]COSEAlgorithm

Algorithms returns the implemented COSE algorithms by COSE algorithm value.

Types

type COSEAlgorithm

type COSEAlgorithm interface {
	// Value returns the COSE algorithm value for the algorithm.
	Value() int

	// CheckKeyType checks that the public key is the correct type for the
	// algorithm, returning an error if not.
	CheckKeyType(key any) error

	// Verify uses the public key to perform a verification of the message data
	// using sig, returning an error if the key type is incorrect or the
	// verification failed.
	Verify(key any, message, sig []byte) error
}

COSEAlgorithm implementers provide functions for using public keys to verify data signed using standard COSE algorithms.

See the algorithm definitions: https://www.iana.org/assignments/cose/cose.xhtml#algorithms

type ES256

type ES256 struct{}

ES256 uses ECDSA keys to verify ASN.1 signatures of SHA256 hashes.

func (*ES256) CheckKeyType

func (e *ES256) CheckKeyType(key any) error

func (*ES256) Value

func (e *ES256) Value() int

func (*ES256) Verify

func (e *ES256) Verify(pub any, message, sig []byte) error

type EdDSA

type EdDSA struct{}

EdDSA uses Ed25519 keys to verify signatures.

func (*EdDSA) CheckKeyType

func (e *EdDSA) CheckKeyType(key any) error

func (*EdDSA) Value

func (e *EdDSA) Value() int

func (*EdDSA) Verify

func (e *EdDSA) Verify(pub any, message, sig []byte) error

type RS256

type RS256 struct{}

RS256 uses RSA keys to verify PKCS#1 v1.5 signatures generated using SHA256.

func (*RS256) CheckKeyType

func (r *RS256) CheckKeyType(key any) error

func (*RS256) Value

func (r *RS256) Value() int

func (*RS256) Verify

func (r *RS256) Verify(pub any, message, sig []byte) error

Jump to

Keyboard shortcuts

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