Documentation ¶
Index ¶
- Constants
- Variables
- func BigIntToBytes(n *big.Int) []byte
- func BytesToBigInt(b []byte) *big.Int
- func DecryptOAEPM(hash hash.Hash, random io.Reader, pub *rsa.PublicKey, ciphertext []byte, ...) ([]byte, error)
- func EncryptOAEPM(hash hash.Hash, random io.Reader, priv *rsa.PrivateKey, msg []byte, ...) ([]byte, error)
- func SignByPublic(rand io.Reader, pub *rsa.PublicKey, hash crypto.Hash, hashed []byte) ([]byte, error)
- func SignPKCS1v15(rand io.Reader, priv *rsa.PrivateKey, hash crypto.Hash, hashed []byte) ([]byte, error)
- func SignPSS(rand io.Reader, priv *rsa.PrivateKey, hash crypto.Hash, digest []byte, ...) ([]byte, error)
- func SignPSSByPublic(rand io.Reader, pub *rsa.PublicKey, hash crypto.Hash, digest []byte, ...) ([]byte, error)
- func VerifyByPrivate(priv *rsa.PrivateKey, hash crypto.Hash, hashed []byte, sig []byte) error
- func VerifyPSS(pub *rsa.PublicKey, hash crypto.Hash, digest []byte, sig []byte, ...) error
- func VerifyPSSByPrivate(priv *rsa.PrivateKey, hash crypto.Hash, digest []byte, sig []byte, ...) error
- type PSSOptions
Constants ¶
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 ¶
var ErrMessageTooLong = errors.New("message too long")
Functions ¶
func BigIntToBytes ¶
func BytesToBigInt ¶
func DecryptOAEPM ¶
func EncryptOAEPM ¶
func SignByPublic ¶
func SignPKCS1v15 ¶
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 VerifyByPrivate ¶
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.