manifest

package
v2.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 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 (
	// 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     Algorithm = 0x0012
	AlgRSASSA  Algorithm = 0x0014
	AlgRSAPSS  Algorithm = 0x0016
	AlgECDSA   Algorithm = 0x0018
	AlgSM2     Algorithm = 0x001b
	AlgECC     Algorithm = 0x0023
)

Supported algorithms

func GetAlgFromString

func GetAlgFromString(name string) (Algorithm, error)

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

func (v Algorithm) PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string

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

func (Algorithm) ReadFrom

func (v Algorithm) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads the Algorithm from 'r' in binary format.

func (Algorithm) String

func (a Algorithm) String() string

func (Algorithm) TotalSize

func (v Algorithm) TotalSize() uint64

TotalSize returns the total size measured through binary.Size.

func (Algorithm) WriteTo

func (v Algorithm) WriteTo(w io.Writer) (int64, error)

WriteTo writes the Algorithm into 'w' in binary format.

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 (v 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) ReadFrom

func (v BitSize) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads the BitSize from 'r' in binary 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.

func (BitSize) TotalSize

func (v BitSize) TotalSize() uint64

TotalSize returns the total size measured through binary.Size.

func (BitSize) WriteTo

func (v BitSize) WriteTo(w io.Writer) (int64, error)

WriteTo writes the BitSize into 'w' in binary format.

type ChipsetACModuleInformation

type ChipsetACModuleInformation struct {
	UUID            [16]byte
	ChipsetACMType  uint8
	Version         uint8
	Length          uint16
	ChipsetIDList   uint32
	OsSinitDataVer  uint32
	MinMleHeaderVer uint32
	Capabilities    uint32
	AcmVersion      uint8
	AcmRevision     [3]uint8
	ProcessorIDList uint32
}

ChipsetACModuleInformation represents Chipset AC Module Information Table parts for all versions

func NewChipsetACModuleInformation

func NewChipsetACModuleInformation() *ChipsetACModuleInformation

NewChipsetACModuleInformation returns a new instance of ChipsetACModuleInformation with all default values set.

func (*ChipsetACModuleInformation) AcmRevisionOffset

func (s *ChipsetACModuleInformation) AcmRevisionOffset() uint64

AcmRevisionOffset returns the offset in bytes of field AcmRevision

func (*ChipsetACModuleInformation) AcmRevisionTotalSize

func (s *ChipsetACModuleInformation) AcmRevisionTotalSize() uint64

AcmRevisionSize returns the size in bytes of the value of field AcmRevision

func (*ChipsetACModuleInformation) AcmVersionOffset

func (s *ChipsetACModuleInformation) AcmVersionOffset() uint64

AcmVersionOffset returns the offset in bytes of field AcmVersion

func (*ChipsetACModuleInformation) AcmVersionTotalSize

func (s *ChipsetACModuleInformation) AcmVersionTotalSize() uint64

AcmVersionSize returns the size in bytes of the value of field AcmVersion

func (*ChipsetACModuleInformation) CapabilitiesOffset

func (s *ChipsetACModuleInformation) CapabilitiesOffset() uint64

CapabilitiesOffset returns the offset in bytes of field Capabilities

func (*ChipsetACModuleInformation) CapabilitiesTotalSize

func (s *ChipsetACModuleInformation) CapabilitiesTotalSize() uint64

CapabilitiesSize returns the size in bytes of the value of field Capabilities

func (*ChipsetACModuleInformation) ChipsetACMTypeOffset

func (s *ChipsetACModuleInformation) ChipsetACMTypeOffset() uint64

ChipsetACMTypeOffset returns the offset in bytes of field ChipsetACMType

func (*ChipsetACModuleInformation) ChipsetACMTypeTotalSize

func (s *ChipsetACModuleInformation) ChipsetACMTypeTotalSize() uint64

ChipsetACMTypeSize returns the size in bytes of the value of field ChipsetACMType

func (*ChipsetACModuleInformation) ChipsetIDListOffset

func (s *ChipsetACModuleInformation) ChipsetIDListOffset() uint64

ChipsetIDListOffset returns the offset in bytes of field ChipsetIDList

func (*ChipsetACModuleInformation) ChipsetIDListTotalSize

func (s *ChipsetACModuleInformation) ChipsetIDListTotalSize() uint64

ChipsetIDListSize returns the size in bytes of the value of field ChipsetIDList

func (*ChipsetACModuleInformation) LengthOffset

func (s *ChipsetACModuleInformation) LengthOffset() uint64

LengthOffset returns the offset in bytes of field Length

func (*ChipsetACModuleInformation) LengthTotalSize

func (s *ChipsetACModuleInformation) LengthTotalSize() uint64

LengthSize returns the size in bytes of the value of field Length

func (*ChipsetACModuleInformation) MinMleHeaderVerOffset

func (s *ChipsetACModuleInformation) MinMleHeaderVerOffset() uint64

MinMleHeaderVerOffset returns the offset in bytes of field MinMleHeaderVer

func (*ChipsetACModuleInformation) MinMleHeaderVerTotalSize

func (s *ChipsetACModuleInformation) MinMleHeaderVerTotalSize() uint64

MinMleHeaderVerSize returns the size in bytes of the value of field MinMleHeaderVer

func (*ChipsetACModuleInformation) OsSinitDataVerOffset

func (s *ChipsetACModuleInformation) OsSinitDataVerOffset() uint64

OsSinitDataVerOffset returns the offset in bytes of field OsSinitDataVer

func (*ChipsetACModuleInformation) OsSinitDataVerTotalSize

func (s *ChipsetACModuleInformation) OsSinitDataVerTotalSize() uint64

OsSinitDataVerSize returns the size in bytes of the value of field OsSinitDataVer

func (*ChipsetACModuleInformation) PrettyString

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

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

func (*ChipsetACModuleInformation) ProcessorIDListOffset

func (s *ChipsetACModuleInformation) ProcessorIDListOffset() uint64

ProcessorIDListOffset returns the offset in bytes of field ProcessorIDList

func (*ChipsetACModuleInformation) ProcessorIDListTotalSize

func (s *ChipsetACModuleInformation) ProcessorIDListTotalSize() uint64

ProcessorIDListSize returns the size in bytes of the value of field ProcessorIDList

func (*ChipsetACModuleInformation) ReadFrom

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

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

func (*ChipsetACModuleInformation) Rehash

func (s *ChipsetACModuleInformation) 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 (*ChipsetACModuleInformation) RehashRecursive

func (s *ChipsetACModuleInformation) RehashRecursive()

RehashRecursive calls Rehash (see below) recursively.

func (*ChipsetACModuleInformation) TotalSize

func (s *ChipsetACModuleInformation) TotalSize() uint64

Size returns the total size of the ChipsetACModuleInformation.

func (*ChipsetACModuleInformation) UUIDOffset

func (s *ChipsetACModuleInformation) UUIDOffset() uint64

UUIDOffset returns the offset in bytes of field UUID

func (*ChipsetACModuleInformation) UUIDTotalSize

func (s *ChipsetACModuleInformation) UUIDTotalSize() uint64

UUIDSize returns the size in bytes of the value of field UUID

func (*ChipsetACModuleInformation) Validate

func (s *ChipsetACModuleInformation) Validate() error

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

func (*ChipsetACModuleInformation) VersionOffset

func (s *ChipsetACModuleInformation) VersionOffset() uint64

VersionOffset returns the offset in bytes of field Version

func (*ChipsetACModuleInformation) VersionTotalSize

func (s *ChipsetACModuleInformation) VersionTotalSize() uint64

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

func (*ChipsetACModuleInformation) WriteTo

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

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

type ChipsetACModuleInformationV5

type ChipsetACModuleInformationV5 struct {
	Base        ChipsetACModuleInformation
	TPMInfoList uint32
}

ChipsetACModuleInformationV5 represents Chipset AC Module Information Table for version >= 5

func NewChipsetACModuleInformationV5

func NewChipsetACModuleInformationV5() *ChipsetACModuleInformationV5

NewChipsetACModuleInformationV5 returns a new instance of ChipsetACModuleInformationV5 with all default values set.

func ParseChipsetACModuleInformation

func ParseChipsetACModuleInformation(r io.Reader) (int64, ChipsetACModuleInformationV5, error)

ParseChipsetACModuleInformation parses Chipset AC Module Information Table according to the version

func (*ChipsetACModuleInformationV5) BaseOffset

func (s *ChipsetACModuleInformationV5) BaseOffset() uint64

BaseOffset returns the offset in bytes of field Base

func (*ChipsetACModuleInformationV5) BaseTotalSize

func (s *ChipsetACModuleInformationV5) BaseTotalSize() uint64

BaseSize returns the size in bytes of the value of field Base

func (*ChipsetACModuleInformationV5) PrettyString

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

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

func (*ChipsetACModuleInformationV5) ReadFrom

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

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

func (*ChipsetACModuleInformationV5) Rehash

func (s *ChipsetACModuleInformationV5) 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 (*ChipsetACModuleInformationV5) RehashRecursive

func (s *ChipsetACModuleInformationV5) RehashRecursive()

RehashRecursive calls Rehash (see below) recursively.

func (*ChipsetACModuleInformationV5) TPMInfoListOffset

func (s *ChipsetACModuleInformationV5) TPMInfoListOffset() uint64

TPMInfoListOffset returns the offset in bytes of field TPMInfoList

func (*ChipsetACModuleInformationV5) TPMInfoListTotalSize

func (s *ChipsetACModuleInformationV5) TPMInfoListTotalSize() uint64

TPMInfoListSize returns the size in bytes of the value of field TPMInfoList

func (*ChipsetACModuleInformationV5) TotalSize

func (s *ChipsetACModuleInformationV5) TotalSize() uint64

Size returns the total size of the ChipsetACModuleInformationV5.

func (*ChipsetACModuleInformationV5) Validate

func (s *ChipsetACModuleInformationV5) Validate() error

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

func (*ChipsetACModuleInformationV5) WriteTo

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

type Element

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

Element is an abstraction of an element of a manifest.

type ElementsContainer

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

ElementsContainer is an abstraction of set of elements of a manifest (for example: the root structure of BPM).

type HashList

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

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:"hsAlg"`
	HashBuffer []byte    `json:"hsBuffer"`
}

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:"keyAlg"`
	Version uint8     `require:"0x10"  json:"keyVersion"`
	KeySize BitSize   `json:"keyBitsize"`
	Data    []byte    `countValue:"keyDataSize()" json:"keyData"`
}

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:"ksVersion,omitempty"`
	Key       Key       `json:"ksKey"`
	Signature Signature `json:"ksSignature"`
}

KeySignature combines a public key and a signature in a single structure.

func NewKeySignature

func NewKeySignature() *KeySignature

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

func (*KeySignature) FillSignature

func (s *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 (s *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 (s *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 (s *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:"sigScheme"`
	Version   uint8     `require:"0x10" json:"sigVersion,omitempty"`
	KeySize   BitSize   `json:"sigKeysize,omitempty"`
	HashAlg   Algorithm `json:"sigHashAlg"`
	Data      []byte    `countValue:"KeySize.InBytes()" prettyValue:"dataPrettyValue()" json:"sigData"`
}

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 `json:"StructInfoID"`
	Version     uint8       `json:"StructInfoVersion"`
	Variable0   uint8       `json:"StructInfoVariable0"`
	ElementSize uint16      `json:"StructInfoElementSize"`
}

StructInfo is the common part of any structure of a manifest

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

StructInfo just returns StructInfo, it is a handy method if StructInfo is included anonymously to another type.

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, opts ...pretty.Option) string
}

Structure is an abstraction of a structure of a manifest.

type StructureID

type StructureID [8]byte

StructureID is the magic ID string used to identify the structure type in the manifest

func (StructureID) String

func (s StructureID) String() string

String returns the ID as a string.

type TPM2PCRExtendPolicySupport

type TPM2PCRExtendPolicySupport uint8

TPM2PCRExtendPolicySupport defined TPM2 PCR Extend policy support.

const (
	TPM2PCRExtendIllegal                  TPM2PCRExtendPolicySupport = 0
	TPM2PCRExtendMaximumAgilityPolicy     TPM2PCRExtendPolicySupport = 1
	TPM2PCRExtendMaximumPerformancePolicy TPM2PCRExtendPolicySupport = 2
	TPM2PCRExtendBothPolicies             TPM2PCRExtendPolicySupport = 3
)

Possible values of TPM2PCRExtendPolicySupport

func (TPM2PCRExtendPolicySupport) PrettyString

func (v TPM2PCRExtendPolicySupport) PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string

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

func (TPM2PCRExtendPolicySupport) ReadFrom

func (v TPM2PCRExtendPolicySupport) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads the TPM2PCRExtendPolicySupport from 'r' in binary format.

func (TPM2PCRExtendPolicySupport) TotalSize

func (v TPM2PCRExtendPolicySupport) TotalSize() uint64

TotalSize returns the total size measured through binary.Size.

func (TPM2PCRExtendPolicySupport) WriteTo

WriteTo writes the TPM2PCRExtendPolicySupport into 'w' in binary format.

type TPMCapabilities

type TPMCapabilities uint32

TPMCapabilities defines TPM capabilities

func (TPMCapabilities) PrettyString

func (v TPMCapabilities) PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string

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

func (TPMCapabilities) ReadFrom

func (v TPMCapabilities) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads the TPMCapabilities from 'r' in binary format.

func (TPMCapabilities) TPM2PCRExtendPolicySupport

func (cap TPMCapabilities) TPM2PCRExtendPolicySupport() TPM2PCRExtendPolicySupport

TPM2PCRExtendPolicySupport returns TPM2PCRExtendPolicySupport

func (TPMCapabilities) TPMFamilySupport

func (cap TPMCapabilities) TPMFamilySupport() TPMFamilySupport

TPMFamilySupport returns TPMFamilySupport

func (TPMCapabilities) TotalSize

func (v TPMCapabilities) TotalSize() uint64

TotalSize returns the total size measured through binary.Size.

func (TPMCapabilities) WriteTo

func (v TPMCapabilities) WriteTo(w io.Writer) (int64, error)

WriteTo writes the TPMCapabilities into 'w' in binary format.

type TPMFamilySupport

type TPMFamilySupport uint8

TPMFamilySupport defines TPM family support

func (TPMFamilySupport) IsDiscreteTPM12Supported

func (familySupport TPMFamilySupport) IsDiscreteTPM12Supported() bool

IsDiscreteTPM12Supported returns true if discrete TPM1.2 is supported. PrettyString-true: Discrete TPM1.2 is supported PrettyString-false: Discrete TPM1.2 is not supported

func (TPMFamilySupport) IsDiscreteTPM20Supported

func (familySupport TPMFamilySupport) IsDiscreteTPM20Supported() bool

IsDiscreteTPM20Supported returns true if discrete TPM2.0 is supported. PrettyString-true: Discrete TPM2.0 is supported PrettyString-false: Discrete TPM2.0 is not supported

func (TPMFamilySupport) IsFirmwareTPM20Supported

func (familySupport TPMFamilySupport) IsFirmwareTPM20Supported() bool

IsFirmwareTPM20Supported returns true if firmware TPM2.0 is supported. PrettyString-true: Firmware TPM2.0 is supported PrettyString-false: Firmware TPM2.0 is not supported

func (TPMFamilySupport) PrettyString

func (v TPMFamilySupport) PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string

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

func (TPMFamilySupport) ReadFrom

func (v TPMFamilySupport) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads the TPMFamilySupport from 'r' in binary format.

func (TPMFamilySupport) TotalSize

func (v TPMFamilySupport) TotalSize() uint64

TotalSize returns the total size measured through binary.Size.

func (TPMFamilySupport) WriteTo

func (v TPMFamilySupport) WriteTo(w io.Writer) (int64, error)

WriteTo writes the TPMFamilySupport into 'w' in binary format.

type TPMInfoList

type TPMInfoList struct {
	Capabilities TPMCapabilities
	Algorithms   []Algorithm
}

TPMInfoList represents TPM capabilities supported by ACM

func NewTPMInfoList

func NewTPMInfoList() *TPMInfoList

NewTPMInfoList returns a new instance of TPMInfoList with all default values set.

func (*TPMInfoList) AlgorithmsOffset

func (s *TPMInfoList) AlgorithmsOffset() uint64

AlgorithmsOffset returns the offset in bytes of field Algorithms

func (*TPMInfoList) AlgorithmsTotalSize

func (s *TPMInfoList) AlgorithmsTotalSize() uint64

AlgorithmsSize returns the size in bytes of the value of field Algorithms

func (*TPMInfoList) CapabilitiesOffset

func (s *TPMInfoList) CapabilitiesOffset() uint64

CapabilitiesOffset returns the offset in bytes of field Capabilities

func (*TPMInfoList) CapabilitiesTotalSize

func (s *TPMInfoList) CapabilitiesTotalSize() uint64

CapabilitiesSize returns the size in bytes of the value of field Capabilities

func (*TPMInfoList) PrettyString

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

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

func (*TPMInfoList) ReadFrom

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

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

func (*TPMInfoList) Rehash

func (s *TPMInfoList) 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 (*TPMInfoList) RehashRecursive

func (s *TPMInfoList) RehashRecursive()

RehashRecursive calls Rehash (see below) recursively.

func (*TPMInfoList) TotalSize

func (s *TPMInfoList) TotalSize() uint64

Size returns the total size of the TPMInfoList.

func (*TPMInfoList) Validate

func (s *TPMInfoList) Validate() error

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

func (*TPMInfoList) WriteTo

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

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

Jump to

Keyboard shortcuts

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