goverify

package module
v0.0.0-...-1486f89 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: MPL-2.0 Imports: 9 Imported by: 31

README

RSA Verifier

This lib makes it easy to verify a string with a signature using an RSA public/private key combination.

Shamelessly ripped off from SO:

http://stackoverflow.com/questions/20655702/signing-and-decoding-with-rsa-sha-in-go

And this play example:

https://play.golang.org/p/bzpD7Pa9mr

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RSAPrivateKey

type RSAPrivateKey struct {
	*rsa.PrivateKey
}

func (*RSAPrivateKey) Sign

func (r *RSAPrivateKey) Sign(data []byte) ([]byte, error)

Sign signs data with rsa-sha256

type RSAPublicKey

type RSAPublicKey struct {
	*rsa.PublicKey
}

func (*RSAPublicKey) Verify

func (r *RSAPublicKey) Verify(message []byte, sig []byte) error

Unsign verifies the message using a rsa-sha256 signature

type Signer

type Signer interface {
	// Sign returns raw signature for the given data. This method
	// will apply the hash specified for the keytype to the data.
	Sign(data []byte) ([]byte, error)
}

A Signer is can create signatures that verify against a public key.

func LoadPrivateKeyFromFile

func LoadPrivateKeyFromFile(path string) (Signer, error)

loadPrivateKey loads an parses a PEM encoded private key file.

func LoadPrivateKeyFromString

func LoadPrivateKeyFromString(key string) (Signer, error)

type Verifier

type Verifier interface {
	// Sign returns raw signature for the given data. This method
	// will apply the hash specified for the keytype to the data.
	Verify(data []byte, sig []byte) error
}

A Verifier is can validate signatures that verify against a public key.

func LoadPublicKeyFromFile

func LoadPublicKeyFromFile(path string) (Verifier, error)

loadPrivateKey loads an parses a PEM encoded private key file.

func LoadPublicKeyFromString

func LoadPublicKeyFromString(key string) (Verifier, error)

Jump to

Keyboard shortcuts

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