signed

package
v0.0.0-...-3980bf9 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2020 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package signed contains (1) convenience functions for ECDSA private and public key handling, and for signing and verifying byte slices with ECDSA; (2) functions for marshaling structs to signed bytes, and verifying and unmarshaling signed bytes back to structs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKey

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

func MarshalPemPrivateKey

func MarshalPemPrivateKey(sk *ecdsa.PrivateKey) ([]byte, error)

func MarshalPemPublicKey

func MarshalPemPublicKey(pk *ecdsa.PublicKey) ([]byte, error)

func MarshalPrivateKey

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

func MarshalPublicKey

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

func Sign

func Sign(sk *ecdsa.PrivateKey, bts []byte) ([]byte, error)

func UnmarshalPemPrivateKey

func UnmarshalPemPrivateKey(bts []byte) (*ecdsa.PrivateKey, error)

func UnmarshalPemPublicKey

func UnmarshalPemPublicKey(bts []byte) (*ecdsa.PublicKey, error)

func UnmarshalPrivateKey

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

func UnmarshalPublicKey

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

func UnmarshalVerify

func UnmarshalVerify(pk *ecdsa.PublicKey, signed Message, dst interface{}) error

UnmarshalVerify verifies the signature a Message created by MarshalSign, and unmarshals the message bytes into dst using either its UnmarshalBinary method (c.f. the encoding.BinaryUnmarshaler interface) or using gob.

func Verify

func Verify(pk *ecdsa.PublicKey, bts []byte, signature []byte) error

Types

type Message

type Message []byte

Message is a signed message, created and signed by MarshalSign, and verified and parsed by UnmarshalVerify.

func MarshalSign

func MarshalSign(sk *ecdsa.PrivateKey, message interface{}) (Message, error)

MarshalSign marshals the message to bytes using either its MarshalBinary() method (c.f. the encoding.BinaryMarshaler interface) or using gob, signs the resulting bytes, and returns signed message bytes suitable for verifying with UnmarshalVerify.

Jump to

Keyboard shortcuts

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