Movatterモバイル変換


[0]ホーム

URL:


rsa

packagestandard library
go1.25.5Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License:BSD-3-ClauseImports:13Imported by:0

Details

Repository

cs.opensource.google/go/go

Links

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDecryption =errors.New("crypto/rsa: decryption error")
View Source
var ErrMessageTooLong =errors.New("crypto/rsa: message too long for RSA key size")
View Source
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.

funcEncrypt

func Encrypt(pub *PublicKey, plaintext []byte) ([]byte,error)

Encrypt performs the RSA public 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

func PSSMaxSaltLength(pub *PublicKey, hashhash.Hash) (int,error)

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

func VerifyPKCS1v15(pub *PublicKey, hashstring, hashed []byte, sig []byte)error

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.

funcVerifyPSS

func VerifyPSS(pub *PublicKey, hashhash.Hash, digest []byte, sig []byte)error

VerifyPSS verifies sig with RSASSA-PSS automatically detecting the salt length.

funcVerifyPSSWithSaltLength

func VerifyPSSWithSaltLength(pub *PublicKey, hashhash.Hash, digest []byte, sig []byte, saltLengthint)error

VerifyPSS verifies sig with RSASSA-PSS and an expected salt length.

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

typePublicKey

type PublicKey struct {N *bigmod.ModulusEint}

func (*PublicKey)Size

func (pub *PublicKey) Size()int

Size returns the modulus size in bytes. Raw signatures and ciphertextsfor or by this public key will have the same size.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp