crypto

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: BSD-2-Clause Imports: 7 Imported by: 1

Documentation

Overview

Package crypto implements verification interfaces.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyPrivateKey = errors.New("trying to sign without private key")
)

Functions

This section is empty.

Types

type RSAPSS

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

RSAPSS represents RSA PSS algo for signing/verification (with SHA256 as digest calculation function).

func (RSAPSS) Name

func (r RSAPSS) Name() string

Name implements SignerVerifier interface.

func (RSAPSS) Sign

func (r RSAPSS) Sign(data []byte) ([]byte, error)

Sign generates SHA-256 digest and signs it using RSASSA-PSS.

func (RSAPSS) Verify

func (r RSAPSS) Verify(data []byte, signature []byte) error

Verify compares data with signature.

type Signer

type Signer interface {
	// Name returns name of the crypto algorithm, used by signer.
	Name() string
	// Sign returns signature for passed data.
	Sign(data []byte) ([]byte, error)
}

Signer implements high-level API for package signing.

type SignerVerifier

type SignerVerifier interface {
	Signer
	Verifier
}

SignerVerifier common interface.

func NewHexRSAPSSSignerVerifier added in v1.6.1

func NewHexRSAPSSSignerVerifier(privKey rsa.PrivateKey) SignerVerifier

NewHexRSAPSSSignerVerifier creates an RSA-PSS signer/verifier whose signatures are hex-encoded.

func NewHexSignerVerifier added in v1.6.1

func NewHexSignerVerifier(sv SignerVerifier) SignerVerifier

NewHexSignerVerifier wraps sv so that Sign emits a hex-encoded signature and Verify accepts a hex-encoded one.

func NewRSAPSSSignerVerifier

func NewRSAPSSSignerVerifier(privKey rsa.PrivateKey) SignerVerifier

NewRSAPSSSignerVerifier creates new RSAPSS object that can both sign and verify. The public key is derived from the private key.

type Verifier

type Verifier interface {
	// Name returns name of the crypto algorithm, used by verifier.
	Name() string
	// Verify checks data and signature mapping.
	Verify(data []byte, signature []byte) error
}

Verifier is an interface implementing a generic signature verification algorithm.

func NewHexRSAPSSVerifier added in v1.6.1

func NewHexRSAPSSVerifier(pubKey rsa.PublicKey) Verifier

NewHexRSAPSSVerifier creates an RSA-PSS verifier that accepts hex-encoded signatures.

func NewHexVerifier added in v1.6.1

func NewHexVerifier(v Verifier) Verifier

NewHexVerifier wraps v so that Verify accepts a hex-encoded signature.

func NewRSAPSSVerifier

func NewRSAPSSVerifier(pubKey rsa.PublicKey) Verifier

NewRSAPSSVerifier creates new RSAPSS object that can only verify signatures.

Jump to

Keyboard shortcuts

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