crypto

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package crypto implements verification interfaces.

Index

Constants

View Source
const AlgoRSAPSS = "rsapss"

AlgoRSAPSS is the algorithm name returned by the RSA-PSS signer/verifier's Name method. Use it with integrity codec location options (e.g. WithSignatureLocation) instead of retyping the bare string.

Variables

View Source
var (
	ErrEmptyPrivateKey = errors.New("crypto: cannot sign without a private key")
)

Functions

This section is empty.

Types

type Mode

type Mode int

Mode selects how a signer encodes the signature it produces and which encodings a verifier accepts.

const (
	// ModeAuto emits raw signature bytes and, on verification, accepts a
	// signature in either raw or lower-case hex form. It is the default.
	ModeAuto Mode = iota
	// ModeHex emits a lower-case hex signature and accepts only hex on
	// verification.
	ModeHex
	// ModeBin emits raw signature bytes and accepts only raw bytes on
	// verification.
	ModeBin
)

type Option

type Option func(*config)

Option configures an RSA-PSS signer/verifier constructor.

func WithMode

func WithMode(m Mode) Option

WithMode sets the encoding mode of the signer/verifier. See ModeAuto, ModeHex and ModeBin. When omitted, ModeAuto is used.

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 NewRSAPSS

func NewRSAPSS(privKey rsa.PrivateKey, opts ...Option) SignerVerifier

NewRSAPSS 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 NewRSAPSSVerifier

func NewRSAPSSVerifier(pubKey rsa.PublicKey, opts ...Option) 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