signature

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package signature provides subtle implementations of the PublicKeySign and PublicKeyVerify primitives.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateEcdsaParams

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 EcdsaSign

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

EcdsaSign is an implementation of PublicKeySign for ECDSA. At the moment, the implementation only accepts DER encoding.

func NewEcdsaSign

func NewEcdsaSign(hashAlg string,
	curve string,
	encoding string,
	keyValue []byte) (*EcdsaSign, error)

NewEcdsaSign creates a new instance of EcdsaSign.

func NewEcdsaSignFromPrivateKey

func NewEcdsaSignFromPrivateKey(hashAlg string,
	encoding string,
	privateKey *ecdsa.PrivateKey) (*EcdsaSign, error)

NewEcdsaSignFromPrivateKey creates a new instance of EcdsaSign

func (*EcdsaSign) Sign

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

Sign computes a signature for the given data.

type EcdsaSignature

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

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

func DecodeEcdsaSignature

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

func NewEcdsaSignature(r, s *big.Int) *EcdsaSignature

NewEcdsaSignature creates a new ecdsaSignature object.

func (*EcdsaSignature) EncodeEcdsaSignature

func (sig *EcdsaSignature) EncodeEcdsaSignature(encoding string) ([]byte, error)

EncodeEcdsaSignature converts the signature to the given encoding format. Only DER encoding is supported now.

type EcdsaVerify

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

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

func NewEcdsaVerify

func NewEcdsaVerify(hashAlg string,
	curve string,
	encoding string,
	x []byte,
	y []byte) (*EcdsaVerify, error)

NewEcdsaVerify creates a new instance of EcdsaVerify.

func NewEcdsaVerifyFromPublicKey

func NewEcdsaVerifyFromPublicKey(hashAlg string, encoding string,
	publicKey *ecdsa.PublicKey) (*EcdsaVerify, error)

NewEcdsaVerifyFromPublicKey creates a new instance of EcdsaVerify.

func (*EcdsaVerify) Verify

func (e *EcdsaVerify) Verify(signatureBytes []byte, 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