serialization

package
v0.0.0-...-ff5f600 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2016 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package serialization implements utilities for reading and writing data with signature-based integrity checking.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSigningWriteCloser

func NewSigningWriteCloser(data, signature io.WriteCloser, s Signer, opts *Options) (io.WriteCloser, error)

NewSigningWriteCloser returns an io.WriteCloser that writes data along with an appropriate signature that establishes the integrity and authenticity of the data. It behaves as follows:

  • A Write call writes chunks (of size provided by the Options or 1MB by default) of data to the provided data WriteCloser and a hash of the chunks to the provided signature WriteCloser.
  • A Close call writes a signature (computed using the provided signer) of all the hashes written, and then closes the data and signature WriteClosers.

func NewVerifyingReader

func NewVerifyingReader(data, signature io.Reader, key security.PublicKey) (io.Reader, error)

NewVerifyingReader returns an io.Reader that ensures that all data returned by Read calls was written using a NewSigningWriter (by a principal possessing a signer corresponding to the provided public key), and has not been modified since (ensuring integrity and authenticity of data).

func VDLReadSignedData

func VDLReadSignedData(dec vdl.Decoder, x *SignedData) error

Types

type HashCode

type HashCode [32]byte

func (*HashCode) FillVDLTarget

func (m *HashCode) FillVDLTarget(t vdl.Target, tt *vdl.Type) error

func (*HashCode) MakeVDLTarget

func (m *HashCode) MakeVDLTarget() vdl.Target

func (HashCode) VDLIsZero

func (x HashCode) VDLIsZero() bool

func (*HashCode) VDLRead

func (x *HashCode) VDLRead(dec vdl.Decoder) error

func (HashCode) VDLWrite

func (x HashCode) VDLWrite(enc vdl.Encoder) error

type HashCodeTarget

type HashCodeTarget struct {
	Value *HashCode
	vdl.TargetBase
}

func (*HashCodeTarget) FromBytes

func (t *HashCodeTarget) FromBytes(src []byte, tt *vdl.Type) error

type Options

type Options struct {
	// ChunkSizeBytes controls the maximum amount of memory devoted to buffering
	// data provided to Write calls. See NewSigningWriteCloser.
	ChunkSizeBytes int64
}

Options specifies parameters to tune a SigningWriteCloser.

type SignedData

type SignedData interface {
	// Index returns the field index.
	Index() int
	// Interface returns the field value as an interface.
	Interface() interface{}
	// Name returns the field name.
	Name() string

	FillVDLTarget(vdl.Target, *vdl.Type) error
	VDLIsZero() bool
	VDLWrite(vdl.Encoder) error
	// contains filtered or unexported methods
}

SignedData represents any single field of the SignedData union type.

SignedData describes the information sent by a SigningWriter and read by VerifiyingReader.

type SignedDataHash

type SignedDataHash struct{ Value HashCode }

SignedDataHash represents field Hash of the SignedData union type.

func (SignedDataHash) FillVDLTarget

func (m SignedDataHash) FillVDLTarget(t vdl.Target, tt *vdl.Type) error

func (SignedDataHash) Index

func (x SignedDataHash) Index() int

func (SignedDataHash) Interface

func (x SignedDataHash) Interface() interface{}

func (SignedDataHash) MakeVDLTarget

func (m SignedDataHash) MakeVDLTarget() vdl.Target

func (SignedDataHash) Name

func (x SignedDataHash) Name() string

func (SignedDataHash) VDLIsZero

func (x SignedDataHash) VDLIsZero() bool

func (SignedDataHash) VDLWrite

func (x SignedDataHash) VDLWrite(enc vdl.Encoder) error

type SignedDataSignature

type SignedDataSignature struct{ Value security.Signature }

SignedDataSignature represents field Signature of the SignedData union type.

func (SignedDataSignature) FillVDLTarget

func (m SignedDataSignature) FillVDLTarget(t vdl.Target, tt *vdl.Type) error

func (SignedDataSignature) Index

func (x SignedDataSignature) Index() int

func (SignedDataSignature) Interface

func (x SignedDataSignature) Interface() interface{}

func (SignedDataSignature) MakeVDLTarget

func (m SignedDataSignature) MakeVDLTarget() vdl.Target

func (SignedDataSignature) Name

func (x SignedDataSignature) Name() string

func (SignedDataSignature) VDLIsZero

func (x SignedDataSignature) VDLIsZero() bool

func (SignedDataSignature) VDLWrite

func (x SignedDataSignature) VDLWrite(enc vdl.Encoder) error

type SignedDataTarget

type SignedDataTarget struct {
	Value *SignedData

	vdl.TargetBase
	vdl.FieldsTargetBase
	// contains filtered or unexported fields
}

func (*SignedDataTarget) FinishField

func (t *SignedDataTarget) FinishField(_, fieldTarget vdl.Target) error

func (*SignedDataTarget) FinishFields

func (t *SignedDataTarget) FinishFields(_ vdl.FieldsTarget) error

func (*SignedDataTarget) StartField

func (t *SignedDataTarget) StartField(name string) (key, field vdl.Target, _ error)

func (*SignedDataTarget) StartFields

func (t *SignedDataTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error)

type SignedHeader

type SignedHeader struct {
	ChunkSizeBytes int64
}

func (*SignedHeader) FillVDLTarget

func (m *SignedHeader) FillVDLTarget(t vdl.Target, tt *vdl.Type) error

func (*SignedHeader) MakeVDLTarget

func (m *SignedHeader) MakeVDLTarget() vdl.Target

func (SignedHeader) VDLIsZero

func (x SignedHeader) VDLIsZero() bool

func (*SignedHeader) VDLRead

func (x *SignedHeader) VDLRead(dec vdl.Decoder) error

func (SignedHeader) VDLWrite

func (x SignedHeader) VDLWrite(enc vdl.Encoder) error

type SignedHeaderTarget

type SignedHeaderTarget struct {
	Value *SignedHeader

	vdl.TargetBase
	vdl.FieldsTargetBase
	// contains filtered or unexported fields
}

func (*SignedHeaderTarget) FinishField

func (t *SignedHeaderTarget) FinishField(_, _ vdl.Target) error

func (*SignedHeaderTarget) FinishFields

func (t *SignedHeaderTarget) FinishFields(_ vdl.FieldsTarget) error

func (*SignedHeaderTarget) StartField

func (t *SignedHeaderTarget) StartField(name string) (key, field vdl.Target, _ error)

func (*SignedHeaderTarget) StartFields

func (t *SignedHeaderTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error)

func (*SignedHeaderTarget) ZeroField

func (t *SignedHeaderTarget) ZeroField(name string) error

type Signer

type Signer interface {
	Sign(message []byte) (security.Signature, error)
	PublicKey() security.PublicKey
}

Signer is the interface for digital signature operations used by NewSigningWriteCloser.

Jump to

Keyboard shortcuts

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