pubkeycrypto

package
v0.0.0-...-6562eda Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2015 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnexpectedPublicKeyFormat = errors.New("Unexpected public key format")
)

Errors

Functions

This section is empty.

Types

type KeyPair

type KeyPair struct {
	PrivateKey *PrivateKey
	PublicKey  *PublicKey
}

KeyPair is a holder for a private key and a public key.

func GenerateKeyPair

func GenerateKeyPair() (*KeyPair, error)

GenerateKeyPair generates a private-public keypair.

type PrivateKey

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

PrivateKey is a wrapper over rsa.PrivateKey.

func GeneratePrivateKey

func GeneratePrivateKey() (*PrivateKey, error)

GeneratePrivateKey generates a PrivateKey.

func (*PrivateKey) DecryptOAEP

func (pk *PrivateKey) DecryptOAEP(ciphertext []byte) ([]byte, error)

DecryptOAEP decrypts the ciphertext using RSA-OAEP.

func (*PrivateKey) GetPublicKey

func (pk *PrivateKey) GetPublicKey() *PublicKey

GetPublicKey returns the public key based on this private key

func (*PrivateKey) Sign

func (pk *PrivateKey) Sign(message []byte) ([]byte, error)

Sign signs the given message using this private key and returns the signature.

func (*PrivateKey) ToString

func (pk *PrivateKey) ToString() string

ToString produces a string representation of this private key.

type PublicKey

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

PublicKey is a wrapper over rsa.PublicKey.

func PublicKeyFromBytes

func PublicKeyFromBytes(b []byte) (*PublicKey, error)

PublicKeyFromBytes returns a PublicKey given a slice of bytes in X509 PKIX public key format.

func (*PublicKey) EncryptOAEP

func (pk *PublicKey) EncryptOAEP(message []byte) ([]byte, error)

EncryptOAEP encrypts the message using RSA-OAEP.

func (*PublicKey) Sha1Hash

func (pk *PublicKey) Sha1Hash() string

Sha1Hash returns the SHA1 hash of ToBytes() of this public key.

func (*PublicKey) ToBytes

func (pk *PublicKey) ToBytes() []byte

ToBytes returns a slice of bytes representing this public key in X509 PKIX public key format.

func (*PublicKey) ToString

func (pk *PublicKey) ToString() string

ToString produces a string representation of this public key.

func (*PublicKey) VerifySignature

func (pk *PublicKey) VerifySignature(message, signature []byte) error

VerifySignature verifies that the signature for this message was produced with the private key for which this is the public key.

Jump to

Keyboard shortcuts

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