signature

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package signature provides subtle implementations of the Signer and Verifier primitives.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateECDSAParams added in v1.3.0

func ValidateECDSAParams(hashAlg string, curve string, encoding string) error

ValidateECDSAParams validates ECDSA parameters. The hash's strength must not be weaker than the curve's strength. Only DER encoding is supported now.

Types

type ECDSASignature added in v1.3.0

type ECDSASignature struct {
	R, S *big.Int
}

ECDSASignature is a struct holding r and s values of an ECDSA signature.

func DecodeECDSASignature added in v1.3.0

func DecodeECDSASignature(encodedBytes []byte, encoding string) (*ECDSASignature, error)

DecodeECDSASignature creates a new ECDSA signature using the given byte slice. The function assumes that the byte slice is the concatenation of the BigEndian representation of two big integer r and s.

func NewECDSASignature added in v1.3.0

func NewECDSASignature(r, s *big.Int) *ECDSASignature

NewECDSASignature creates a new ecdsaSignature object.

func (*ECDSASignature) EncodeECDSASignature added in v1.3.0

func (sig *ECDSASignature) EncodeECDSASignature(encoding, curveName string) ([]byte, error)

EncodeECDSASignature converts the signature to the given encoding format.

type ECDSASigner added in v1.3.0

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

ECDSASigner is an implementation of Signer for ECDSA. At the moment, the implementation only accepts DER encoding.

func NewECDSASigner added in v1.3.0

func NewECDSASigner(hashAlg string,
	curve string,
	encoding string,
	keyValue []byte) (*ECDSASigner, error)

NewECDSASigner creates a new instance of ECDSASigner.

func NewECDSASignerFromPrivateKey added in v1.3.0

func NewECDSASignerFromPrivateKey(hashAlg string,
	encoding string,
	privateKey *ecdsa.PrivateKey) (*ECDSASigner, error)

NewECDSASignerFromPrivateKey creates a new instance of ECDSASigner

func (*ECDSASigner) Sign added in v1.3.0

func (e *ECDSASigner) Sign(data []byte) ([]byte, error)

Sign computes a signature for the given data.

type ECDSAVerifier added in v1.3.0

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

ECDSAVerifier is an implementation of Verifier for ECDSA. At the moment, the implementation only accepts signatures with strict DER encoding.

func NewECDSAVerifier added in v1.3.0

func NewECDSAVerifier(hashAlg string, curve string, encoding string, x []byte, y []byte) (*ECDSAVerifier, error)

NewECDSAVerifier creates a new instance of ECDSAVerifier.

func NewECDSAVerifierFromPublicKey added in v1.3.0

func NewECDSAVerifierFromPublicKey(hashAlg string, encoding string, publicKey *ecdsa.PublicKey) (*ECDSAVerifier, error)

NewECDSAVerifierFromPublicKey creates a new instance of ECDSAVerifier.

func (*ECDSAVerifier) Verify added in v1.3.0

func (e *ECDSAVerifier) Verify(signatureBytes, data []byte) error

Verify verifies whether the given signature is valid for the given data. It returns an error if the signature is not valid; nil otherwise.

type ED25519Signer added in v1.3.0

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

ED25519Signer is an implementation of Signer for ED25519.

func NewED25519Signer added in v1.3.0

func NewED25519Signer(keyValue []byte) (*ED25519Signer, error)

NewED25519Signer creates a new instance of ED25519Signer.

func NewED25519SignerFromPrivateKey added in v1.3.0

func NewED25519SignerFromPrivateKey(privateKey *ed25519.PrivateKey) (*ED25519Signer, error)

NewED25519SignerFromPrivateKey creates a new instance of ED25519Signer

func (*ED25519Signer) Sign added in v1.3.0

func (e *ED25519Signer) Sign(data []byte) ([]byte, error)

Sign computes a signature for the given data.

type ED25519Verifier added in v1.3.0

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

ED25519Verifier is an implementation of Verifier for ED25519. At the moment, the implementation only accepts signatures with strict DER encoding.

func NewED25519Verifier added in v1.3.0

func NewED25519Verifier(pub []byte) (*ED25519Verifier, error)

NewED25519Verifier creates a new instance of ED25519Verifier.

func NewED25519VerifierFromPublicKey added in v1.3.0

func NewED25519VerifierFromPublicKey(publicKey *ed25519.PublicKey) (*ED25519Verifier, error)

NewED25519VerifierFromPublicKey creates a new instance of ED25519Verifier.

func (*ED25519Verifier) Verify added in v1.3.0

func (e *ED25519Verifier) Verify(signature, data []byte) error

Verify verifies whether the given signature is valid for the given data. It returns an error if the signature is not valid; nil otherwise.

Jump to

Keyboard shortcuts

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