rsa
packagestandard libraryThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
- Variables
- func DecryptOAEP(hash, mgfHash hash.Hash, priv *PrivateKey, ciphertext []byte, label []byte) ([]byte, error)
- func DecryptWithCheck(priv *PrivateKey, ciphertext []byte) ([]byte, error)
- func DecryptWithoutCheck(priv *PrivateKey, ciphertext []byte) ([]byte, error)
- func Encrypt(pub *PublicKey, plaintext []byte) ([]byte, error)
- func EncryptOAEP(hash, mgfHash hash.Hash, random io.Reader, pub *PublicKey, msg []byte, ...) ([]byte, error)
- func PSSMaxSaltLength(pub *PublicKey, hash hash.Hash) (int, error)
- func SignPKCS1v15(priv *PrivateKey, hash string, hashed []byte) ([]byte, error)
- func SignPSS(rand io.Reader, priv *PrivateKey, hash hash.Hash, hashed []byte, ...) ([]byte, error)
- func VerifyPKCS1v15(pub *PublicKey, hash string, hashed []byte, sig []byte) error
- func VerifyPSS(pub *PublicKey, hash hash.Hash, digest []byte, sig []byte) error
- func VerifyPSSWithSaltLength(pub *PublicKey, hash hash.Hash, digest []byte, sig []byte, saltLength int) error
- type PrivateKey
- func GenerateKey(rand io.Reader, bits int) (*PrivateKey, error)
- func NewPrivateKey(N []byte, e int, d, P, Q []byte) (*PrivateKey, error)
- func NewPrivateKeyWithPrecomputation(N []byte, e int, d, P, Q, dP, dQ, qInv []byte) (*PrivateKey, error)
- func NewPrivateKeyWithoutCRT(N []byte, e int, d []byte) (*PrivateKey, error)
- type PublicKey
Constants¶
This section is empty.
Variables¶
var ErrDecryption =errors.New("crypto/rsa: decryption error")var ErrMessageTooLong =errors.New("crypto/rsa: message too long for RSA key size")var ErrVerification =errors.New("crypto/rsa: verification error")Functions¶
funcDecryptOAEP¶
func DecryptOAEP(hash, mgfHashhash.Hash, priv *PrivateKey, ciphertext []byte, label []byte) ([]byte,error)
DecryptOAEP decrypts ciphertext using RSAES-OAEP.
funcDecryptWithCheck¶
func DecryptWithCheck(priv *PrivateKey, ciphertext []byte) ([]byte,error)
DecryptWithCheck performs the RSA private key operation and checks theresult to defend against errors in the CRT computation.
funcDecryptWithoutCheck¶
func DecryptWithoutCheck(priv *PrivateKey, ciphertext []byte) ([]byte,error)
DecryptWithoutCheck performs the RSA private key operation.
funcEncryptOAEP¶
func EncryptOAEP(hash, mgfHashhash.Hash, randomio.Reader, pub *PublicKey, msg []byte, label []byte) ([]byte,error)
EncryptOAEP encrypts the given message with RSAES-OAEP.
funcPSSMaxSaltLength¶
PSSMaxSaltLength returns the maximum salt length for a given public key andhash function.
funcSignPKCS1v15¶
func SignPKCS1v15(priv *PrivateKey, hashstring, hashed []byte) ([]byte,error)
SignPKCS1v15 calculates an RSASSA-PKCS1-v1.5 signature.
hash is the name of the hash function as returned bycrypto.Hash.Stringor the empty string to indicate that the message is signed directly.
funcSignPSS¶
func SignPSS(randio.Reader, priv *PrivateKey, hashhash.Hash, hashed []byte, saltLengthint) ([]byte,error)
SignPSS calculates the signature of hashed using RSASSA-PSS.
funcVerifyPKCS1v15¶
VerifyPKCS1v15 verifies an RSASSA-PKCS1-v1.5 signature.
hash is the name of the hash function as returned bycrypto.Hash.Stringor the empty string to indicate that the message is signed directly.
Types¶
typePrivateKey¶
type PrivateKey struct {// contains filtered or unexported fields}funcGenerateKey¶
func GenerateKey(randio.Reader, bitsint) (*PrivateKey,error)
GenerateKey generates a new RSA key pair of the given bit size.bits must be at least 32.
funcNewPrivateKey¶
func NewPrivateKey(N []byte, eint, d, P, Q []byte) (*PrivateKey,error)
NewPrivateKey creates a new RSA private key from the given parameters.
All values are in big-endian byte slice format, and may have leading zerosor be shorter if leading zeroes were trimmed.
funcNewPrivateKeyWithPrecomputation¶
func NewPrivateKeyWithPrecomputation(N []byte, eint, d, P, Q, dP, dQ, qInv []byte) (*PrivateKey,error)
NewPrivateKeyWithPrecomputation creates a new RSA private key from the givenparameters, which include precomputed CRT values.
funcNewPrivateKeyWithoutCRT¶
func NewPrivateKeyWithoutCRT(N []byte, eint, d []byte) (*PrivateKey,error)
NewPrivateKeyWithoutCRT creates a new RSA private key from the given parameters.
This is meant for deprecated multi-prime keys, and is not FIPS 140 compliant.
func (*PrivateKey)Export¶
func (priv *PrivateKey) Export() (N []byte, eint, d, P, Q, dP, dQ, qInv []byte)
Export returns the key parameters in big-endian byte slice format.
P, Q, dP, dQ, and qInv may be nil if the key was created withNewPrivateKeyWithoutCRT.
func (*PrivateKey)PublicKey¶
func (priv *PrivateKey) PublicKey() *PublicKey