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 ¶
- Variables
- func GenerateKey() (*ecdsa.PrivateKey, error)
- func MarshalPemPrivateKey(sk *ecdsa.PrivateKey) ([]byte, error)
- func MarshalPemPublicKey(pk *ecdsa.PublicKey) ([]byte, error)
- func MarshalPrivateKey(sk *ecdsa.PrivateKey) ([]byte, error)
- func MarshalPublicKey(pk *ecdsa.PublicKey) ([]byte, error)
- func Sign(sk *ecdsa.PrivateKey, bts []byte) ([]byte, error)
- func UnmarshalPemPrivateKey(bts []byte) (*ecdsa.PrivateKey, error)
- func UnmarshalPemPublicKey(bts []byte) (*ecdsa.PublicKey, error)
- func UnmarshalPrivateKey(bts []byte) (*ecdsa.PrivateKey, error)
- func UnmarshalPublicKey(bts []byte) (*ecdsa.PublicKey, error)
- func UnmarshalVerify(pk *ecdsa.PublicKey, signed Message, dst interface{}) error
- func Verify(pk *ecdsa.PublicKey, bts []byte, signature []byte) error
- type Message
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidSignature = errors.New("ecdsa signature was invalid")
Functions ¶
func GenerateKey ¶
func GenerateKey() (*ecdsa.PrivateKey, error)
func MarshalPemPrivateKey ¶
func MarshalPemPrivateKey(sk *ecdsa.PrivateKey) ([]byte, error)
func MarshalPrivateKey ¶
func MarshalPrivateKey(sk *ecdsa.PrivateKey) ([]byte, error)
func UnmarshalPemPrivateKey ¶
func UnmarshalPemPrivateKey(bts []byte) (*ecdsa.PrivateKey, error)
func UnmarshalPrivateKey ¶
func UnmarshalPrivateKey(bts []byte) (*ecdsa.PrivateKey, error)
func UnmarshalVerify ¶
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.
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.