common

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: AGPL-3.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// SpoolIDSize is the size of a spool identity
	SpoolIDSize = 12

	// SignatureSize is the size of a spool command signature
	SignatureSize = 64

	// PublicKeySize is the size of a public key for verifying
	// spool command signatures.
	PublicKeySize = 32

	// MessageIDSize is the size of a message identity.
	MessageIDSize = 4

	// ResponsePadding is size of the padding of the spool service response.
	ResponsePadding = 121

	// QueryOverhead is the number of bytes overhead
	// from the spool command CBOR encoding.
	QueryOverhead = 171

	// SpoolPayloadLength is the length of the spool append message payload.
	SpoolPayloadLength = (constants.UserForwardPayloadLength - 4) - QueryOverhead

	// CreateSpoolCommand is the identity of the create spool command.
	CreateSpoolCommand = 0

	// PurgeSpoolCommand is the identity of the purge spool command.
	PurgeSpoolCommand = 1

	// AppendMessageCommand is the identity of the append message command.
	AppendMessageCommand = 2

	// RetrieveMessageCommand is the identity of the retrieve message command.
	RetrieveMessageCommand = 3

	// SpoolServiceName is the canonical name of the memspool service.
	SpoolServiceName = "spool"

	// StatusOK is a status string indicating there was no error on the spool operation.
	StatusOK = "OK"
)

Variables

This section is empty.

Functions

func AppendToSpool

func AppendToSpool(spoolID [SpoolIDSize]byte, message []byte) ([]byte, error)

func CreateSpool

func CreateSpool(privKey *eddsa.PrivateKey) ([]byte, error)

func PurgeSpool

func PurgeSpool(spoolID [SpoolIDSize]byte, privKey *eddsa.PrivateKey) ([]byte, error)

func ReadFromSpool

func ReadFromSpool(spoolID [SpoolIDSize]byte, messageID uint32, privKey *eddsa.PrivateKey) ([]byte, error)

Types

type SpoolRequest

type SpoolRequest struct {
	Command byte

	// SpoolID identities a spool on a particular Provider host.
	// This field must be SpoolIDSize bytes long.
	SpoolID   [SpoolIDSize]byte
	Signature []byte
	PublicKey []byte
	MessageID uint32
	Message   []byte
}

func SpoolRequestFromBytes

func SpoolRequestFromBytes(raw []byte) (SpoolRequest, error)

func (*SpoolRequest) Encode

func (s *SpoolRequest) Encode() ([]byte, error)

type SpoolResponse

type SpoolResponse struct {
	SpoolID   [SpoolIDSize]byte
	MessageID uint32
	Message   []byte
	Status    string
	Padding   []byte
}

func SpoolResponseFromBytes

func SpoolResponseFromBytes(raw []byte) (SpoolResponse, error)

func (*SpoolResponse) Encode

func (s *SpoolResponse) Encode() ([]byte, error)

func (*SpoolResponse) IsOK added in v0.0.2

func (s *SpoolResponse) IsOK() bool

func (*SpoolResponse) StatusAsError added in v0.0.2

func (s *SpoolResponse) StatusAsError() error

Jump to

Keyboard shortcuts

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