Documentation ¶
Overview ¶
Package serialization implements utilities for reading and writing data with signature-based integrity checking.
Index ¶
- func NewSigningWriteCloser(data, signature io.WriteCloser, s Signer, opts *Options) (io.WriteCloser, error)
- func NewVerifyingReader(data, signature io.Reader, key security.PublicKey) (io.Reader, error)
- func VDLReadSignedData(dec vdl.Decoder, x *SignedData) error
- type HashCode
- type HashCodeTarget
- type Options
- type SignedData
- type SignedDataHash
- func (m SignedDataHash) FillVDLTarget(t vdl.Target, tt *vdl.Type) error
- func (x SignedDataHash) Index() int
- func (x SignedDataHash) Interface() interface{}
- func (m SignedDataHash) MakeVDLTarget() vdl.Target
- func (x SignedDataHash) Name() string
- func (x SignedDataHash) VDLIsZero() bool
- func (x SignedDataHash) VDLWrite(enc vdl.Encoder) error
- type SignedDataSignature
- func (m SignedDataSignature) FillVDLTarget(t vdl.Target, tt *vdl.Type) error
- func (x SignedDataSignature) Index() int
- func (x SignedDataSignature) Interface() interface{}
- func (m SignedDataSignature) MakeVDLTarget() vdl.Target
- func (x SignedDataSignature) Name() string
- func (x SignedDataSignature) VDLIsZero() bool
- func (x SignedDataSignature) VDLWrite(enc vdl.Encoder) error
- type SignedDataTarget
- func (t *SignedDataTarget) FinishField(_, fieldTarget vdl.Target) error
- func (t *SignedDataTarget) FinishFields(_ vdl.FieldsTarget) error
- func (t *SignedDataTarget) StartField(name string) (key, field vdl.Target, _ error)
- func (t *SignedDataTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error)
- type SignedHeader
- type SignedHeaderTarget
- func (t *SignedHeaderTarget) FinishField(_, _ vdl.Target) error
- func (t *SignedHeaderTarget) FinishFields(_ vdl.FieldsTarget) error
- func (t *SignedHeaderTarget) StartField(name string) (key, field vdl.Target, _ error)
- func (t *SignedHeaderTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error)
- func (t *SignedHeaderTarget) ZeroField(name string) error
- type Signer
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 ¶
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 HashCodeTarget ¶
type HashCodeTarget struct { Value *HashCode vdl.TargetBase }
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 (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
type SignedDataSignature ¶
SignedDataSignature represents field Signature of the SignedData union type.
func (SignedDataSignature) FillVDLTarget ¶
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
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 (*SignedHeader) MakeVDLTarget ¶
func (m *SignedHeader) MakeVDLTarget() vdl.Target
func (SignedHeader) VDLIsZero ¶
func (x SignedHeader) VDLIsZero() bool
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