sortedmap

package
v0.0.0-...-30b4a77 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2016 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package sortedmap implements sorted and signed maps.

Index

Constants

View Source
const MaxSignatureAge = 14400 // four hours

MaxSignatureAge is the maximum difference between now and the signature time.

Variables

View Source
var (
	// ErrNoVerify is returned when a signature could not be verified.
	ErrNoVerify = errors.New("sortedmap: signature verification failed")
	// ErrBadTime is returned if a signature time is either too old or too young.
	ErrBadTime = errors.New("sortedmap: signature time wrong")
	// ErrWalkBack is returned if an old certificate was presented.
	ErrWalkBack = errors.New("sortedmap: expired certificate replayed")
)

Functions

This section is empty.

Types

type SignedMap

type SignedMap struct {
	Config    StringMap
	Signature []byte
	SignDate  uint64
}

SignedMap is a signed map.

func Certify

func Certify(lastSignDate uint64, publicKey []byte, cert []byte) (*SignedMap, error)

Certify verifies an encoded certificate.

func Unmarshal

func Unmarshal(d []byte) (*SignedMap, error)

Unmarshal a signed map back to struct.

func (*SignedMap) Marshal

func (sm *SignedMap) Marshal() ([]byte, error)

Marshal a signed map.

type SortedMap

type SortedMap []StringStruct

SortedMap is a sorted (or sortable) string->string representation.

func (SortedMap) Image

func (so SortedMap) Image() []byte

Image returns the sha512 hash of SortedMap

func (SortedMap) Len

func (so SortedMap) Len() int

Len returns the number of elements in the SortedMap. sort.Sort interface implementation.

func (SortedMap) Less

func (so SortedMap) Less(i, j int) bool

Less compares i and j from SortedMap. sort.Sort interface implementation.

func (SortedMap) Sign

func (so SortedMap) Sign(signdate uint64, privKey *[ed25519.PrivateKeySize]byte) []byte

Sign a SortedMap with the given private key, returns the signature.

func (SortedMap) Swap

func (so SortedMap) Swap(i, j int)

Swap swaps two elements in the SortedMap. sort.Sort interface implementation.

func (SortedMap) ToMap

func (so SortedMap) ToMap() StringMap

ToMap returns a standard map from a SortedMap

func (SortedMap) Verify

func (so SortedMap) Verify(signdate uint64, publicKey []byte, signature []byte) bool

Verify a signature for a SortedMap with the publickey.

type StringMap

type StringMap map[string]string

StringMap is a string->string map.

func (StringMap) GenerateCertificate

func (sm StringMap) GenerateCertificate(privKey *[ed25519.PrivateKeySize]byte) ([]byte, error)

GenerateCertificate returns a signed and encoded SortedMap.

func (StringMap) Sort

func (sm StringMap) Sort() SortedMap

Sort converts a StingMap into a SortedMap.

type StringStruct

type StringStruct struct {
	K, V string
}

StringStruct is a stringmap converted to struct.

Jump to

Keyboard shortcuts

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