rsa

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Method

type Method struct {
	PrivateKey *rsa.PrivateKey
	PublicKey  *rsa.PublicKey
	HashFunc   func() hash.Hash
	Hash       crypto.Hash
	Name       string
	// contains filtered or unexported fields
}

func New

func New(algorithm string, privateKey *rsa.PrivateKey, publicKey *rsa.PublicKey) (*Method, error)

func NewFromPublicKey

func NewFromPublicKey(publicKey *rsa.PublicKey) (*Method, error)

NewFromPublicKey constructs a verifying Method from an RSA public key by heuristically selecting a JOSE RSA algorithm based on modulus size.

Heuristics (PKCS#1 v1.5):

  • n bits >= 4096 -> RS512
  • n bits >= 3072 -> RS384
  • otherwise -> RS256

Note: The choice between PKCS#1 v1.5 (RS*) and PSS (PS*) cannot be inferred from the key alone. This helper defaults to RS* for maximum interoperability.

func (*Method) GetName

func (m *Method) GetName() string

func (*Method) Sign

func (m *Method) Sign(message []byte) ([]byte, error)

func (*Method) Verify

func (m *Method) Verify(message []byte, signature []byte) error

Jump to

Keyboard shortcuts

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