rsa

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package rsa provides utilities for signing and verifying messages using RSA.

Index

Constants

This section is empty.

Variables

View Source
var ErrHashUnavailable = errors.New("rsa: requested hash function is unavailable")

ErrHashUnavailable is returned when the hash function is not linked into the binary.

Functions

This section is empty.

Types

type PKCSSigner

type PKCSSigner struct {
	PKCSVerifier
	Rand io.Reader // Defaults to crypto/rand.Reader if not set.
	// contains filtered or unexported fields
}

PKCSSigner signs messages using RSA-PKCS #1 v1.5. It is safe for concurrent use by multiple goroutines.

func NewPKCSSigner

func NewPKCSSigner(priv *rsa.PrivateKey, hash crypto.Hash) (*PKCSSigner, error)

NewPKCSSigner returns a new PKCSSigner for the provided private key and hash algorithm.

func (*PKCSSigner) Sign

func (s *PKCSSigner) Sign(message []byte) ([]byte, error)

Sign signs a message using the private key.

type PKCSVerifier

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

PKCSVerifier verifies RSA-PKCS #1 v1.5 message signatures. It is safe for concurrent use by multiple goroutines.

func NewPKCSVerifier

func NewPKCSVerifier(pub *rsa.PublicKey, hash crypto.Hash) (*PKCSVerifier, error)

NewPKCSVerifier returns a new PKCSVerifier for the provided public key and hash algorithm.

func (*PKCSVerifier) Verify

func (v *PKCSVerifier) Verify(message []byte, signature []byte) (bool, error)

Verify verifies the signature of a message using the public key.

type PSSSigner

type PSSSigner struct {
	PSSVerifier
	Rand io.Reader // Defaults to crypto/rand.Reader if not set.
	// contains filtered or unexported fields
}

PSSSigner signs messages using RSA-PSS. It is safe for concurrent use by multiple goroutines.

func NewPSSSigner

func NewPSSSigner(priv *rsa.PrivateKey, opts *rsa.PSSOptions) (*PSSSigner, error)

NewPSSSigner returns a new PSSSigner for the provided private key.

func (*PSSSigner) Sign

func (s *PSSSigner) Sign(message []byte) ([]byte, error)

Sign signs a message using the private key.

type PSSVerifier

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

PSSVerifier verifies RSA-PSS message signatures. It is safe for concurrent use by multiple goroutines.

func NewPSSVerifier

func NewPSSVerifier(pub *rsa.PublicKey, opts *rsa.PSSOptions) (*PSSVerifier, error)

NewPSSVerifier returns a new PSSVerifier for the provided public key.

func (*PSSVerifier) Verify

func (v *PSSVerifier) Verify(message []byte, signature []byte) (bool, error)

Verify verifies the signature of a message using the public key.

Jump to

Keyboard shortcuts

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