rsa

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cipher

type Cipher interface {
	Encrypt(plainText []byte) ([]byte, error)
	Decrypt(cipherText []byte) ([]byte, error)
	Sign(src []byte, hash crypto.Hash) ([]byte, error)
	Verify(src []byte, sign []byte, hash crypto.Hash) error
}

func NewCipher

func NewCipher(key Key, padding Padding, cipherMode CipherMode, signMode SignMode) Cipher

type CipherMode

type CipherMode interface {
	Encrypt(plainText []byte, puk *rsa.PublicKey) ([]byte, error)
	Decrypt(cipherText []byte, prk *rsa.PrivateKey) ([]byte, error)
}

func NewOAEPCipher

func NewOAEPCipher() CipherMode

func NewPKCS1v15Cipher

func NewPKCS1v15Cipher() CipherMode

type Key

type Key interface {
	PublicKey() *rsa.PublicKey
	PrivateKey() *rsa.PrivateKey
	Modulus() int
}

func LoadKeyFromDerFile

func LoadKeyFromDerFile(publicKeyFilePath, privateKeyFilePath string, ParseKey func([]byte, []byte) (Key, error)) (Key, error)

func LoadKeyFromPEMByte

func LoadKeyFromPEMByte(pukBytes, prkBytes []byte, ParseKey func([]byte, []byte) (Key, error)) (Key, error)

Eason Lin

func LoadKeyFromPEMFile

func LoadKeyFromPEMFile(publicKeyFilePath, privateKeyFilePath string, ParseKey func([]byte, []byte) (Key, error)) (Key, error)

func ParsePKCS1Key

func ParsePKCS1Key(publicKey, privateKey []byte) (Key, error)

func ParsePKCS1KeyByCert

func ParsePKCS1KeyByCert(publicKey, privateKey []byte) (Key, error)

func ParsePKCS8Key

func ParsePKCS8Key(publicKey, privateKey []byte) (Key, error)

type Padding

type Padding interface {
	Padding(src []byte) [][]byte
}

func NewNoPadding

func NewNoPadding(modulus int) Padding

func NewOAEPPadding

func NewOAEPPadding(modulus int) Padding

func NewPKCS1Padding

func NewPKCS1Padding(modulus int) Padding

type SignMode

type SignMode interface {
	Sign(src []byte, hash crypto.Hash, prk *rsa.PrivateKey) ([]byte, error)
	Verify(src []byte, sign []byte, hash crypto.Hash, puk *rsa.PublicKey) error
}

func NewPKCS1v15Sign

func NewPKCS1v15Sign() SignMode

Jump to

Keyboard shortcuts

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