signatures

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2019 License: Apache-2.0 Imports: 17 Imported by: 5

Documentation

Overview

Package signatures is used to check signatures. Only ED25519 which is not yet supported by crypto/x509 is implemented directly, other signatures are verified using x509 package.

Index

Constants

View Source
const (
	PureED25519 x509.SignatureAlgorithm = iota + 1000

	// SignaturePEMLabel is the label of a PEM-encoded signed message
	SignaturePEMLabel = "MESSAGE"
)

List of signature algorithms supported in addition to x509.

Variables

View Source
var (
	ErrInvalidLengthSignature = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowSignature   = fmt.Errorf("proto: integer overflow")
)
View Source
var ErrInvalidSignature = errors.New("signature verification failed")

ErrInvalidSignature is the error returned when the signature verification failed

View Source
var ErrNotImplemented = errors.New("Unhandled signature algorithm")

ErrNotImplemented is the error returned when trying to sign a message with an unimplemented algorithm.

Functions

func Verify

func Verify(signature *Signature) error

Verify checks the signature of a message for a given public key, it returns nil if the signature is correct. Except for ED25519 signatures it relies on x509 signature check for certificates.

Types

type Signature

type Signature struct {
	PublicKey            []byte   `protobuf:"bytes,2,opt,name=publicKey,proto3" json:"public_key"`
	Signature            []byte   `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"`
	Message              []byte   `protobuf:"bytes,4,opt,name=message,proto3" json:"message,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Signature describes a signed message. It contains: - the digital signature algorithm used to sign the message - the publicKey of the signer - the original message - the signature. Depending on the algorithm, either the whole message or just a hash of it is signed.

func ParseSignature

func ParseSignature(sigBytes []byte) (*Signature, error)

ParseSignature deserializes a signature from a PEM format.

func Sign

func Sign(secretKey, msg []byte) (*Signature, error)

Sign signs a message with the private key. It returns a Signature object containing the public key, the identifier for the signature algorithm used, the message that was signed and the signature. The secretKey argument must be the content of a PEM file containing the secret key.

func (*Signature) Descriptor

func (*Signature) Descriptor() ([]byte, []int)

func (*Signature) Encode

func (s *Signature) Encode() ([]byte, error)

Encode serializes a signature to the PEM format.

func (*Signature) GetMessage

func (m *Signature) GetMessage() []byte

func (*Signature) GetPublicKey

func (m *Signature) GetPublicKey() []byte

func (*Signature) GetSignature

func (m *Signature) GetSignature() []byte

func (*Signature) Marshal

func (m *Signature) Marshal() (dAtA []byte, err error)

func (*Signature) MarshalTo

func (m *Signature) MarshalTo(dAtA []byte) (int, error)

func (*Signature) ProtoMessage

func (*Signature) ProtoMessage()

func (*Signature) Reset

func (m *Signature) Reset()

func (*Signature) Size

func (m *Signature) Size() (n int)

func (*Signature) String

func (m *Signature) String() string

func (*Signature) Unmarshal

func (m *Signature) Unmarshal(dAtA []byte) error

func (*Signature) XXX_DiscardUnknown

func (m *Signature) XXX_DiscardUnknown()

func (*Signature) XXX_Marshal

func (m *Signature) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Signature) XXX_Merge

func (dst *Signature) XXX_Merge(src proto.Message)

func (*Signature) XXX_Size

func (m *Signature) XXX_Size() int

func (*Signature) XXX_Unmarshal

func (m *Signature) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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