alg_hmac

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 8 Imported by: 2

Documentation

Overview

Package alg_hmac provides signer and verifier for HMAC digests using hmac-sha256

Index

Constants

View Source
const HMAC_SHA256 = "hmac-sha256" // Algo is the HMAC algorithm name

Variables

This section is empty.

Functions

func NewMultiHMACKeyDirectory

func NewMultiHMACKeyDirectory(keys map[string]HMAC) verifier.KeyDirectory

NewMultiHMACKeyDirectory creates a new in-memory MultiHMACKeyDirectory with the provided map of keyID to HMAC

GetKey() will validate the algorithm and return the HMAC if it is found

func NewSingleHMACKeyDirectory

func NewSingleHMACKeyDirectory(hmac *HMAC) verifier.KeyDirectory

NewSingleHMACKeyDirectory creates a new in-memory SingleHMACKeyDirectory with the provided key. All parameters are ignored in the GetKey() method, and it will never error.

Types

type HMAC

type HMAC struct {
	Key   []byte
	Attrs any
}

HMAC is a signer and verifier for HMAC digests. It uses crypto/hmac with sha256, and implements the httpsig.Attributer interface

func NewHMAC

func NewHMAC(key []byte) *HMAC

NewHMAC creates a new HMAC with the provided key

func NewHMACWithAttributes

func NewHMACWithAttributes(key []byte, attrs any) *HMAC

NewHMACWithAttributes creates a new HMAC with the provided key and attributes

func (*HMAC) Attributes

func (h *HMAC) Attributes() any

func (*HMAC) ContentDigest

func (h *HMAC) ContentDigest() contentdigest.Digester

func (*HMAC) Sign

func (h *HMAC) Sign(ctx context.Context, base string) ([]byte, error)

func (*HMAC) Type

func (h *HMAC) Type() string

func (*HMAC) Verify

func (h *HMAC) Verify(ctx context.Context, base string, sig []byte) error

Jump to

Keyboard shortcuts

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