manifest

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: BSD-3-Clause Imports: 18 Imported by: 0

README

Prequesites: Open another terminal and go get the sm2/sm3 crypto library into your gopath. The code generator disables go modules.

GOPATH=your/go/path go get github.com/tjfoc/gmsm/sm2

To generalize all the logic related to Boot Policy Manifest and Key Manifest we use code generation. Therefore it is enough to create structure declarations and run command from this directory:

go run ./common/manifestcodegen/cmd/manifestcodegen/ . ./bootpolicy ./key

It will performe the code autogeneration in directories:

  • Current directory (.), which contains common structures for different manifests;
  • Boot Policy Manifest directory (./bootpolicy);
  • and Key Manifest directory (./key).

To check if the files are in the up-to-date state, one may add option -check:

go run ./common/manifestcodegen/cmd/manifestcodegen/ -check . ./bootpolicy ./key

Or if it is required to debug/trace the behavior of autogenerated code, one may add option -trace:

go run ./common/manifestcodegen/cmd/manifestcodegen/ -trace . ./bootpolicy ./key

In this case the code will write a verbose log into stdout.

If you need to edit the template, please edit file: ./common/manifestcodegen/cmd/manifestcodegen/template_methods.tpl.go.

Field tags

There are few special struct field tags which are recognized by the code generator:

  • id -- defines the element Structure ID string (for example __TXTS__).
  • version -- defines the value of StructVersion (see document #575623).
  • countType -- used only for slices and it defines which variable type is used to store amount of items of the slice. Arrays in a structure in a Manifest is almost always prepended with a count variable, and we automatically map it to the real amount of elements of our slice. And to do that we need to know the bitsize of the counter, therefore this tag exists.
  • countValue -- (see also countType) sometimes a counter requires special transformations before it could be maped into the real amount of elements of a slice. countValue allows to define a function to calculate the real count value.
  • require -- defines the value required by the document #575623.
  • default -- defines the default value.
  • prettyValue -- defines the function which prints the value in a pretty format.
  • rehashValue -- is used to receive an auto-updated value, for example it could be handy to automatically update size-fields.

See also:

grep -RIn field.TagGet ./

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// RandReader exports the rand.Reader
	RandReader = rand.Reader
)
View Source
var SM2UID = []byte{0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38}
View Source
var (
	// StrictOrderCheck defines if elements order checks should be performed.
	// For example in the Boot Policy Manifest elements could be in a wrong
	// order. And we still can parse it, but in this way `*Offset` methods
	// could be confusing, since they will show the offset as they will
	// be written (not as they were parsed).
	//
	// We require a strict order because it is explicitly required
	// in the documentation #575623:
	//
	// > The order of the elements and the order of the fields within each
	// > element are architectural and must be followed.
	StrictOrderCheck = true
)

Functions

This section is empty.

Types

type Algorithm

type Algorithm uint16

Algorithm represents a crypto algorithm value.

const (
	AlgUnknown Algorithm = 0x0000
	AlgRSA     Algorithm = 0x0001
	AlgSHA1    Algorithm = 0x0004
	AlgSHA256  Algorithm = 0x000B
	AlgSHA384  Algorithm = 0x000C
	AlgSHA512  Algorithm = 0x000D
	AlgNull    Algorithm = 0x0010
	AlgSM3_256 Algorithm = 0x0012
	AlgRSASSA  Algorithm = 0x0014
	AlgRSAPSS  Algorithm = 0x0016
	AlgECDSA   Algorithm = 0x0018
	AlgSM2     Algorithm = 0x001b
	AlgECC     Algorithm = 0x0023
)

func (Algorithm) Hash

func (a Algorithm) Hash() (hash.Hash, error)

Hash returns a crypto.Hash based on the given id. An error is returned if the given algorithm is not a hash algorithm or is not available.

func (Algorithm) IsNull

func (a Algorithm) IsNull() bool

IsNull returns true if a is AlgNull or zero (unset).

func (Algorithm) String

func (a Algorithm) String() string

type BitSize

type BitSize uint16

BitSize is a size in bits.

func (BitSize) InBits

func (ks BitSize) InBits() uint16

InBits returns the size in bits.

func (BitSize) InBytes

func (ks BitSize) InBytes() uint16

InBytes returns the size in bytes.

func (BitSize) PrettyString

func (flags BitSize) PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string

PrettyString returns the bits of the flags in an easy-to-read format.

func (*BitSize) SetInBits

func (ks *BitSize) SetInBits(amountOfBits uint16)

SetInBits sets the size in bits.

func (*BitSize) SetInBytes

func (ks *BitSize) SetInBytes(amountOfBytes uint16)

SetInBytes sets the size in bytes.

type Element

type Element interface {
	Structure
	ReadDataFrom(r io.Reader) (int64, error)
	GetStructInfo() StructInfo
	SetStructInfo(StructInfo)
}

type ElementsContainer

type ElementsContainer interface {
	Structure
	GetFieldByStructID(structID string) interface{}
}

type HashList

type HashList struct {
	Size uint16 `rehashValue:"TotalSize()"`
	List []HashStructure
}

HashList describes multiple digests

func NewHashList

func NewHashList() *HashList

NewHashList returns a new instance of HashList with all default values set.

func (*HashList) ListOffset

func (s *HashList) ListOffset() uint64

ListOffset returns the offset in bytes of field List

func (*HashList) ListTotalSize

func (s *HashList) ListTotalSize() uint64

ListSize returns the size in bytes of the value of field List

func (*HashList) PrettyString

func (s *HashList) PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string

PrettyString returns the content of the structure in an easy-to-read format.

func (*HashList) ReadFrom

func (s *HashList) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads the HashList from 'r' in format defined in the document #575623.

func (*HashList) Rehash

func (s *HashList) Rehash()

Rehash sets values which are calculated automatically depending on the rest data. It is usually about the total size field of an element.

func (*HashList) RehashRecursive

func (s *HashList) RehashRecursive()

RehashRecursive calls Rehash (see below) recursively.

func (*HashList) SizeOffset

func (s *HashList) SizeOffset() uint64

SizeOffset returns the offset in bytes of field Size

func (*HashList) SizeTotalSize

func (s *HashList) SizeTotalSize() uint64

SizeSize returns the size in bytes of the value of field Size

func (*HashList) TotalSize

func (s *HashList) TotalSize() uint64

Size returns the total size of the HashList.

func (*HashList) Validate

func (s *HashList) Validate() error

Validate (recursively) checks the structure if there are any unexpected values. It returns an error if so.

func (*HashList) WriteTo

func (s *HashList) WriteTo(w io.Writer) (int64, error)

WriteTo writes the HashList into 'w' in format defined in the document #575623.

type HashStructure

type HashStructure struct {
	HashAlg    Algorithm `default:"0x10" json:"hs_Alg"`
	HashBuffer []byte    `json:"hs_Buffer"`
}

HashStructure describes a digest.

func NewHashStructure

func NewHashStructure() *HashStructure

NewHashStructure returns a new instance of HashStructure with all default values set.

func (*HashStructure) HashAlgOffset

func (s *HashStructure) HashAlgOffset() uint64

HashAlgOffset returns the offset in bytes of field HashAlg

func (*HashStructure) HashAlgTotalSize

func (s *HashStructure) HashAlgTotalSize() uint64

HashAlgSize returns the size in bytes of the value of field HashAlg

func (*HashStructure) HashBufferOffset

func (s *HashStructure) HashBufferOffset() uint64

HashBufferOffset returns the offset in bytes of field HashBuffer

func (*HashStructure) HashBufferTotalSize

func (s *HashStructure) HashBufferTotalSize() uint64

HashBufferSize returns the size in bytes of the value of field HashBuffer

func (*HashStructure) PrettyString

func (s *HashStructure) PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string

PrettyString returns the content of the structure in an easy-to-read format.

func (*HashStructure) ReadFrom

func (s *HashStructure) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads the HashStructure from 'r' in format defined in the document #575623.

func (*HashStructure) Rehash

func (s *HashStructure) Rehash()

Rehash sets values which are calculated automatically depending on the rest data. It is usually about the total size field of an element.

func (*HashStructure) RehashRecursive

func (s *HashStructure) RehashRecursive()

RehashRecursive calls Rehash (see below) recursively.

func (*HashStructure) TotalSize

func (s *HashStructure) TotalSize() uint64

Size returns the total size of the HashStructure.

func (*HashStructure) Validate

func (s *HashStructure) Validate() error

Validate (recursively) checks the structure if there are any unexpected values. It returns an error if so.

func (*HashStructure) WriteTo

func (s *HashStructure) WriteTo(w io.Writer) (int64, error)

WriteTo writes the HashStructure into 'w' in format defined in the document #575623.

type Key

type Key struct {
	KeyAlg  Algorithm `json:"key_alg"`
	Version uint8     `require:"0x10"  json:"key_version"`
	KeySize BitSize   `json:"key_bitsize"`
	Data    []byte    `countValue:"keyDataSize()" json:"key_data"`
}

Key is a public key of an asymmetric crypto keypair.

func NewKey

func NewKey() *Key

NewKey returns a new instance of Key with all default values set.

func (*Key) DataOffset

func (s *Key) DataOffset() uint64

DataOffset returns the offset in bytes of field Data

func (*Key) DataTotalSize

func (s *Key) DataTotalSize() uint64

DataSize returns the size in bytes of the value of field Data

func (*Key) KeyAlgOffset

func (s *Key) KeyAlgOffset() uint64

KeyAlgOffset returns the offset in bytes of field KeyAlg

func (*Key) KeyAlgTotalSize

func (s *Key) KeyAlgTotalSize() uint64

KeyAlgSize returns the size in bytes of the value of field KeyAlg

func (*Key) KeySizeOffset

func (s *Key) KeySizeOffset() uint64

KeySizeOffset returns the offset in bytes of field KeySize

func (*Key) KeySizeTotalSize

func (s *Key) KeySizeTotalSize() uint64

KeySizeSize returns the size in bytes of the value of field KeySize

func (*Key) PrettyString

func (s *Key) PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string

PrettyString returns the content of the structure in an easy-to-read format.

func (*Key) PrintBPMPubKey

func (k *Key) PrintBPMPubKey(bpmAlg Algorithm) error

PrintBPMPubKey prints the BPM public signing key hash to fuse into the Intel ME

func (*Key) PrintKMPubKey

func (k *Key) PrintKMPubKey(kmAlg Algorithm) error

PrintKMPubKey prints the KM public signing key hash to fuse into the Intel ME

func (Key) PubKey

func (k Key) PubKey() (crypto.PublicKey, error)

PubKey parses Data into crypto.PublicKey.

func (*Key) ReadFrom

func (s *Key) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads the Key from 'r' in format defined in the document #575623.

func (*Key) Rehash

func (s *Key) Rehash()

Rehash sets values which are calculated automatically depending on the rest data. It is usually about the total size field of an element.

func (*Key) RehashRecursive

func (s *Key) RehashRecursive()

RehashRecursive calls Rehash (see below) recursively.

func (*Key) SetPubKey

func (k *Key) SetPubKey(key crypto.PublicKey) error

SetPubKey sets Data the value corresponding to passed `key`.

func (*Key) TotalSize

func (s *Key) TotalSize() uint64

Size returns the total size of the Key.

func (*Key) Validate

func (s *Key) Validate() error

Validate (recursively) checks the structure if there are any unexpected values. It returns an error if so.

func (*Key) VersionOffset

func (s *Key) VersionOffset() uint64

VersionOffset returns the offset in bytes of field Version

func (*Key) VersionTotalSize

func (s *Key) VersionTotalSize() uint64

VersionSize returns the size in bytes of the value of field Version

func (*Key) WriteTo

func (s *Key) WriteTo(w io.Writer) (int64, error)

WriteTo writes the Key into 'w' in format defined in the document #575623.

type KeySignature

type KeySignature struct {
	Version   uint8     `require:"0x10" json:"ks_Version,omitempty"`
	Key       Key       `json:"ks_key"`
	Signature Signature `json:"ks_Signature"`
}

KeySignature

func NewKeySignature

func NewKeySignature() *KeySignature

NewKeySignature returns a new instance of KeySignature with all default values set.

func (*KeySignature) FillSignature

func (ks *KeySignature) FillSignature(signAlgo Algorithm, pubKey crypto.PublicKey, signedData []byte, hashAlgo Algorithm) error

FillSignature sets a signature and all the values of KeyManifest, accordingly to arguments signAlgo, pubKey and signedData.

if signAlgo is zero then it is detected automatically, based on the type of the provided private key.

func (*KeySignature) KeyOffset

func (s *KeySignature) KeyOffset() uint64

KeyOffset returns the offset in bytes of field Key

func (*KeySignature) KeyTotalSize

func (s *KeySignature) KeyTotalSize() uint64

KeySize returns the size in bytes of the value of field Key

func (*KeySignature) PrettyString

func (s *KeySignature) PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string

PrettyString returns the content of the structure in an easy-to-read format.

func (*KeySignature) ReadFrom

func (s *KeySignature) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads the KeySignature from 'r' in format defined in the document #575623.

func (*KeySignature) Rehash

func (s *KeySignature) Rehash()

Rehash sets values which are calculated automatically depending on the rest data. It is usually about the total size field of an element.

func (*KeySignature) RehashRecursive

func (s *KeySignature) RehashRecursive()

RehashRecursive calls Rehash (see below) recursively.

func (*KeySignature) SetSignature

func (ks *KeySignature) SetSignature(signAlgo Algorithm, privKey crypto.Signer, signedData []byte) error

SetSignature generates a signature and sets all the values of KeyManifest, accordingly to arguments signAlgo, privKey and signedData.

if signAlgo is zero then it is detected automatically, based on the type of the provided private key.

func (*KeySignature) SetSignatureAuto

func (ks *KeySignature) SetSignatureAuto(privKey crypto.Signer, signedData []byte) error

SetSignatureAuto generates a signature and sets all the values of KeyManifest, accordingly to arguments privKey and signedData.

Signing algorithm will be detected automatically based on the type of the provided private key.

func (*KeySignature) SignatureOffset

func (s *KeySignature) SignatureOffset() uint64

SignatureOffset returns the offset in bytes of field Signature

func (*KeySignature) SignatureTotalSize

func (s *KeySignature) SignatureTotalSize() uint64

SignatureSize returns the size in bytes of the value of field Signature

func (*KeySignature) TotalSize

func (s *KeySignature) TotalSize() uint64

Size returns the total size of the KeySignature.

func (*KeySignature) Validate

func (s *KeySignature) Validate() error

Validate (recursively) checks the structure if there are any unexpected values. It returns an error if so.

func (*KeySignature) Verify

func (m *KeySignature) Verify(signedData []byte) error

Verify verifies the builtin signature with the builtin public key.

func (*KeySignature) VersionOffset

func (s *KeySignature) VersionOffset() uint64

VersionOffset returns the offset in bytes of field Version

func (*KeySignature) VersionTotalSize

func (s *KeySignature) VersionTotalSize() uint64

VersionSize returns the size in bytes of the value of field Version

func (*KeySignature) WriteTo

func (s *KeySignature) WriteTo(w io.Writer) (int64, error)

WriteTo writes the KeySignature into 'w' in format defined in the document #575623.

type Manifest

type Manifest interface {
	Structure
}

Manifest is an abstract manifest.

type SVN

type SVN uint8

SVN represents Security Version Number.

func (SVN) SVN

func (svn SVN) SVN() uint8

SVN returns the Security Version Number of an SVN field

type Signature

type Signature struct {
	SigScheme Algorithm `json:"sig_scheme"`
	Version   uint8     `require:"0x10" json:"sig_version,omitempty"`
	KeySize   BitSize   `json:"sig_keysize,omitempty"`
	HashAlg   Algorithm `json:"sig_hashAlg"`
	Data      []byte    `countValue:"KeySize.InBytes()" prettyValue:"dataPrettyValue()" json:"sig_data"`
}

Signature exports the Signature structure

func NewSignature

func NewSignature() *Signature

NewSignature returns a new instance of Signature with all default values set.

func (*Signature) DataOffset

func (s *Signature) DataOffset() uint64

DataOffset returns the offset in bytes of field Data

func (*Signature) DataTotalSize

func (s *Signature) DataTotalSize() uint64

DataSize returns the size in bytes of the value of field Data

func (*Signature) FillSignature

func (m *Signature) FillSignature(signAlgo Algorithm, pubKey crypto.PublicKey, signedData []byte, hashAlgo Algorithm) error

FillSignature sets the signature accordingly to arguments signAlgo, pubKey and signedData; and sets all the fields of the structure Signature.

if signAlgo is zero then it is detected automatically, based on the type of the provided private key.

func (*Signature) HashAlgOffset

func (s *Signature) HashAlgOffset() uint64

HashAlgOffset returns the offset in bytes of field HashAlg

func (*Signature) HashAlgTotalSize

func (s *Signature) HashAlgTotalSize() uint64

HashAlgSize returns the size in bytes of the value of field HashAlg

func (*Signature) KeySizeOffset

func (s *Signature) KeySizeOffset() uint64

KeySizeOffset returns the offset in bytes of field KeySize

func (*Signature) KeySizeTotalSize

func (s *Signature) KeySizeTotalSize() uint64

KeySizeSize returns the size in bytes of the value of field KeySize

func (*Signature) PrettyString

func (s *Signature) PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string

PrettyString returns the content of the structure in an easy-to-read format.

func (*Signature) ReadFrom

func (s *Signature) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads the Signature from 'r' in format defined in the document #575623.

func (*Signature) Rehash

func (s *Signature) Rehash()

Rehash sets values which are calculated automatically depending on the rest data. It is usually about the total size field of an element.

func (*Signature) RehashRecursive

func (s *Signature) RehashRecursive()

RehashRecursive calls Rehash (see below) recursively.

func (*Signature) SetSignature

func (m *Signature) SetSignature(signAlgo Algorithm, privKey crypto.Signer, signedData []byte) error

SetSignature calculates the signature accordingly to arguments signAlgo, privKey and signedData; and sets all the fields of the structure Signature.

if signAlgo is zero then it is detected automatically, based on the type of the provided private key.

func (*Signature) SetSignatureByData

func (m *Signature) SetSignatureByData(sig SignatureDataInterface, hashAlgo Algorithm) error

SetSignatureByData sets all the fields of the structure Signature by accepting one of these types as the input argument `sig`: * SignatureRSAPSS * SignatureRSAASA * SignatureECDSA * SignatureSM2

func (*Signature) SetSignatureData

func (m *Signature) SetSignatureData(sig SignatureDataInterface) error

SetSignatureData sets the value of the field Data by accepting one of these types as the input argument `sig`: * SignatureRSAPSS * SignatureRSAASA * SignatureECDSA * SignatureSM2

func (*Signature) SigSchemeOffset

func (s *Signature) SigSchemeOffset() uint64

SigSchemeOffset returns the offset in bytes of field SigScheme

func (*Signature) SigSchemeTotalSize

func (s *Signature) SigSchemeTotalSize() uint64

SigSchemeSize returns the size in bytes of the value of field SigScheme

func (Signature) SignatureData

func (m Signature) SignatureData() (SignatureDataInterface, error)

SignatureData parses field Data and returns the signature as one of these types: * SignatureRSAPSS * SignatureRSAASA * SignatureECDSA * SignatureSM2

func (*Signature) TotalSize

func (s *Signature) TotalSize() uint64

Size returns the total size of the Signature.

func (*Signature) Validate

func (s *Signature) Validate() error

Validate (recursively) checks the structure if there are any unexpected values. It returns an error if so.

func (*Signature) VersionOffset

func (s *Signature) VersionOffset() uint64

VersionOffset returns the offset in bytes of field Version

func (*Signature) VersionTotalSize

func (s *Signature) VersionTotalSize() uint64

VersionSize returns the size in bytes of the value of field Version

func (*Signature) WriteTo

func (s *Signature) WriteTo(w io.Writer) (int64, error)

WriteTo writes the Signature into 'w' in format defined in the document #575623.

type SignatureDataInterface

type SignatureDataInterface interface {
	fmt.Stringer

	// Verify returns nil if signedData was indeed signed by key pk, and
	// returns an appropriate error otherwise.
	Verify(pk crypto.PublicKey, signedData []byte) error
}

SignatureDataInterface is the interface which abstracts all the signature data types.

func NewSignatureByData

func NewSignatureByData(
	signAlgo Algorithm,
	pubKey crypto.PublicKey,
	signedData []byte,
) (SignatureDataInterface, error)

NewSignatureByData returns an implementation of SignatureDataInterface, accordingly to signAlgo, publicKey and signedData.

if signAlgo is zero then it is detected automatically, based on the type of the provided private key.

func NewSignatureData

func NewSignatureData(
	signAlgo Algorithm,
	privKey crypto.Signer,
	signedData []byte,
) (SignatureDataInterface, error)

NewSignatureData returns an implementation of SignatureDataInterface, accordingly to signAlgo, privKey and signedData.

if signAlgo is zero then it is detected automatically, based on the type of the provided private key.

type SignatureECDSA

type SignatureECDSA struct {
	// R is the R component of the signature.
	R *big.Int
	// S is the S component of the signature.
	S *big.Int
}

SignatureECDSA is a structure with components of an ECDSA signature.

func (SignatureECDSA) String

func (s SignatureECDSA) String() string

String implements fmt.Stringer

func (SignatureECDSA) Verify

func (s SignatureECDSA) Verify(pkIface crypto.PublicKey, signedData []byte) error

Verify implements SignatureDataInterface.

type SignatureRSAASA

type SignatureRSAASA []byte

SignatureRSAASA is RSAASA signature bytes.

func (SignatureRSAASA) String

func (s SignatureRSAASA) String() string

String implements fmt.Stringer

func (SignatureRSAASA) Verify

func (s SignatureRSAASA) Verify(pkIface crypto.PublicKey, signedData []byte) error

Verify implements SignatureDataInterface.

type SignatureRSAPSS

type SignatureRSAPSS []byte

SignatureRSAPSS is RSAPSS signature bytes.

func (SignatureRSAPSS) String

func (s SignatureRSAPSS) String() string

String implements fmt.Stringer

func (SignatureRSAPSS) Verify

func (s SignatureRSAPSS) Verify(pkIface crypto.PublicKey, signedData []byte) error

Verify implements SignatureDataInterface.

type SignatureSM2

type SignatureSM2 struct {
	// R is the R component of the signature.
	R *big.Int
	// S is the S component of the signature.
	S *big.Int
}

SignatureSM2 is a structure with components of an SM2 signature.

func (SignatureSM2) String

func (s SignatureSM2) String() string

String implements fmt.Stringer

func (SignatureSM2) Verify

func (s SignatureSM2) Verify(pkIface crypto.PublicKey, signedData []byte) error

Verify implements SignatureDataInterface.

type StructInfo

type StructInfo struct {
	ID          StructureID
	Version     uint8
	Variable0   uint8
	ElementSize uint16
}

func NewStructInfo

func NewStructInfo() *StructInfo

NewStructInfo returns a new instance of StructInfo with all default values set.

func (*StructInfo) ElementSizeOffset

func (s *StructInfo) ElementSizeOffset() uint64

ElementSizeOffset returns the offset in bytes of field ElementSize

func (*StructInfo) ElementSizeTotalSize

func (s *StructInfo) ElementSizeTotalSize() uint64

ElementSizeSize returns the size in bytes of the value of field ElementSize

func (*StructInfo) IDOffset

func (s *StructInfo) IDOffset() uint64

IDOffset returns the offset in bytes of field ID

func (*StructInfo) IDTotalSize

func (s *StructInfo) IDTotalSize() uint64

IDSize returns the size in bytes of the value of field ID

func (*StructInfo) PrettyString

func (s *StructInfo) PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string

PrettyString returns the content of the structure in an easy-to-read format.

func (*StructInfo) ReadFrom

func (s *StructInfo) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads the StructInfo from 'r' in format defined in the document #575623.

func (*StructInfo) Rehash

func (s *StructInfo) Rehash()

Rehash sets values which are calculated automatically depending on the rest data. It is usually about the total size field of an element.

func (*StructInfo) RehashRecursive

func (s *StructInfo) RehashRecursive()

RehashRecursive calls Rehash (see below) recursively.

func (StructInfo) StructInfo

func (s StructInfo) StructInfo() StructInfo

func (*StructInfo) TotalSize

func (s *StructInfo) TotalSize() uint64

Size returns the total size of the StructInfo.

func (*StructInfo) Validate

func (s *StructInfo) Validate() error

Validate (recursively) checks the structure if there are any unexpected values. It returns an error if so.

func (*StructInfo) Variable0Offset

func (s *StructInfo) Variable0Offset() uint64

Variable0Offset returns the offset in bytes of field Variable0

func (*StructInfo) Variable0TotalSize

func (s *StructInfo) Variable0TotalSize() uint64

Variable0Size returns the size in bytes of the value of field Variable0

func (*StructInfo) VersionOffset

func (s *StructInfo) VersionOffset() uint64

VersionOffset returns the offset in bytes of field Version

func (*StructInfo) VersionTotalSize

func (s *StructInfo) VersionTotalSize() uint64

VersionSize returns the size in bytes of the value of field Version

func (*StructInfo) WriteTo

func (s *StructInfo) WriteTo(w io.Writer) (int64, error)

WriteTo writes the StructInfo into 'w' in format defined in the document #575623.

type Structure

type Structure interface {
	io.ReaderFrom
	io.WriterTo
	TotalSize() uint64
	// PrettyString returns the whole object as a structured string.
	PrettyString(depth uint, withHeader bool) string
}

type StructureID

type StructureID [8]byte

func (StructureID) String

func (s StructureID) String() string

String returns the ID as a string.

Jump to

Keyboard shortcuts

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