rabin

package
v1.0.4016 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(priv *PrivateKey, ciphertext []byte, opts crypto.DecrypterOpts) ([]byte, error)

func Encrypt

func Encrypt(pub *PublicKey, plaintext []byte, opts crypto.DecrypterOpts) ([]byte, error)

func PrivateKeyTo

func PrivateKeyTo(priv *PrivateKey) []byte

Marshal private key

func PublicKeyTo

func PublicKeyTo(pub *PublicKey) []byte

Marshal public key

Types

type PrivateKey

type PrivateKey struct {
	PublicKey
	P, Q *big.Int
}

PrivateKey represents an Rabin private key.

func GenerateKey

func GenerateKey(rand io.Reader) (*PrivateKey, error)

GenerateKey generates a random Rabin private key of the given bit size.

func GenerateKeyWithBitLength

func GenerateKeyWithBitLength(rand io.Reader, bitLength int) (*PrivateKey, error)

GenerateKey generates a random Rabin private key of the given bit size. bitLength = 64

func NewPrivateKey

func NewPrivateKey(raw []byte) (*PrivateKey, error)

Unmarshal private key

func (*PrivateKey) Decrypt

func (priv *PrivateKey) Decrypt(_ io.Reader, ciphertext []byte, opts crypto.DecrypterOpts) (plaintext []byte, err error)

crypto.Decrypter

func (*PrivateKey) Equal

func (priv *PrivateKey) Equal(x crypto.PrivateKey) bool

Equal reports whether priv and x have the same value.

func (*PrivateKey) Public

func (priv *PrivateKey) Public() crypto.PublicKey

Public returns the public key corresponding to priv.

type PublicKey

type PublicKey struct {
	N *big.Int
}

PublicKey represents an Rabin public key.

func NewPublicKey

func NewPublicKey(raw []byte) (*PublicKey, error)

Unmarshal public key

func (*PublicKey) Encrypt

func (pub *PublicKey) Encrypt(plaintext []byte, opts crypto.DecrypterOpts) ([]byte, error)

Encrypt data

func (*PublicKey) Equal

func (pub *PublicKey) Equal(x crypto.PublicKey) bool

Equal reports whether pub and x have the same value.

Jump to

Keyboard shortcuts

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