signature

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 4 Imported by: 11

Documentation

Overview

Messages are prepended with a HMAC SHA256 signature (the signature makes up the first 32 bytes of a signed message; the remainder is the original message in cleartext).

Index

Constants

View Source
const SIGNATURE_LENGTH = 32

Variables

This section is empty.

Functions

func SignMessage

func SignMessage(message, secret []byte) []byte

SignMessage returns a message signed with the provided secret, with the signature prepended to the original message.

Types

type Verifier

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

A SignatureVerifier is a self-instrumenting pipeline object that validates and removes signatures.

func NewVerifier

func NewVerifier(sharedSecret string) *Verifier

NewSignatureVerifier returns a SignatureVerifier with the provided shared signing secret.

func (*Verifier) Run

func (v *Verifier) Run(inputChan <-chan []byte, outputChan chan<- []byte)

Run validates signatures. It consumes signed messages from inputChan, verifies the signature, and sends the message (sans signature) to outputChan. Invalid messages are dropped and nothing is sent to outputChan. Thus a reader of outputChan is guaranteed to receive only messages with a valid signature.

Run blocks on sending to outputChan, so the channel must be drained for the function to continue consuming from inputChan.

Jump to

Keyboard shortcuts

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