httpsig

package
v0.7.46 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: ISC Imports: 16 Imported by: 5

Documentation

Overview

An implementation of HTTP Signatures

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeKey

func DecodeKey(s string) (pri PrivateKey, pub PublicKey, err error)

Unmarshall an ASCII string into (optional) private and public keys

func EncodeKey

func EncodeKey(i interface{}) (string, error)

Marshall an RSA key into an ASCII string

func SignRequest

func SignRequest(keyname string, key PrivateKey, req *http.Request, content []byte)

Sign a request and add Signature header

func VerifyRequest

func VerifyRequest(req *http.Request, content []byte, lookupPubkey func(string) (PublicKey, error)) (string, error)

Verify the Signature header for a request is valid. The request body should be provided separately. The lookupPubkey function takes a keyname and returns a public key. Returns keyname if known, and/or error.

Types

type KeyType

type KeyType int
const (
	None KeyType = iota
	RSA
	Ed25519
)

type Options

type Options struct {
	CheckTime bool
	Headers   []string
}

type PrivateKey

type PrivateKey struct {
	Type KeyType
	Key  interface{}
}

func (PrivateKey) Sign

func (privkey PrivateKey) Sign(msg []byte) []byte

type PublicKey

type PublicKey struct {
	Type KeyType
	Key  interface{}
}

func (PublicKey) Verify

func (pubkey PublicKey) Verify(msg []byte, sig []byte) error

Source Files

  • httpsig.go

Jump to

Keyboard shortcuts

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