httpsig

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

README

This is a copy of Ted Unangst's HTTP signatures package, adapted for Betula's needs. Thanks Tedu!

See the original file.

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 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

Jump to

Keyboard shortcuts

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