ecdsa

package
v0.0.0-...-811544e Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const SignatureSize = 64

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey() (*ecdsa.PrivateKey, error)

GenerateKey generates a new ECDSA private key for the P-256 curve

func GenerateSharedKey

func GenerateSharedKey(publicKey *ecdsa.PublicKey, privateKey *ecdsa.PrivateKey) ([]byte, error)

GenerateSharedKey generates a shared key using ECDH exchange between a public and private key

func MarshalPrivateKey

func MarshalPrivateKey(privateKey *ecdsa.PrivateKey) ([]byte, error)

MarshalPrivateKey marshals a private key to SEC 1, ASN.1 DER form

func MarshalPublicKey

func MarshalPublicKey(publicKey *ecdsa.PublicKey) ([]byte, error)

MarshalPublicKey marshals a public key to SEC 1, ASN.1 DER form

func Sign

func Sign(privateKey *ecdsa.PrivateKey, data []byte) ([]byte, error)

Sign signs a message using ECDSA and returns an ASN.1 encoded signature

func UnmarshalPrivateKey

func UnmarshalPrivateKey(data []byte) (*ecdsa.PrivateKey, error)

UnmarshalPrivateKey unmarshal a private key from SEC 1, ASN.1 DER form

func UnmarshalPublicKey

func UnmarshalPublicKey(data []byte) (*ecdsa.PublicKey, error)

UnmarshalPublicKey unmarshal a public key from SEC 1, ASN.1 DER form

func Verify

func Verify(publicKey *ecdsa.PublicKey, data, signature []byte) bool

Verify verifies a message using ECDSA with an ASN.1 encoded signature

Types

type Signer

type Signer struct {
	Verifier
	// contains filtered or unexported fields
}

func NewSigner

func NewSigner(privateKey *ecdsa.PrivateKey) *Signer

func (*Signer) Sign

func (s *Signer) Sign(data []byte) ([]byte, error)

func (*Signer) SignatureSize

func (s *Signer) SignatureSize() int

func (*Signer) Verify

func (s *Signer) Verify(data, signature []byte) error

type Verifier

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

func NewVerifier

func NewVerifier(publicKey *ecdsa.PublicKey) *Verifier

func (*Verifier) Verify

func (v *Verifier) Verify(data, signature []byte) error

Jump to

Keyboard shortcuts

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