rsa

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratePrivateKey

func GeneratePrivateKey(bits int) (*rsa.PrivateKey, error)

GeneratePrivateKey generates an RSA private key.

func Pem2PrivateKey

func Pem2PrivateKey(privateKeyStr []byte) (*rsa.PrivateKey, error)

PemToPrivateKey converts a PEM-encoded private key to an *rsa.PrivateKey.

func Pem2PublicKey

func Pem2PublicKey(publicPem []byte) (*rsa.PublicKey, error)

PemToPublicKey converts a PEM-encoded public key to an *rsa.PublicKey.

func PrivateKey2Pem

func PrivateKey2Pem(privateKey *rsa.PrivateKey) []byte

PrivateKeyToPem converts an *rsa.PrivateKey to a PEM-encoded private key.

func PublicKey2Pem

func PublicKey2Pem(publicKey *rsa.PublicKey) []byte

PublicKeyToPem converts an *rsa.PublicKey to a PEM-encoded public key.

Types

type Rsa

type Rsa struct {
	// contains filtered or unexported fields
}

RsaEncryption represents an RSA encryption scheme.

func New

func New(code crypto.Hash, hash hash.Hash) *Rsa

NewRsaEncryption creates a new RsaEncryption instance.

func (*Rsa) Decrypt

func (r *Rsa) Decrypt(ciphertext []byte, priv *rsa.PrivateKey) ([]byte, error)

Decrypt decrypts data with private key

func (*Rsa) Encrypt

func (r *Rsa) Encrypt(msg []byte, pub *rsa.PublicKey) ([]byte, error)

Encrypt encrypts data with public key public key bits Must be 1024 or above

func (*Rsa) Sign

func (r *Rsa) Sign(privateKey *rsa.PrivateKey, content []byte) ([]byte, error)

Sign signs a message using an RSA private key.

func (*Rsa) VerifySign

func (r *Rsa) VerifySign(publicKey *rsa.PublicKey, sign []byte, content []byte) error

VerifySignature verifies an RSA signature.

Jump to

Keyboard shortcuts

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