serialization

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: BSD-3-Clause Imports: 9 Imported by: 4

Documentation

Overview

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

This file was auto-generated by the vanadium vdl tool. Package: serialization

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

func (x HashCode) VDLIsZero() bool

func (*HashCode) VDLRead

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

func (HashCode) VDLReflect

func (HashCode) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/security/serialization.HashCode"`
})

func (HashCode) VDLWrite

func (x HashCode) VDLWrite(enc vdl.Encoder) 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
	// VDLReflect describes the SignedData union type.
	VDLReflect(vdlSignedDataReflect)
	VDLIsZero() bool
	VDLWrite(vdl.Encoder) error
}

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

func (x SignedDataHash) Index() int

func (SignedDataHash) Interface

func (x SignedDataHash) Interface() interface{}

func (SignedDataHash) Name

func (x SignedDataHash) Name() string

func (SignedDataHash) VDLIsZero

func (x SignedDataHash) VDLIsZero() bool

func (SignedDataHash) VDLReflect

func (x SignedDataHash) VDLReflect(vdlSignedDataReflect)

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

func (x SignedDataSignature) Index() int

func (SignedDataSignature) Interface

func (x SignedDataSignature) Interface() interface{}

func (SignedDataSignature) Name

func (x SignedDataSignature) Name() string

func (SignedDataSignature) VDLIsZero

func (x SignedDataSignature) VDLIsZero() bool

func (SignedDataSignature) VDLReflect

func (x SignedDataSignature) VDLReflect(vdlSignedDataReflect)

func (SignedDataSignature) VDLWrite

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

type SignedHeader

type SignedHeader struct {
	ChunkSizeBytes int64
}

Type definitions ================

func (SignedHeader) VDLIsZero

func (x SignedHeader) VDLIsZero() bool

func (*SignedHeader) VDLRead

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

func (SignedHeader) VDLReflect

func (SignedHeader) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/security/serialization.SignedHeader"`
})

func (SignedHeader) VDLWrite

func (x SignedHeader) VDLWrite(enc vdl.Encoder) 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