hkp

package module
v0.0.0-...-bb7c1da Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: MIT Imports: 17 Imported by: 1

README

go-openpgp-hkp

GoDoc

A Go library for OpenPGP HTTP Keyserver Protocol (HKP).

License

MIT

Documentation

Overview

Package hkp implements OpenPGP HTTP Keyserver Protocol (HKP), as defined in https://tools.ietf.org/html/draft-shaw-openpgp-hkp-00

Index

Examples

Constants

View Source
const Base = "/pks"

Base is the base path for the HTTP API.

Variables

View Source
var (
	ErrNotFound  = errors.New("hkp: not found")
	ErrForbidden = errors.New("hkp: forbidden")
)

Functions

This section is empty.

Types

type Adder

type Adder interface {
	Add(el openpgp.EntityList) error
}

type Client

type Client struct {
	Host     string
	Insecure bool
}
Example
c := hkp.Client{Host: "https://pgp.mit.edu"}

req := hkp.LookupRequest{Search: "0x2C6464AF2A8E4C02"}
index, err := c.Index(&req)
if err != nil {
	log.Fatal(err)
}

log.Println(index)

keys, err := c.Get(&req)
if err != nil {
	log.Fatal(err)
}

log.Println(keys)
Output:

func (*Client) Add

func (c *Client) Add(el openpgp.EntityList) error

func (*Client) Get

func (c *Client) Get(req *LookupRequest) (openpgp.EntityList, error)

func (*Client) Index

func (c *Client) Index(req *LookupRequest) ([]IndexKey, error)

type Handler

type Handler struct {
	Lookuper Lookuper
	Adder    Adder
}

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

type IndexFlags

type IndexFlags int
const (
	IndexKeyRevoked IndexFlags = 1 << iota
	IndexKeyDisabled
	IndexKeyExpired
)

type IndexIdentity

type IndexIdentity struct {
	Name           string
	CreationTime   time.Time
	ExpirationTime time.Time
	Flags          IndexFlags
}

type IndexKey

type IndexKey struct {
	CreationTime   time.Time
	ExpirationTime time.Time
	Algo           packet.PublicKeyAlgorithm
	Fingerprint    []byte
	BitLength      int
	Flags          IndexFlags
	Identities     []IndexIdentity
}

func IndexKeyFromEntity

func IndexKeyFromEntity(e *openpgp.Entity) (*IndexKey, error)

IndexKeyFromEntity creates an IndexKey from an openpgp.Entity.

type KeyIDSearch

type KeyIDSearch []byte

func ParseKeyIDSearch

func ParseKeyIDSearch(search string) KeyIDSearch

ParseKeyIDSearch parses a key ID search prefixed with "0x". If the supplied search isn't a key ID, returns nil.

func (KeyIDSearch) Fingerprint

func (search KeyIDSearch) Fingerprint() []byte

Fingerprint extracts a fingerprint from a key ID search. It returns nil if the search doesn't contain a fingerprint.

func (KeyIDSearch) KeyId

func (search KeyIDSearch) KeyId() *uint64

KeyId extracts a 64-bit key ID from a key ID search. It returns nil if the search doesn't contain a 64-bit key ID.

func (KeyIDSearch) KeyIdShort

func (search KeyIDSearch) KeyIdShort() *uint32

KeyIdShort extracts a 32-bit key ID from a key ID search. It returns nil if the search doesn't contain a 32-bit key ID.

type LookupOptions

type LookupOptions struct {
	NoModification bool
}

type LookupRequest

type LookupRequest struct {
	Search  string
	Options LookupOptions
	Exact   bool
}

type Lookuper

type Lookuper interface {
	Get(req *LookupRequest) (openpgp.EntityList, error)
	Index(req *LookupRequest) ([]IndexKey, error)
}

Jump to

Keyboard shortcuts

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