cry

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PSSSaltLengthAuto causes the salt in a PSS signature to be as large
	// as possible when signing, and to be auto-detected when verifying.
	PSSSaltLengthAuto = 0
	// PSSSaltLengthEqualsHash causes the salt length to equal the length
	// of the hash used in the signature.
	PSSSaltLengthEqualsHash = -1
)

Variables

View Source
var ErrMessageTooLong = errors.New("message too long")

Functions

func BigIntToBytes

func BigIntToBytes(n *big.Int) []byte

func BytesToBigInt

func BytesToBigInt(b []byte) *big.Int

func DecryptOAEPM

func DecryptOAEPM(hash hash.Hash, random io.Reader, pub *rsa.PublicKey, ciphertext []byte, label []byte) ([]byte, error)

func EncryptOAEPM

func EncryptOAEPM(hash hash.Hash, random io.Reader, priv *rsa.PrivateKey, msg []byte, label []byte) ([]byte, error)

func SignByPublic

func SignByPublic(rand io.Reader, pub *rsa.PublicKey, hash crypto.Hash, hashed []byte) ([]byte, error)

func SignPKCS1v15

func SignPKCS1v15(rand io.Reader, priv *rsa.PrivateKey, hash crypto.Hash, hashed []byte) ([]byte, error)

func SignPSS added in v1.0.0

func SignPSS(rand io.Reader, priv *rsa.PrivateKey, hash crypto.Hash, digest []byte, opts *PSSOptions) ([]byte, error)

SignPSS calculates the signature of digest using PSS.

digest must be the result of hashing the input message using the given hash function. The opts argument may be nil, in which case sensible defaults are used. If opts.Hash is set, it overrides hash.

func SignPSSByPublic added in v1.0.0

func SignPSSByPublic(rand io.Reader, pub *rsa.PublicKey, hash crypto.Hash, digest []byte, opts *PSSOptions) ([]byte, error)

func VerifyByPrivate

func VerifyByPrivate(priv *rsa.PrivateKey, hash crypto.Hash, hashed []byte, sig []byte) error

func VerifyPSS added in v1.0.0

func VerifyPSS(pub *rsa.PublicKey, hash crypto.Hash, digest []byte, sig []byte, opts *PSSOptions) error

VerifyPSS verifies a PSS signature.

A valid signature is indicated by returning a nil error. digest must be the result of hashing the input message using the given hash function. The opts argument may be nil, in which case sensible defaults are used. opts.Hash is ignored.

func VerifyPSSByPrivate added in v1.0.0

func VerifyPSSByPrivate(priv *rsa.PrivateKey, hash crypto.Hash, digest []byte, sig []byte, opts *PSSOptions) error

VerifyPSS verifies a PSS signature.

A valid signature is indicated by returning a nil error. digest must be the result of hashing the input message using the given hash function. The opts argument may be nil, in which case sensible defaults are used. opts.Hash is ignored.

Types

type PSSOptions added in v1.0.0

type PSSOptions struct {
	// SaltLength controls the length of the salt used in the PSS
	// signature. It can either be a number of bytes, or one of the special
	// PSSSaltLength constants.
	SaltLength int

	// Hash is the hash function used to generate the message digest. If not
	// zero, it overrides the hash function passed to SignPSS. It's required
	// when using PrivateKey.Sign.
	Hash crypto.Hash
}

PSSOptions contains options for creating and verifying PSS signatures.

func (*PSSOptions) HashFunc added in v1.0.0

func (opts *PSSOptions) HashFunc() crypto.Hash

HashFunc returns opts.Hash so that PSSOptions implements crypto.SignerOpts.

Jump to

Keyboard shortcuts

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