types

package
v0.0.0-...-341aec2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2025 License: GPL-2.0 Imports: 10 Imported by: 0

README

Firmware Data Structures

This package contains all the data structures used for parsing Mellanox firmware files (FS4 and FS5 formats).

Structure Overview

All structures are designed to match the binary layout from mstflint, with Big Endian byte order.

Common Structures
  • HWPointerEntry: 8-byte structure containing pointer and CRC
  • ITOCHeader: 32-byte Image Table of Contents header
  • ITOCEntry: 32-byte ITOC entry with complex bit packing
  • ImageInfo: 960-byte structure containing firmware metadata
  • DeviceInfo: Device-specific information
  • MFGInfo: Manufacturing information
  • VPDData: Vital Product Data
FS4-Specific Structures
  • FS4HWPointers: 64-byte Carmel hardware pointers (8 entries)
  • Uses standard ITOC/DTOC structures
FS5-Specific Structures
  • FS5HWPointers: 128-byte Gilboa hardware pointers (16 entries)
  • HashesTableHeader: Header for hashes table
  • HashTableEntry: Individual hash entries for secure boot
Security Structures
  • SignatureBlock: RSA signature blocks (256/512)
  • PublicKeyBlock: Public key storage (2048/4096)
  • ForbiddenVersionsHeader/Entry: Version blacklisting
CRC Implementation
  • Software CRC16 with polynomial 0x100b
  • Hardware CRC with special table and first 2 bytes inverted
  • Three CRC modes: INITOCENTRY, NOCRC, INSECTION

Usage with annotations

Structures are parsed via pkg/annotations using offset:"..." tags:

  • offset:"byte:N" for explicit byte offsets within the structure
  • offset:"bit:P,len:L,endian:be|le" for bitfields (absolute bit positions)
  • offset:"...,endian:be|le" to specify endianness for multi-byte fields
  • offset:"...,hex_as_dec:true" for BCD-encoded fields (e.g., years, timestamps)

Types provide Unmarshal([]byte) error and Marshal() ([]byte, error) for binary round-tripping; prefer these over ad-hoc byte slicing implemented in business logic.

Section Types

ITOC sections (0x0 - 0xFF) and DTOC sections are defined in section_names.go with human-readable names.

Documentation

Overview

Package types contains all data structures for Mellanox firmware parsing

Index

Constants

View Source
const (
	// Magic patterns
	MagicPattern       = 0x4D544657ABCDEF00 // "MTFW\xAB\xCD\xEF\x00" in big endian
	MagicPatternOffset = 0x08               // Standard offset for magic pattern in FS4
	ITOCSignature      = 0x49544F43         // "ITOC"
	DTOCSignature      = 0x44544F43         // "DTOC"

	// CRC polynomial and initial values
	CRCPolynomial = 0x100b
	CRCInitial    = 0xffff
	CRCXorOut     = 0xffff

	// Section types (from mstflint fs3_ops.h)
	SectionTypeBootCode                = 0x1
	SectionTypePCICode                 = 0x2
	SectionTypeMainCode                = 0x3
	SectionTypePCIELinkCode            = 0x4
	SectionTypeIronPrepCode            = 0x5
	SectionTypePostIronBootCode        = 0x6
	SectionTypeUpgradeCode             = 0x7
	SectionTypeHWBootCfg               = 0x8
	SectionTypeHWMainCfg               = 0x9
	SectionTypePhyUCCode               = 0xa
	SectionTypePhyUCConsts             = 0xb
	SectionTypePCIEPhyUCCode           = 0xc
	SectionTypeCCIRInfraCode           = 0xd
	SectionTypeCCIRAlgoCode            = 0xe
	SectionTypeBoot3Code               = 0xf
	SectionTypeImageInfo               = 0x10
	SectionTypeFWBootCfg               = 0x11
	SectionTypeFWMainCfg               = 0x12
	SectionTypeAPUKernel               = 0x14
	SectionTypeACECode                 = 0x15
	SectionTypeROMCode                 = 0x18
	SectionTypeResetInfo               = 0x20
	SectionTypeDbgFWINI                = 0x30
	SectionTypeDbgFWParams             = 0x32
	SectionTypeFWAdb                   = 0x33
	SectionTypeImageSignature256       = 0xa0
	SectionTypePublicKeys2048          = 0xa1
	SectionTypeForbiddenVersions       = 0xa2
	SectionTypeImageSignature512       = 0xa3
	SectionTypePublicKeys4096          = 0xa4
	SectionTypeHMACDigest              = 0xa5
	SectionTypeRsaPublicKey            = 0xa6
	SectionTypeRsa4096Signatures       = 0xa7
	SectionTypeEncryptionKeyTransition = 0xa9
	SectionTypePxirIni                 = 0xaa
	SectionTypePxirIni1                = 0xab
	SectionTypeNvdaRotCertificates     = 0xad
	SectionTypeExclkSyncInfo           = 0xb0
	SectionTypeMainPagesHashes         = 0xb1
	SectionTypeMainPagesLockedHashes   = 0xb2
	SectionTypeStrnMain                = 0xb4
	SectionTypeStrnIron                = 0xb5
	SectionTypeStrnTile                = 0xb6
	SectionTypeMainData                = 0xd3
	SectionTypeFwDebugDump2            = 0xd4
	SectionTypeSecurityLog             = 0xd5
	SectionTypeMfgInfo                 = 0xe0
	SectionTypeDevInfo                 = 0xe1
	SectionTypeNvData1                 = 0xe2
	SectionTypeVpdR0                   = 0xe3
	SectionTypeNvData2                 = 0xe4
	SectionTypeFwNvLog                 = 0xe5
	SectionTypeNvData0                 = 0xe6
	SectionTypeDevInfo1                = 0xe7
	SectionTypeDevInfo2                = 0xe8
	SectionTypeCRDumpMaskData          = 0xe9
	SectionTypeFwInternalUsage         = 0xea
	SectionTypeProgrammableHwFw1       = 0xeb
	SectionTypeProgrammableHwFw2       = 0xec
	SectionTypeDigitalCertPtr          = 0xed
	SectionTypeDigitalCertRw           = 0xee
	SectionTypeLcIni1Table             = 0xef
	SectionTypeLcIni2Table             = 0xf0
	SectionTypeLcIniNvData             = 0xf1
	SectionTypeCertChain0              = 0xf2
	SectionTypeDigitalCaCertRw         = 0xf3
	SectionTypeCertificateChains1      = 0xf4
	SectionTypeCertificateChains2      = 0xf5
	SectionTypeRootCertificates1       = 0xf6
	SectionTypeRootCertificates2       = 0xf7
	SectionTypeToolsArea               = 0xf9
	SectionTypeHashesTable             = 0xfa
	SectionTypeHwPtr                   = 0xfb
	SectionTypeFwDebugDump             = 0xfc
	SectionTypeItoc                    = 0xfd
	SectionTypeDtoc                    = 0xfe
	SectionTypeEnd                     = 0xff

	// Special section types for sections not in ITOC/DTOC
	SectionTypeBoot2 = 0x100 // Special marker for BOOT2 section

	// NOCRC flag value
	NOCRC = 1
)
View Source
const (

	// Standard firmware sizes
	FirmwareSize8MB  = 0x00800000 // 8MB
	FirmwareSize16MB = 0x01000000 // 16MB
	FirmwareSize32MB = 0x02000000 // 32MB
	FirmwareSize64MB = 0x04000000 // 64MB

	// DTOC location for different firmware sizes
	DTOCOffset8MB  = 0x007ff000
	DTOCOffset16MB = 0x00fff000
	DTOCOffset32MB = 0x01fff000
	DTOCOffset64MB = 0x03fff000

	// Hardware pointer offsets from magic
	HWPointersOffsetFromMagic = 0x18 // 24 bytes
	HWPointersSize            = 128  // 16 entries * 8 bytes

	// BOOT2 section constants
	Boot2MaxSize = 0x8000 // 32KB max size

	// Standard CRC positions
	CRCSize = 4 // CRC32 is 4 bytes

	// Section alignment
	SectionAlignmentDword  = 4      // Sections aligned to dwords
	SectionAlignmentSector = 0x1000 // 4KB sector alignment

	// Special addresses
	InvalidAddress = 0xFFFFFFFF
	NullAddress    = 0x00000000

	// Header sizes
	ITOCHeaderSize = 32 // 8 dwords
	ITOCEntrySize  = 32 // 8 dwords

	// Tools area constants
	ToolsAreaSize = 0x40 // 64 bytes

	// Image info constants
	ImageInfoSize = 1024 // Standard size

	// DEV_INFO and MFG_INFO constants
	DevInfoSize = 512 // 0x200 - image_layout_device_info size
	MfgInfoSize = 320 // 0x140 - image_layout_mfg_info size

	// Padding patterns
	PaddingByteFF    uint8  = 0xFF
	PaddingByte00    uint8  = 0x00
	PaddingPatternFF uint32 = 0xFFFFFFFF

	// Section type ranges for validation
	SectionTypeImageMin  = 0x10 // Image sections start at 0x10
	SectionTypeImageMax  = 0x5F // Image sections end at 0x5F
	SectionTypeDeviceMin = 0x80 // Device sections start at 0x80
	SectionTypeDeviceMax = 0xFF // Device sections end at 0xFF

	// Authentication window constants
	AuthWindowAlignment = 0x1000 // 4KB alignment

	// Secure boot constants
	SignatureSize256  = 256 // RSA-2048 signature
	SignatureSize512  = 512 // RSA-4096 signature
	PublicKeySize2048 = 256 // RSA-2048 public key
	PublicKeySize4096 = 512 // RSA-4096 public key

	// Hash table constants
	HashesTableSize    = 2052                 // 0x804
	HashesTableMagic   = 0x484153485F5441424C // "HASH_TABL"
	HashTableEntrySize = 64                   // 32-byte hash + metadata

	// Firmware format identifiers
	FS3Magic = 0x4D544657 // "MTFW" for FS3

	// Boot version offset from magic pattern
	// Based on mstflint's FS4_BOOT_VERSION_OFFSET in mlxfwops/lib/fw_ops.h:492
	BootVersionOffset = 0x10 // Offset to boot version structure from magic pattern

	// Image format version values
	// Based on mstflint's enum in mlxfwops/lib/fw_ops.h:523-526
	ImageFormatVersionFS2 = 0
	ImageFormatVersionFS3 = 3
	ImageFormatVersionFS4 = 1
	ImageFormatVersionFS5 = 2
)

Firmware header constants based on mstflint definitions

View Source
const (
	SecurityAttributeNone          = 0x0
	SecurityAttributeEncrypted     = 0x1
	SecurityAttributeSigned        = 0x2
	SecurityAttributeCsCrypto      = 0x4
	SecurityAttributeCsDevelopment = 0x8
	SecurityAttributeDebugFW       = 0x10
)

SecurityAttribute constants

Variables

View Source
var CRC16Table2 = [256]uint16{}/* 256 elements not displayed */

CRC16Table2 is the hardware CRC table from calc_hw_crc.c This table is used for hardware CRC calculations

View Source
var MagicSearchOffsets = []uint32{
	0x0, 0x10000, 0x20000, 0x40000, 0x80000,
	0x100000, 0x200000, 0x400000, 0x800000,
	0x1000000, 0x2000000,
}

Search offsets for magic pattern

View Source
var SMMFlags = SecurityModeMask{
	MCC_EN:                  0x1,
	DEBUG_FW:                0x1 << 1,
	SIGNED_FW:               0x1 << 2,
	SECURE_FW:               0x1 << 3,
	DEV_FW:                  0x1 << 4,
	CS_TOKEN:                0x1 << 5,
	DBG_TOKEN:               0x1 << 6,
	CRYPTO_TO_COMMISSIONING: 0x1 << 7,
	RMCS_TOKEN:              0x1 << 8,
	RMDT_TOKEN:              0x1 << 9,
}

SMMFlags contains the security mode mask values

Functions

func AlignToDword

func AlignToDword(size uint32) uint32

AlignToDword aligns a size to dword boundary

func AlignToSector

func AlignToSector(addr uint32) uint32

AlignToSector aligns an address to sector boundary

func CalculateNumSections

func CalculateNumSections(firmwareData []byte, itocOffset uint32) (int, error)

CalculateNumSections calculates the actual number of valid sections in an ITOC by reading entries until an invalid entry is found

func GetDTOCOffset

func GetDTOCOffset(firmwareSize uint32) uint32

GetDTOCOffset returns the DTOC offset for a given firmware size

func GetDTOCSectionTypeName

func GetDTOCSectionTypeName(sectionType uint8) string

GetDTOCSectionTypeName returns a human-readable name for a DTOC section type

func GetSectionTypeByName

func GetSectionTypeByName(name string) uint16

GetSectionTypeByName returns the section type for a given name

func GetSectionTypeName

func GetSectionTypeName(sectionType uint16) string

GetSectionTypeName returns a human-readable name for a section type

func IsDeviceSection

func IsDeviceSection(sectionType uint16) bool

IsDeviceSection checks if a section type is a device section

func IsImageSection

func IsImageSection(sectionType uint16) bool

IsImageSection checks if a section type is an image section

func IsValidSectionType

func IsValidSectionType(sectionType uint16) bool

IsValidSectionType checks if a section type is valid

func MarshalBE

func MarshalBE(v interface{}) ([]byte, error)

MarshalBE marshals a struct to binary big-endian format

func MarshalLE

func MarshalLE(v interface{}) ([]byte, error)

MarshalLE marshals a struct to binary little-endian format

Types

type BinaryVersion

type BinaryVersion struct {
	Length   uint16 `offset:"byte:0,endian:be"`               // Length of the structure
	Type     uint8  `offset:"byte:2"`                         // Type identifier
	Version  uint8  `offset:"byte:3"`                         // Version number
	Reserved uint32 `offset:"byte:4,endian:be,reserved:true"` // Reserved field
}

BinaryVersion represents the binary version structure used in Tools Area Based on tools_binary_header from mstflint

func (*BinaryVersion) Marshal

func (b *BinaryVersion) Marshal() ([]byte, error)

Marshal marshals the annotated structure into binary data

func (*BinaryVersion) Unmarshal

func (b *BinaryVersion) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into the annotated structure

type Boot2Header

type Boot2Header struct {
	Magic    uint32 `offset:"byte:0,endian:be"`                // Magic value
	Version  uint32 `offset:"byte:4,endian:be"`                // Boot2 version
	Size     uint32 `offset:"byte:8,endian:be"`                // Size of Boot2 section
	Reserved uint32 `offset:"byte:12,endian:be,reserved:true"` // Reserved field
}

Boot2Header represents the Boot2 section header

func (*Boot2Header) Marshal

func (b *Boot2Header) Marshal() ([]byte, error)

Marshal marshals the annotated structure into binary data

func (*Boot2Header) Unmarshal

func (b *Boot2Header) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into the annotated structure

type BootVersion

type BootVersion struct {
	MajorVersion uint16 // offset 0x0.16-0x0.31
	MinorVersion uint16 // offset 0x0.0-0x0.15
	SubVersion   uint16 // offset 0x4.16-0x4.31
	Reserved     uint16 // offset 0x4.0-0x4.15
}

BootVersion represents the boot version structure Based on image_layout_boot_version from mstflint

func (*BootVersion) Marshal

func (b *BootVersion) Marshal() ([]byte, error)

func (*BootVersion) Unmarshal

func (b *BootVersion) Unmarshal(data []byte) error

Marshal/Unmarshal methods for BootVersion

type CRCAlgorithm

type CRCAlgorithm uint8

CRCAlgorithm represents the algorithm used for CRC calculation

const (
	// CRCAlgorithmSoftware uses software CRC16 (polynomial 0x100b)
	CRCAlgorithmSoftware CRCAlgorithm = iota
	// CRCAlgorithmHardware uses hardware CRC16 (calc_hw_crc with crc16table2)
	CRCAlgorithmHardware
)

func GetSectionCRCAlgorithm

func GetSectionCRCAlgorithm(sectionType uint16) CRCAlgorithm

GetSectionCRCAlgorithm returns the CRC algorithm used for a specific section type This is the single source of truth for CRC algorithm selection

func (CRCAlgorithm) String

func (c CRCAlgorithm) String() string

String returns the string representation of the CRC algorithm

type CRCType

type CRCType uint8

CRCType represents the type of CRC verification

const (
	// CRCInITOCEntry means CRC is stored in ITOC entry
	CRCInITOCEntry CRCType = 0
	// CRCNone means no CRC verification
	CRCNone CRCType = 1
	// CRCInSection means CRC is stored at end of section
	CRCInSection CRCType = 2
)

func (CRCType) MarshalJSON

func (c CRCType) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (CRCType) String

func (c CRCType) String() string

String returns the string representation of the CRC type

func (*CRCType) UnmarshalJSON

func (c *CRCType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type CRDumpMaskData

type CRDumpMaskData struct {
	Version  uint32    `offset:"0x0,endian:be"` // Version of the mask data format
	MaskSize uint32    `offset:"0x4,endian:be"` // Size of the mask data
	Reserved [8]uint32 `offset:"0x8,endian:be"` // Reserved

}

CRDumpMaskData represents the CRDUMP_MASK_DATA section with annotations

func (*CRDumpMaskData) Marshal

func (c *CRDumpMaskData) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*CRDumpMaskData) MarshalWithReserved

func (c *CRDumpMaskData) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals to binary data including reserved fields

func (*CRDumpMaskData) Unmarshal

func (c *CRDumpMaskData) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

func (*CRDumpMaskData) UnmarshalWithReserved

func (c *CRDumpMaskData) UnmarshalWithReserved(data []byte) error

UnmarshalWithReserved unmarshals binary data including reserved fields

type CRDumpMaskDataJSON

type CRDumpMaskDataJSON struct {
	Version  uint32 `json:"version"`
	MaskSize uint32 `json:"mask_size"`
	DataSize int    `json:"data_size"`
}

CRDumpMaskDataJSON represents CRDUMP_MASK_DATA section data in JSON

type CertChain

type CertChain struct {
	ChainLength uint32    `offset:"0x0,endian:be"`     // Number of certificates in chain
	Reserved    [12]uint8 `offset:"0x4,reserved:true"` // Reserved
}

CertChain represents CERT_CHAIN_0 section with annotations

func (*CertChain) Marshal

func (c *CertChain) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*CertChain) Unmarshal

func (c *CertChain) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type CertificateChains

type CertificateChains struct {
	Version    uint32   `offset:"0x0,endian:be"`     // Version
	ChainCount uint32   `offset:"0x4,endian:be"`     // Number of chains
	Reserved   [8]uint8 `offset:"0x8,reserved:true"` // Reserved
}

CertificateChains represents CERTIFICATE_CHAINS sections with annotations

func (*CertificateChains) Marshal

func (c *CertificateChains) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*CertificateChains) Unmarshal

func (c *CertificateChains) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type DBGFwIni

type DBGFwIni struct {
	CompressionMethod uint32 `offset:"0x0,endian:be"` // 0=Uncompressed, 1=Zlib, 2=LZMA
	UncompressedSize  uint32 `offset:"0x4,endian:be"` // Size when uncompressed
	CompressedSize    uint32 `offset:"0x8,endian:be"` // Size of compressed data
	Reserved          uint32 `offset:"0xc,endian:be"` // Reserved

}

DBGFwIni represents the DBG_FW_INI section with annotations

func (*DBGFwIni) Marshal

func (d *DBGFwIni) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*DBGFwIni) Unmarshal

func (d *DBGFwIni) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type DBGFwParams

type DBGFwParams struct {
	CompressionMethod uint32 `offset:"0x0,endian:be"` // 0=Uncompressed, 1=Zlib, 2=LZMA
	UncompressedSize  uint32 `offset:"0x4,endian:be"` // Size when uncompressed
	CompressedSize    uint32 `offset:"0x8,endian:be"` // Size of compressed data
	Reserved          uint32 `offset:"0xc,endian:be"` // Reserved

}

DBGFwParams represents the DBG_FW_PARAMS section with annotations

func (*DBGFwParams) Marshal

func (d *DBGFwParams) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*DBGFwParams) Unmarshal

func (d *DBGFwParams) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type DTOCEntryJSON

type DTOCEntryJSON struct {
	Type             uint16 `json:"type"`
	Size             uint32 `json:"size"`
	ParamStartOffset uint32 `json:"param_start_offset"`
	ParamEndOffset   uint32 `json:"param_end_offset"`
	DataStartOffset  uint32 `json:"data_start_offset"`
	DataEndOffset    uint32 `json:"data_end_offset"`
	CRC              uint16 `json:"crc"`
}

DTOCEntryJSON represents a DTOC entry in JSON

type DTOCHeaderJSON

type DTOCHeaderJSON struct {
	IdentifierLo      uint32 `json:"identifier_lo"`
	IdentifierHi      uint32 `json:"identifier_hi"`
	Version           uint8  `json:"version"`
	Reserved0         uint8  `json:"reserved0"`
	Reserved1         uint16 `json:"reserved1"`
	Reserved2         uint32 `json:"reserved2"`
	Reserved3         uint32 `json:"reserved3"`
	Reserved4         uint32 `json:"reserved4"`
	NextHeaderPointer uint32 `json:"next_header_pointer"`
	NextHeaderSize    uint32 `json:"next_header_size"`
	CRC               uint32 `json:"crc"`
}

DTOCHeaderJSON represents a DTOC header in JSON

type DTOCJSON

type DTOCJSON struct {
	Header  DTOCHeaderJSON  `json:"header"`
	Entries []DTOCEntryJSON `json:"entries"`
}

DTOCJSON represents a DTOC section in JSON

type DevInfo

type DevInfo struct {
	Signature0   uint32    `offset:"byte:0,endian:be" json:"signature0"`     // "mDevInfo"
	Signature1   uint32    `offset:"byte:4,endian:be" json:"signature1"`     // "#B.."
	Signature2   uint32    `offset:"byte:8,endian:be" json:"signature2"`     // "baca"
	Signature3   uint32    `offset:"byte:12,endian:be" json:"signature3"`    // "fe00"
	MinorVersion uint8     `offset:"byte:16" json:"minor_version"`           // offset 0x10
	MajorVersion uint16    `offset:"byte:17,endian:be" json:"major_version"` // offset 0x11
	Reserved1    uint8     `offset:"byte:19,reserved:true" json:"reserved1"` // offset 0x13
	Reserved2    [12]byte  `offset:"byte:20,reserved:true" json:"reserved2"` // offset 0x14-0x1f
	Guids        UidEntry  `offset:"byte:32" json:"guids"`                   // offset 0x20 - GUID allocation info
	Macs         UidEntry  `offset:"byte:48" json:"macs"`                    // offset 0x30 - MAC allocation info
	Reserved3    [444]byte `offset:"byte:64,reserved:true" json:"reserved3"` // offset 0x40 - padding to 0x1fc
	CRC          uint32    `offset:"byte:508,endian:be" json:"crc"`          // offset 0x1fc - CRC32 field (lower 16 bits contain CRC16)

	// The firmware has a 4-byte CRC trailer after this structure at offset 0x200
	// This field is not part of the binary structure but is used for JSON marshaling
	TrailerCRC uint16 `offset:"-" json:"original_crc,omitempty"` // CRC after the struct (from ITOC)
}

DevInfo represents the DEV_INFO section structure using annotations Based on mstflint's image_layout_device_info structure

func (*DevInfo) Marshal

func (d *DevInfo) Marshal() ([]byte, error)

Marshal marshals DevInfo into binary data

func (*DevInfo) Unmarshal

func (d *DevInfo) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into DevInfo

type DevInfoJSON

type DevInfoJSON struct {
	Signature0   uint32    `json:"signature0"`
	Signature1   uint32    `json:"signature1"`
	Signature2   uint32    `json:"signature2"`
	Signature3   uint32    `json:"signature3"`
	MinorVersion uint8     `json:"minor_version"`
	MajorVersion uint16    `json:"major_version"`
	Reserved1    uint8     `json:"reserved1"`
	Reserved2    []byte    `json:"reserved2"`
	Guids        GuidsJSON `json:"guids"`
	Macs         MacsJSON  `json:"macs"`
	Reserved3    []byte    `json:"reserved3"`
	Reserved4    uint16    `json:"reserved4"`
	CRC          uint16    `json:"crc"`
	OriginalCRC  uint16    `json:"original_crc"`
}

DevInfoJSON is a JSON-serializable version of DevInfo

type DeviceInfoExtended

type DeviceInfoExtended struct {
	Signature     uint32          // offset 0x0
	MinorVersion  uint16          // offset 0x4.0-0x4.15
	MajorVersion  uint16          // offset 0x4.16-0x4.31
	Reserved1     [24]uint8       // offset 0x8-0x20
	GUIDs         Guids           // offset 0x20-0x120
	Reserved2     [48]uint8       // offset 0x120-0x150
	VSD           [208]uint8      // offset 0x150-0x220
	OperationKeys [4]OperationKey // offset 0x220-0x260
	Reserved3     [416]uint8      // offset 0x260-0x400
}

DeviceInfoExtended represents the extended device info structure Based on image_layout_device_info from mstflint

func (*DeviceInfoExtended) Marshal

func (d *DeviceInfoExtended) Marshal() ([]byte, error)

func (*DeviceInfoExtended) Unmarshal

func (d *DeviceInfoExtended) Unmarshal(data []byte) error

Marshal/Unmarshal methods for DeviceInfoExtended

type DigitalCertPtr

type DigitalCertPtr struct {
	CertType   uint32    `offset:"0x0,endian:be"`     // Certificate type
	CertOffset uint32    `offset:"0x4,endian:be"`     // Offset to certificate
	CertSize   uint32    `offset:"0x8,endian:be"`     // Certificate size
	Reserved   [28]uint8 `offset:"0xc,reserved:true"` // Reserved (28 bytes to make total 40)
}

DigitalCertPtr represents DIGITAL_CERT_PTR section with annotations

func (*DigitalCertPtr) Marshal

func (d *DigitalCertPtr) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*DigitalCertPtr) MarshalWithReserved

func (d *DigitalCertPtr) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals to binary data including reserved fields

func (*DigitalCertPtr) Unmarshal

func (d *DigitalCertPtr) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

func (*DigitalCertPtr) UnmarshalWithReserved

func (d *DigitalCertPtr) UnmarshalWithReserved(data []byte) error

UnmarshalWithReserved unmarshals binary data including reserved fields

type DigitalCertPtrJSON

type DigitalCertPtrJSON struct {
	CertType   uint32 `json:"cert_type"`
	CertOffset string `json:"cert_offset"`
	CertSize   uint32 `json:"cert_size"`
}

DigitalCertPtrJSON represents DIGITAL_CERT_PTR section data in JSON

type DigitalCertRW

type DigitalCertRW struct {
	CertType    uint32      `offset:"0x0,endian:be"`      // Certificate type
	CertSize    uint32      `offset:"0x4,endian:be"`      // Certificate size
	ValidFrom   uint64      `offset:"0x8,endian:be"`      // Validity start timestamp
	ValidTo     uint64      `offset:"0x10,endian:be"`     // Validity end timestamp
	Reserved    [32]uint8   `offset:"0x18,reserved:true"` // Reserved
	Certificate [4096]uint8 `offset:"0x38"`               // Certificate data (up to 4K)
}

DigitalCertRW represents DIGITAL_CERT_RW section with annotations

func (*DigitalCertRW) Marshal

func (d *DigitalCertRW) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*DigitalCertRW) MarshalWithReserved

func (d *DigitalCertRW) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals to binary data including reserved fields

func (*DigitalCertRW) Unmarshal

func (d *DigitalCertRW) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

func (*DigitalCertRW) UnmarshalWithReserved

func (d *DigitalCertRW) UnmarshalWithReserved(data []byte) error

UnmarshalWithReserved unmarshals binary data including reserved fields

type DigitalCertRWJSON

type DigitalCertRWJSON struct {
	CertType       uint32 `json:"cert_type"`
	CertSize       uint32 `json:"cert_size"`
	ValidFrom      uint64 `json:"valid_from"`
	ValidTo        uint64 `json:"valid_to"`
	ActualCertSize int    `json:"actual_cert_size"`
	CertPreview    string `json:"cert_preview,omitempty"`
}

DigitalCertRWJSON represents DIGITAL_CERT_RW section data in JSON

type FS3ITOCEntry

type FS3ITOCEntry struct {
	// Per cibfw_itoc_entry_{pack,unpack} offsets
	// size: offset=8 bits, len=22; type: offset=0, len=8
	SizeDwords uint32 `offset:"bit:8,len:22,endian:be"`
	Type       uint8  `offset:"bit:0,len:8,endian:be"`

	// param0: offset=34,len=30; flags at 33 and 32
	Param0       uint32 `offset:"bit:34,len:30,endian:be"`
	CacheLineCRC bool   `offset:"bit:33,endian:be"`
	ZippedImage  bool   `offset:"bit:32,endian:be"`

	// param1: offset=64, 4 bytes
	Param1 uint32 `offset:"bit:64,len:32,endian:be"`

	// flash_addr: offset=161,len=29; relative_addr: offset=160,len=1
	FlashAddrDwords uint32 `offset:"bit:161,len:29,endian:be"`
	RelativeAddr    bool   `offset:"bit:160,endian:be"`

	// section_crc: offset=208,len=16; no_crc: offset=207,len=1; device_data: offset=206,len=1
	SectionCRC uint16 `offset:"bit:208,len:16,endian:be"`
	NoCRC      bool   `offset:"bit:207,endian:be"`
	DeviceData bool   `offset:"bit:206,endian:be"`

	// itoc_entry_crc: offset=240,len=16
	ITOCEntryCRC uint16 `offset:"bit:240,len:16,endian:be"`
}

FS3ITOCEntry represents the FS3/CIB ITOC entry (32 bytes) Matches cibfw_itoc_entry layout

func (*FS3ITOCEntry) Marshal

func (e *FS3ITOCEntry) Marshal() ([]byte, error)

func (*FS3ITOCEntry) Unmarshal

func (e *FS3ITOCEntry) Unmarshal(data []byte) error

type FS3ITOCHeader

type FS3ITOCHeader struct {
	Signature0 uint32 `offset:"byte:0,endian:be"`        // 0x0: should be ITOC signature ("ITOC")
	Signature1 uint32 `offset:"byte:4,endian:be"`        // 0x4: 0x04081516
	Signature2 uint32 `offset:"byte:8,endian:be"`        // 0x8: 0x2342cafa
	Signature3 uint32 `offset:"byte:12,endian:be"`       // 0xC: 0xbacafe00
	Version    uint8  `offset:"bit:152,len:8,endian:be"` // per cibfw_itoc_header_unpack: offset=152 bits
	// 0x11..0x1B reserved
	ITOCEntryCRC uint16 `offset:"byte:28,endian:be"` // 0x1C: CRC over header (except itself)
}

FS3ITOCHeader represents the FS3/CIB ITOC header (32 bytes) Fields and offsets mirror cibfw_itoc_header

func (*FS3ITOCHeader) Marshal

func (h *FS3ITOCHeader) Marshal() ([]byte, error)

func (*FS3ITOCHeader) Unmarshal

func (h *FS3ITOCHeader) Unmarshal(data []byte) error

type FS4BootVersionStruct

type FS4BootVersionStruct struct {
	MinorVersion       uint8 `offset:"bit:0,len:8,endian:be"`  // offset 0x0, bits 0-7
	MajorVersion       uint8 `offset:"bit:8,len:8,endian:be"`  // offset 0x0, bits 8-15
	Reserved           uint8 `offset:"bit:16,len:8,endian:be"` // offset 0x0, bits 16-23
	ImageFormatVersion uint8 `offset:"bit:24,len:8,endian:be"` // offset 0x0, bits 24-31
}

FS4BootVersionStruct represents the boot version structure for FS4 with annotations

func (*FS4BootVersionStruct) Marshal

func (b *FS4BootVersionStruct) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4BootVersionStruct) Unmarshal

func (b *FS4BootVersionStruct) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4ComponentAuthenticationConfiguration

type FS4ComponentAuthenticationConfiguration struct {
	AuthType         uint8  `offset:"bit:0,len:8,endian:be"`  // bits 0-7: 0-FW_BURN_NONE, 1-SHA256, 2-SHA512, 3-RSA2048, 4-RSA4096
	Reserved1        uint32 `offset:"bit:8,len:17,endian:be"` // bits 8-24: reserved
	CRTokenEn        uint8  `offset:"bit:25,len:1,endian:be"` // bit 25: challenge-response token enable
	BTCTokenEn       uint8  `offset:"bit:26,len:1,endian:be"` // bit 26: back to commissioning token enable
	FRCEn            uint8  `offset:"bit:27,len:1,endian:be"` // bit 27: factory re-configuration enable
	MLNXNVConfigEn   uint8  `offset:"bit:28,len:1,endian:be"` // bit 28: MLNX nvconfig enable
	VendorNVConfigEn uint8  `offset:"bit:29,len:1,endian:be"` // bit 29: vendor nvconfig enable
	CSTokenEn        uint8  `offset:"bit:30,len:1,endian:be"` // bit 30: CS token enable
	FWEn             uint8  `offset:"bit:31,len:1,endian:be"` // bit 31: firmware enable
}

FS4ComponentAuthenticationConfiguration represents authentication configuration for FS4 with annotations

func (*FS4ComponentAuthenticationConfiguration) Marshal

Marshal marshals to binary data

func (*FS4ComponentAuthenticationConfiguration) Unmarshal

func (c *FS4ComponentAuthenticationConfiguration) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4FilePublicKeys

type FS4FilePublicKeys struct {
	ComponentAuthConfig FS4ComponentAuthenticationConfiguration `offset:"0x0"`            // offset 0x0
	Reserved1           [8]uint8                                `offset:"0x4"`            // padding
	KeypairExp          uint32                                  `offset:"0xc,endian:be"`  // offset 0xc: usually 65537
	KeypairUUID         [4]uint32                               `offset:"0x10,endian:be"` // offset 0x10-0x1c: UUID
	Key                 [64]uint32                              `offset:"0x20,endian:be"` // offset 0x20-0x11c: 2048-bit key
}

FS4FilePublicKeys represents the file public keys structure (2048-bit RSA) for FS4 with annotations

func (*FS4FilePublicKeys) Marshal

func (f *FS4FilePublicKeys) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4FilePublicKeys) Unmarshal

func (f *FS4FilePublicKeys) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4FilePublicKeys2

type FS4FilePublicKeys2 struct {
	ComponentAuthConfig FS4ComponentAuthenticationConfiguration `offset:"0x0"`            // offset 0x0
	Reserved1           [8]uint8                                `offset:"0x4"`            // padding
	KeypairExp          uint32                                  `offset:"0xc,endian:be"`  // offset 0xc: usually 65537
	KeypairUUID         [4]uint32                               `offset:"0x10,endian:be"` // offset 0x10-0x1c: UUID
	Key                 [128]uint32                             `offset:"0x20,endian:be"` // offset 0x20-0x21c: 4096-bit key
}

FS4FilePublicKeys2 represents the file public keys structure (4096-bit RSA) for FS4 with annotations

func (*FS4FilePublicKeys2) Marshal

func (f *FS4FilePublicKeys2) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4FilePublicKeys2) Unmarshal

func (f *FS4FilePublicKeys2) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4FilePublicKeys3

type FS4FilePublicKeys3 struct {
	KeypairExp          uint32                                  `offset:"0x0,endian:be"`  // offset 0x0: usually 65537
	KeypairUUID         [4]uint32                               `offset:"0x4,endian:be"`  // offset 0x4-0x10: UUID
	Key                 [128]uint32                             `offset:"0x14,endian:be"` // offset 0x14-0x210: 4096-bit key
	ComponentAuthConfig FS4ComponentAuthenticationConfiguration `offset:"0x214"`          // offset 0x214
	Reserved            [8]uint8                                `offset:"0x218"`          // padding to end
}

FS4FilePublicKeys3 represents the file public keys structure (alternate layout) for FS4 with annotations

func (*FS4FilePublicKeys3) Marshal

func (f *FS4FilePublicKeys3) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4FilePublicKeys3) Unmarshal

func (f *FS4FilePublicKeys3) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4HWPointers

type FS4HWPointers struct {
	BootRecordPtr          HWPointerEntry `offset:"byte:0" json:"boot_record_ptr"`           // offset 0x0
	Boot2Ptr               HWPointerEntry `offset:"byte:8" json:"boot2_ptr"`                 // offset 0x8
	TOCPtr                 HWPointerEntry `offset:"byte:16" json:"toc_ptr"`                  // offset 0x10
	ToolsPtr               HWPointerEntry `offset:"byte:24" json:"tools_ptr"`                // offset 0x18
	AuthenticationStartPtr HWPointerEntry `offset:"byte:32" json:"authentication_start_ptr"` // offset 0x20
	AuthenticationEndPtr   HWPointerEntry `offset:"byte:40" json:"authentication_end_ptr"`   // offset 0x28
	DigestPtr              HWPointerEntry `offset:"byte:48" json:"digest_ptr"`               // offset 0x30
	DigestRecoveryKeyPtr   HWPointerEntry `offset:"byte:56" json:"digest_recovery_key_ptr"`  // offset 0x38
	FWWindowStartPtr       HWPointerEntry `offset:"byte:64" json:"fw_window_start_ptr"`      // offset 0x40
	FWWindowEndPtr         HWPointerEntry `offset:"byte:72" json:"fw_window_end_ptr"`        // offset 0x48
	ImageInfoSectionPtr    HWPointerEntry `offset:"byte:80" json:"image_info_section_ptr"`   // offset 0x50
	ImageSignaturePtr      HWPointerEntry `offset:"byte:88" json:"image_signature_ptr"`      // offset 0x58
	PublicKeyPtr           HWPointerEntry `offset:"byte:96" json:"public_key_ptr"`           // offset 0x60
	FWSecurityVersionPtr   HWPointerEntry `offset:"byte:104" json:"fw_security_version_ptr"` // offset 0x68
	GCMIVDeltaPtr          HWPointerEntry `offset:"byte:112" json:"gcm_iv_delta_ptr"`        // offset 0x70
	HashesTablePtr         HWPointerEntry `offset:"byte:120" json:"hashes_table_ptr"`        // offset 0x78
}

FS4HWPointers represents the Carmel hardware pointers structure (128 bytes) using annotations Based on image_layout_hw_pointers_carmel from mstflint

func (*FS4HWPointers) Marshal

func (h *FS4HWPointers) Marshal() ([]byte, error)

Marshal marshals FS4HWPointers into binary data

func (*FS4HWPointers) Unmarshal

func (h *FS4HWPointers) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into FS4HWPointers

type FS4HWPointersJSON

type FS4HWPointersJSON struct {
	BootRecordPtr        HWPointerEntryJSON `json:"boot_record_ptr"`
	Boot2Ptr             HWPointerEntryJSON `json:"boot2_ptr"`
	TOCPtr               HWPointerEntryJSON `json:"toc_ptr"`
	ToolsPtr             HWPointerEntryJSON `json:"tools_ptr"`
	FWWindowStartPtr     HWPointerEntryJSON `json:"fw_window_start_ptr"`
	FWWindowEndPtr       HWPointerEntryJSON `json:"fw_window_end_ptr"`
	ImageInfoSectionPtr  HWPointerEntryJSON `json:"image_info_section_ptr"`
	HashesTablePtr       HWPointerEntryJSON `json:"hashes_table_ptr"`
	DigestRecoveryKeyPtr HWPointerEntryJSON `json:"digest_recovery_key_ptr"`
	DigestPtr            HWPointerEntryJSON `json:"digest_ptr"`
}

FS4HWPointersJSON represents FS4 hardware pointers in JSON

type FS4HashesTable

type FS4HashesTable struct {
	Header FS4HashesTableHeader `offset:"0x0"`             // offset 0x0-0xb (12 bytes)
	Htoc   FS4Htoc              `offset:"0xc"`             // offset 0xc-0xfb (240 bytes)
	Hash   [28]FS4HtocHash      `offset:"0xfc"`            // offset 0xfc-0x7fb (28 * 64 = 1792 bytes)
	CRC    uint32               `offset:"0x7fc,endian:be"` // offset 0x7fc: CRC at end
}

FS4HashesTable represents the complete hashes table structure for FS4 with annotations

func (*FS4HashesTable) Marshal

func (h *FS4HashesTable) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4HashesTable) Unmarshal

func (h *FS4HashesTable) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4HashesTableHeader

type FS4HashesTableHeader struct {
	LoadAddress uint32 `offset:"0x0,endian:be"` // offset 0x0: hard-coded to 0
	DwSize      uint32 `offset:"0x4,endian:be"` // offset 0x4: num of payload DWs + 1
	CRC         uint16 `offset:"0x8,endian:be"` // offset 0x8: calculated over first 2 DWs
	Reserved    uint16 `offset:"0xa,endian:be"` // padding to 12 bytes
}

FS4HashesTableHeader represents the hashes table header for FS4 with annotations

func (*FS4HashesTableHeader) Marshal

func (h *FS4HashesTableHeader) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4HashesTableHeader) Unmarshal

func (h *FS4HashesTableHeader) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4Htoc

type FS4Htoc struct {
	Header FS4HtocHeader    `offset:"0x0"`  // offset 0x0-0xf (16 bytes)
	Entry  [28]FS4HtocEntry `offset:"0x10"` // offset 0x10-0xef (28 entries * 8 bytes = 224 bytes)
}

FS4Htoc represents the complete Hash Table of Contents structure for FS4 with annotations

func (*FS4Htoc) Marshal

func (h *FS4Htoc) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4Htoc) Unmarshal

func (h *FS4Htoc) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4HtocEntry

type FS4HtocEntry struct {
	HashOffset  uint16 `offset:"0x0,endian:be"` // bits 0-15: offset to hash
	SectionType uint8  `offset:"0x2,endian:be"` // bits 16-23: section type
	Reserved    uint8  `offset:"0x3,endian:be"` // bits 24-31: reserved
	// contains filtered or unexported fields
}

FS4HtocEntry represents a single entry in the HTOC (Hash Table of Contents) for FS4 with annotations

func (*FS4HtocEntry) Marshal

func (h *FS4HtocEntry) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4HtocEntry) Unmarshal

func (h *FS4HtocEntry) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4HtocHash

type FS4HtocHash struct {
	HashVal [16]uint32 `offset:"0x0,endian:be"` // 512-bit hash value (64 bytes)
}

FS4HtocHash represents a hash value in the HTOC for FS4 with annotations

func (*FS4HtocHash) Marshal

func (h *FS4HtocHash) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4HtocHash) Unmarshal

func (h *FS4HtocHash) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4HtocHeader

type FS4HtocHeader struct {
	Version      uint32   `offset:"0x0,endian:be"` // offset 0x0
	NumOfEntries uint8    `offset:"0x4,endian:be"` // offset 0x4, bits 0-7
	HashType     uint8    `offset:"0x5,endian:be"` // offset 0x4, bits 8-15
	HashSize     uint16   `offset:"0x6,endian:be"` // offset 0x4, bits 16-31
	Reserved     [8]uint8 `offset:"0x8"`           // padding to 16 bytes
}

FS4HtocHeader represents the HTOC header for FS4 with annotations

func (*FS4HtocHeader) Marshal

func (h *FS4HtocHeader) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4HtocHeader) Unmarshal

func (h *FS4HtocHeader) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4HwPointerEntry

type FS4HwPointerEntry struct {
	Ptr uint32 `offset:"0x0,endian:be"` // offset 0x0: pointer
	CRC uint16 `offset:"0x4,endian:be"` // offset 0x4: crc16 as calculated by HW
	// contains filtered or unexported fields
}

FS4HwPointerEntry represents a hardware pointer entry for FS4 with annotations

func (*FS4HwPointerEntry) Marshal

func (h *FS4HwPointerEntry) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4HwPointerEntry) Unmarshal

func (h *FS4HwPointerEntry) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4HwPointersCarmel

type FS4HwPointersCarmel struct {
	BootRecordPtr              FS4HwPointerEntry `offset:"0x0"`  // offset 0x0
	Boot2Ptr                   FS4HwPointerEntry `offset:"0x8"`  // offset 0x8
	TocPtr                     FS4HwPointerEntry `offset:"0x10"` // offset 0x10
	ToolsPtr                   FS4HwPointerEntry `offset:"0x18"` // offset 0x18
	AuthenticationStartPointer FS4HwPointerEntry `offset:"0x20"` // offset 0x20
	AuthenticationEndPointer   FS4HwPointerEntry `offset:"0x28"` // offset 0x28
	DigestPointer              FS4HwPointerEntry `offset:"0x30"` // offset 0x30
	DigestRecoveryKeyPointer   FS4HwPointerEntry `offset:"0x38"` // offset 0x38
	FwWindowStartPointer       FS4HwPointerEntry `offset:"0x40"` // offset 0x40
	FwWindowEndPointer         FS4HwPointerEntry `offset:"0x48"` // offset 0x48
	ImageInfoSectionPointer    FS4HwPointerEntry `offset:"0x50"` // offset 0x50
	ImageSignaturePointer      FS4HwPointerEntry `offset:"0x58"` // offset 0x58
	PublicKeyPointer           FS4HwPointerEntry `offset:"0x60"` // offset 0x60
	FwSecurityVersionPointer   FS4HwPointerEntry `offset:"0x68"` // offset 0x68
	GcmIvDeltaPointer          FS4HwPointerEntry `offset:"0x70"` // offset 0x70
	HashesTablePointer         FS4HwPointerEntry `offset:"0x78"` // offset 0x78
}

FS4HwPointersCarmel represents the HW pointers for Carmel architecture (FS4) with annotations

func (*FS4HwPointersCarmel) Marshal

func (h *FS4HwPointersCarmel) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4HwPointersCarmel) Unmarshal

func (h *FS4HwPointersCarmel) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4ImageSignature2Struct

type FS4ImageSignature2Struct struct {
	SignatureUUID [4]uint32   `offset:"0x0,endian:be"`  // offset 0x0-0xc: time-based UUID
	KeypairUUID   [4]uint32   `offset:"0x10,endian:be"` // offset 0x10-0x1c: keypair UUID
	Signature     [128]uint32 `offset:"0x20,endian:be"` // offset 0x20-0x21c: 4096-bit signature
}

FS4ImageSignature2Struct represents the IMAGE_SIGNATURE_512 section structure for FS4 with annotations

func (*FS4ImageSignature2Struct) Marshal

func (i *FS4ImageSignature2Struct) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4ImageSignature2Struct) Unmarshal

func (i *FS4ImageSignature2Struct) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4ImageSignatureStruct

type FS4ImageSignatureStruct struct {
	SignatureUUID [4]uint32  `offset:"0x0,endian:be"`  // offset 0x0-0xc: time-based UUID
	KeypairUUID   [4]uint32  `offset:"0x10,endian:be"` // offset 0x10-0x1c: keypair UUID
	Signature     [64]uint32 `offset:"0x20,endian:be"` // offset 0x20-0x11c: 2048-bit signature
}

FS4ImageSignatureStruct represents the IMAGE_SIGNATURE_256 section structure for FS4 with annotations

func (*FS4ImageSignatureStruct) Marshal

func (i *FS4ImageSignatureStruct) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4ImageSignatureStruct) Unmarshal

func (i *FS4ImageSignatureStruct) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4PublicKeys2Struct

type FS4PublicKeys2Struct struct {
	FilePublicKeys2 [8]FS4FilePublicKeys2 `offset:"0x0"` // 8 public keys of 544 bytes each = 4352 bytes
}

FS4PublicKeys2Struct represents the PUBLIC_KEYS_4096 section for FS4 with annotations

func (*FS4PublicKeys2Struct) Marshal

func (p *FS4PublicKeys2Struct) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4PublicKeys2Struct) Unmarshal

func (p *FS4PublicKeys2Struct) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4PublicKeys3Struct

type FS4PublicKeys3Struct struct {
	FilePublicKeys3 [8]FS4FilePublicKeys3 `offset:"0x0"` // 8 public keys of 544 bytes each = 4352 bytes
}

FS4PublicKeys3Struct represents the PUBLIC_KEYS_4096 section (alternate layout) for FS4 with annotations

func (*FS4PublicKeys3Struct) Marshal

func (p *FS4PublicKeys3Struct) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4PublicKeys3Struct) Unmarshal

func (p *FS4PublicKeys3Struct) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4PublicKeysStruct

type FS4PublicKeysStruct struct {
	FilePublicKeys [8]FS4FilePublicKeys `offset:"0x0"` // 8 public keys of 288 bytes each = 2304 bytes
}

FS4PublicKeysStruct represents the PUBLIC_KEYS_2048 section for FS4 with annotations

func (*FS4PublicKeysStruct) Marshal

func (p *FS4PublicKeysStruct) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4PublicKeysStruct) Unmarshal

func (p *FS4PublicKeysStruct) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS4SecureBootSignaturesStruct

type FS4SecureBootSignaturesStruct struct {
	BootSignature        [128]uint32 `offset:"0x0,endian:be"`   // offset 0x0-0x1fc: boot signature
	CriticalSignature    [128]uint32 `offset:"0x200,endian:be"` // offset 0x200-0x3fc: critical signature
	NonCriticalSignature [128]uint32 `offset:"0x400,endian:be"` // offset 0x400-0x5fc: non-critical signature
}

FS4SecureBootSignaturesStruct represents the secure boot signatures structure with proper layout for FS4 with annotations

func (*FS4SecureBootSignaturesStruct) Marshal

func (s *FS4SecureBootSignaturesStruct) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS4SecureBootSignaturesStruct) Unmarshal

func (s *FS4SecureBootSignaturesStruct) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS5HWPointers

type FS5HWPointers struct {
	Boot2Ptr             HWPointerEntry `offset:"byte:0" json:"boot2_ptr"`                 // offset 0x0
	TOCPtr               HWPointerEntry `offset:"byte:8" json:"toc_ptr"`                   // offset 0x8
	ToolsPtr             HWPointerEntry `offset:"byte:16" json:"tools_ptr"`                // offset 0x10
	ImageInfoSectionPtr  HWPointerEntry `offset:"byte:24" json:"image_info_section_ptr"`   // offset 0x18
	FWPublicKeyPtr       HWPointerEntry `offset:"byte:32" json:"fw_public_key_ptr"`        // offset 0x20
	FWSignaturePtr       HWPointerEntry `offset:"byte:40" json:"fw_signature_ptr"`         // offset 0x28
	PublicKeyPtr         HWPointerEntry `offset:"byte:48" json:"public_key_ptr"`           // offset 0x30
	ForbiddenVersionsPtr HWPointerEntry `offset:"byte:56" json:"forbidden_versions_ptr"`   // offset 0x38
	PSCBl1Ptr            HWPointerEntry `offset:"byte:64" json:"psc_bl1_ptr"`              // offset 0x40
	PSCHashesTablePtr    HWPointerEntry `offset:"byte:72" json:"psc_hashes_table_ptr"`     // offset 0x48
	NCoreHashesPointer   HWPointerEntry `offset:"byte:80" json:"ncore_hashes_pointer"`     // offset 0x50
	PSCFWUpdateHandlePtr HWPointerEntry `offset:"byte:88" json:"psc_fw_update_handle_ptr"` // offset 0x58
	PSCBCHPointer        HWPointerEntry `offset:"byte:96" json:"psc_bch_pointer"`          // offset 0x60
	ReservedPtr13        HWPointerEntry `offset:"byte:104" json:"reserved_ptr13"`          // offset 0x68
	ReservedPtr14        HWPointerEntry `offset:"byte:112" json:"reserved_ptr14"`          // offset 0x70
	NCoreBCHPointer      HWPointerEntry `offset:"byte:120" json:"ncore_bch_pointer"`       // offset 0x78
}

FS5HWPointers represents the Gilboa hardware pointers structure (128 bytes) using annotations Based on fs5_image_layout_hw_pointers_gilboa from mstflint

func (*FS5HWPointers) Marshal

func (h *FS5HWPointers) Marshal() ([]byte, error)

Marshal marshals FS5HWPointers into binary data

func (*FS5HWPointers) Unmarshal

func (h *FS5HWPointers) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into FS5HWPointers

type FS5HWPointersJSON

type FS5HWPointersJSON struct {
	Boot2Ptr             HWPointerEntryJSON `json:"boot2_ptr"`
	TOCPtr               HWPointerEntryJSON `json:"toc_ptr"`
	ToolsPtr             HWPointerEntryJSON `json:"tools_ptr"`
	ImageInfoSectionPtr  HWPointerEntryJSON `json:"image_info_section_ptr"`
	FWPublicKeyPtr       HWPointerEntryJSON `json:"fw_public_key_ptr"`
	FWSignaturePtr       HWPointerEntryJSON `json:"fw_signature_ptr"`
	PublicKeyPtr         HWPointerEntryJSON `json:"public_key_ptr"`
	ForbiddenVersionsPtr HWPointerEntryJSON `json:"forbidden_versions_ptr"`
	PSCBl1Ptr            HWPointerEntryJSON `json:"psc_bl1_ptr"`
	PSCHashesTablePtr    HWPointerEntryJSON `json:"psc_hashes_table_ptr"`
	NCoreHashesPointer   HWPointerEntryJSON `json:"ncore_hashes_pointer"`
	PSCFWUpdateHandlePtr HWPointerEntryJSON `json:"psc_fw_update_handle_ptr"`
	PSCBCHPointer        HWPointerEntryJSON `json:"psc_bch_pointer"`
	NCoreBCHPointer      HWPointerEntryJSON `json:"ncore_bch_pointer"`
}

FS5HWPointersJSON represents FS5 hardware pointers in JSON

type FS5HwPointerEntry

type FS5HwPointerEntry struct {
	Ptr uint32 `offset:"0x0,endian:be"` // offset 0x0: pointer
	CRC uint16 `offset:"0x4,endian:be"` // offset 0x4: crc16 as calculated by HW
	// contains filtered or unexported fields
}

FS5HwPointerEntry represents a hardware pointer entry for FS5 with annotations

func (*FS5HwPointerEntry) Marshal

func (h *FS5HwPointerEntry) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS5HwPointerEntry) Unmarshal

func (h *FS5HwPointerEntry) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FS5HwPointersGilboa

type FS5HwPointersGilboa struct {
	PSCBCTPointer            FS5HwPointerEntry `offset:"0x0"`  // offset 0x0
	Boot2Ptr                 FS5HwPointerEntry `offset:"0x8"`  // offset 0x8
	TOCPtr                   FS5HwPointerEntry `offset:"0x10"` // offset 0x10
	ToolsPtr                 FS5HwPointerEntry `offset:"0x18"` // offset 0x18
	PSCBL1BCHPointer         FS5HwPointerEntry `offset:"0x20"` // offset 0x20
	PSCBL1Pointer            FS5HwPointerEntry `offset:"0x28"` // offset 0x28
	NCoreBCHPointer          FS5HwPointerEntry `offset:"0x30"` // offset 0x30
	Reserved                 FS5HwPointerEntry `offset:"0x38"` // offset 0x38
	PSCFWBCHPointer          FS5HwPointerEntry `offset:"0x40"` // offset 0x40
	PSCFWPointer             FS5HwPointerEntry `offset:"0x48"` // offset 0x48
	ImageInfoSectionPointer  FS5HwPointerEntry `offset:"0x50"` // offset 0x50
	ImageSignaturePointer    FS5HwPointerEntry `offset:"0x58"` // offset 0x58
	PublicKeyPointer         FS5HwPointerEntry `offset:"0x60"` // offset 0x60
	ForbiddenVersionsPointer FS5HwPointerEntry `offset:"0x68"` // offset 0x68
	PSCHashesTablePointer    FS5HwPointerEntry `offset:"0x70"` // offset 0x70
	NCoreHashesPointer       FS5HwPointerEntry `offset:"0x78"` // offset 0x78
}

FS5HwPointersGilboa represents the HW pointers for Gilboa architecture (FS5) with annotations

func (*FS5HwPointersGilboa) Marshal

func (h *FS5HwPointersGilboa) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FS5HwPointersGilboa) Unmarshal

func (h *FS5HwPointersGilboa) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FWAdb

type FWAdb struct {
	Version   uint32 `offset:"0x0,endian:be"` // ADB version
	Size      uint32 `offset:"0x4,endian:be"` // Size of ADB data
	Reserved1 uint32 `offset:"0x8,endian:be"` // Reserved
	Reserved2 uint32 `offset:"0xc,endian:be"` // Reserved

}

FWAdb represents the FW_ADB section with annotations

func (*FWAdb) Marshal

func (f *FWAdb) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FWAdb) Unmarshal

func (f *FWAdb) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type FWByteSlice

type FWByteSlice []byte

FWByteSlice is a helper type for byte slices that marshals/unmarshals as hex strings in JSON

func (FWByteSlice) Bytes

func (b FWByteSlice) Bytes() []byte

Bytes returns the underlying byte slice

func (FWByteSlice) MarshalJSON

func (b FWByteSlice) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (*FWByteSlice) SetBytes

func (b *FWByteSlice) SetBytes(data []byte)

SetBytes sets the byte slice from a byte array

func (FWByteSlice) String

func (b FWByteSlice) String() string

String returns hex representation

func (*FWByteSlice) UnmarshalJSON

func (b *FWByteSlice) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type FWInternalUsage

type FWInternalUsage struct {
	Version  uint32    `offset:"0x0,endian:be"`     // Version
	Size     uint32    `offset:"0x4,endian:be"`     // Data size
	Type     uint32    `offset:"0x8,endian:be"`     // Usage type
	Reserved [52]uint8 `offset:"0xc,reserved:true"` // Reserved
}

FWInternalUsage represents the FW_INTERNAL_USAGE section with annotations

func (*FWInternalUsage) Marshal

func (f *FWInternalUsage) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FWInternalUsage) MarshalWithReserved

func (f *FWInternalUsage) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals to binary data including reserved fields

func (*FWInternalUsage) Unmarshal

func (f *FWInternalUsage) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

func (*FWInternalUsage) UnmarshalWithReserved

func (f *FWInternalUsage) UnmarshalWithReserved(data []byte) error

UnmarshalWithReserved unmarshals binary data including reserved fields

type FWInternalUsageJSON

type FWInternalUsageJSON struct {
	Version  uint32 `json:"version"`
	Size     uint32 `json:"size"`
	Type     uint32 `json:"type"`
	DataSize int    `json:"data_size"`
}

FWInternalUsageJSON represents FW_INTERNAL_USAGE section data in JSON

type FWNVLog

type FWNVLog struct {
	LogVersion uint32     `offset:"0x0,endian:be"`               // Log format version
	LogSize    uint32     `offset:"0x4,endian:be"`               // Size of log data
	EntryCount uint32     `offset:"0x8,endian:be"`               // Number of log entries
	Reserved   [13]uint32 `offset:"0xc,endian:be,reserved:true"` // Reserved
}

FWNVLog represents the FW_NV_LOG section with annotations

func (*FWNVLog) Marshal

func (f *FWNVLog) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*FWNVLog) MarshalWithReserved

func (f *FWNVLog) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals to binary data including reserved fields

func (*FWNVLog) Unmarshal

func (f *FWNVLog) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

func (*FWNVLog) UnmarshalWithReserved

func (f *FWNVLog) UnmarshalWithReserved(data []byte) error

UnmarshalWithReserved unmarshals binary data including reserved fields

type FWNVLogJSON

type FWNVLogJSON struct {
	LogVersion uint32 `json:"log_version"`
	LogSize    uint32 `json:"log_size"`
	EntryCount uint32 `json:"entry_count"`
	DataSize   int    `json:"data_size"`
}

FWNVLogJSON represents FW_NV_LOG section data in JSON

type FWVersion

type FWVersion struct {
	Major     uint16 `bin:"BE"` // offset 0x0.16-0x0.31
	Reserved  uint16 `bin:"BE"` // offset 0x0.0-0x0.15 (padding)
	Minor     uint16 `bin:"BE"` // offset 0x4.16-0x4.31
	Subminor  uint16 `bin:"BE"` // offset 0x4.0-0x4.15
	Hour      uint8  `bin:"BE"` // offset 0x8.8-0x8.15
	Reserved2 uint8  `bin:"BE"` // offset 0x8.0-0x8.7 (padding)
	Minutes   uint8  `bin:"BE"` // offset 0x8.16-0x8.23
	Seconds   uint8  `bin:"BE"` // offset 0x8.24-0x8.31
	Day       uint8  `bin:"BE"` // offset 0xc.0-0xc.7
	Month     uint8  `bin:"BE"` // offset 0xc.8-0xc.15
	Year      uint16 `bin:"BE"` // offset 0xc.16-0xc.31
}

FWVersion represents the firmware version structure Based on image_layout_FW_VERSION from mstflint

func (*FWVersion) Marshal

func (f *FWVersion) Marshal() ([]byte, error)

func (*FWVersion) Unmarshal

func (f *FWVersion) Unmarshal(data []byte) error

Marshal/Unmarshal methods for FWVersion

type FirmwareBootVersion

type FirmwareBootVersion struct {
	ImageFormatVersion uint8 `offset:"byte:0"`               // Bits 0-7
	Reserved           uint8 `offset:"byte:1,reserved:true"` // Bits 8-15
	MajorVersion       uint8 `offset:"byte:2"`               // Bits 16-23
	MinorVersion       uint8 `offset:"byte:3"`               // Bits 24-31
}

FirmwareBootVersion represents the firmware boot version structure using annotations Based on mstflint's image_layout_boot_version_unpack which shows the actual bit layout: - image_format_version at bits 0-7 (offset 0) - major_version at bits 16-23 (offset 16) - minor_version at bits 24-31 (offset 24)

func (*FirmwareBootVersion) Marshal

func (b *FirmwareBootVersion) Marshal() ([]byte, error)

Marshal marshals FirmwareBootVersion structure into binary data

func (*FirmwareBootVersion) Unmarshal

func (b *FirmwareBootVersion) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into FirmwareBootVersion structure

type FirmwareFormat

type FirmwareFormat int

FirmwareFormat represents the firmware format type

const (
	// FormatUnknown indicates unknown firmware format
	FormatUnknown FirmwareFormat = iota
	// FormatFS3 indicates FS3 firmware format
	FormatFS3
	// FormatFS4 indicates FS4 firmware format
	FormatFS4
	// FormatFS5 indicates FS5 firmware format
	FormatFS5
)

func (FirmwareFormat) MarshalJSON

func (f FirmwareFormat) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (FirmwareFormat) String

func (f FirmwareFormat) String() string

String returns the string representation of the firmware format

func (*FirmwareFormat) UnmarshalJSON

func (f *FirmwareFormat) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type FirmwareMetadata

type FirmwareMetadata struct {
	Format      FirmwareFormat
	ImageStart  uint32
	ImageSize   uint64
	ChunkSize   uint64
	IsEncrypted bool
	HWPointers  interface{} // Either *FS4HWPointers or *FS5HWPointers
	ITOCHeader  *ITOCHeader
	DTOCHeader  *ITOCHeader // DTOC uses same header structure as ITOC
	ImageInfo   *ImageInfo
	DeviceInfo  *DevInfo
	MFGInfo     *MfgInfo
}

FirmwareMetadata contains parsed firmware metadata

type ForbiddenVersionEntry

type ForbiddenVersionEntry struct {
	MinVersion uint32 `bin:"BE"` // Minimum forbidden version
	MaxVersion uint32 `bin:"BE"` // Maximum forbidden version
	Flags      uint32 `bin:"BE"` // Flags for this entry
	Reserved   uint32 `bin:"BE"` // Reserved field
}

ForbiddenVersionEntry represents a single forbidden version entry

type ForbiddenVersions

type ForbiddenVersions struct {
	Count    uint32   `offset:"byte:0,endian:be" json:"count"`                              // Number of forbidden versions
	Reserved uint32   `offset:"byte:4,endian:be,reserved:true" json:"reserved"`             // Reserved for alignment
	Versions []uint32 `offset:"byte:8,endian:be,list_size:Count" json:"versions,omitempty"` // List of forbidden version numbers
}

ForbiddenVersions represents the FORBIDDEN_VERSIONS section with annotations

func (*ForbiddenVersions) Marshal

func (f *ForbiddenVersions) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*ForbiddenVersions) Unmarshal

func (f *ForbiddenVersions) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type ForbiddenVersionsHeader

type ForbiddenVersionsHeader struct {
	Magic      uint32 `bin:"BE"` // Magic value
	Version    uint32 `bin:"BE"` // Format version
	NumEntries uint32 `bin:"BE"` // Number of forbidden version entries
	Reserved   uint32 `bin:"BE"` // Reserved field
}

ForbiddenVersionsHeader represents the header for forbidden versions section

type ForbiddenVersionsJSON

type ForbiddenVersionsJSON struct {
	Count    uint32   `json:"count"`
	Reserved uint32   `json:"reserved"`
	Versions []uint32 `json:"versions"`
}

ForbiddenVersionsJSON represents forbidden versions in JSON

type Guids

type Guids struct {
	Guids    UIDEntry   // offset 0x0
	Macs     UIDEntry   // offset 0x20
	Reserved [192]uint8 // padding to 256 bytes
}

Guids represents the GUIDs structure Based on image_layout_guids from mstflint

func (*Guids) Marshal

func (g *Guids) Marshal() ([]byte, error)

func (*Guids) Unmarshal

func (g *Guids) Unmarshal(data []byte) error

Marshal/Unmarshal methods for Guids

type GuidsJSON

type GuidsJSON struct {
	Reserved1    uint16 `json:"reserved1"`
	Step         uint8  `json:"step"`
	NumAllocated uint8  `json:"num_allocated"`
	Reserved2    uint32 `json:"reserved2"`
	UID          uint64 `json:"uid"`
}

GuidsJSON represents GUID info in JSON

type HMACDigest

type HMACDigest struct {
	DigestType uint32    `offset:"0x0,endian:be"` // Type of digest (SHA256, SHA512, etc)
	DigestSize uint32    `offset:"0x4,endian:be"` // Size of the digest in bytes
	Digest     [64]uint8 `offset:"0x8"`           // The actual digest (max 512 bits)
	Reserved   [56]uint8 `offset:"0x48"`          // Padding
}

HMACDigest represents the HMAC_DIGEST section with annotations

func (*HMACDigest) Marshal

func (h *HMACDigest) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*HMACDigest) MarshalWithReserved

func (h *HMACDigest) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals to binary data including reserved fields

func (*HMACDigest) Unmarshal

func (h *HMACDigest) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

func (*HMACDigest) UnmarshalWithReserved

func (h *HMACDigest) UnmarshalWithReserved(data []byte) error

UnmarshalWithReserved unmarshals binary data including reserved fields

type HTOC

type HTOC struct {
	Header  HTOCHeader    // offset 0x0
	Entries [28]HTOCEntry // offset 0x8
}

HTOC represents the HTOC structure with header and entries Based on image_layout_htoc from mstflint

func (*HTOC) Marshal

func (h *HTOC) Marshal() ([]byte, error)

func (*HTOC) Unmarshal

func (h *HTOC) Unmarshal(data []byte) error

Marshal/Unmarshal methods for HTOC

type HTOCEntry

type HTOCEntry struct {
	BinHashType uint8  // offset 0x0.0-0x0.15 (bits 0-15)
	HashOffset  uint16 // offset 0x0.16-0x0.31 (bits 16-31)
	Reserved    uint32 // offset 0x4
}

HTOCEntry represents an HTOC entry structure Based on image_layout_htoc_entry from mstflint

func (*HTOCEntry) Marshal

func (h *HTOCEntry) Marshal() ([]byte, error)

func (*HTOCEntry) Unmarshal

func (h *HTOCEntry) Unmarshal(data []byte) error

Marshal/Unmarshal methods for HTOCEntry

type HTOCHash

type HTOCHash struct {
	HashData [32]uint8 // offset 0x0 - SHA256 hash
	Reserved [32]uint8 // offset 0x20 - padding to 64 bytes
}

HTOCHash represents a hash entry in the hashes table Based on image_layout_htoc_hash from mstflint

func (*HTOCHash) Marshal

func (h *HTOCHash) Marshal() ([]byte, error)

func (*HTOCHash) Unmarshal

func (h *HTOCHash) Unmarshal(data []byte) error

Marshal/Unmarshal methods for HTOCHash

type HTOCHeader

type HTOCHeader struct {
	FirstType    uint16 // offset 0x0.0-0x0.15
	Version      uint8  // offset 0x0.16-0x0.23
	HashLocation uint8  // offset 0x0.24-0x0.31
	Reserved     uint32 // offset 0x4
}

HTOCHeader represents the HTOC header structure Based on image_layout_htoc_header from mstflint

func (*HTOCHeader) Marshal

func (h *HTOCHeader) Marshal() ([]byte, error)

func (*HTOCHeader) Unmarshal

func (h *HTOCHeader) Unmarshal(data []byte) error

Marshal/Unmarshal methods for HTOCHeader

type HWIDRecord

type HWIDRecord struct {
	HWID       uint32 `offset:"byte:0,endian:be"`                // Hardware ID
	ChipType   uint32 `offset:"byte:4,endian:be"`                // Chip type
	DeviceType uint32 `offset:"byte:8,endian:be"`                // Device type
	Reserved   uint32 `offset:"byte:12,endian:be,reserved:true"` // Reserved field
}

HWIDRecord represents a hardware ID record Used for device identification

func (*HWIDRecord) Marshal

func (h *HWIDRecord) Marshal() ([]byte, error)

Marshal marshals the annotated structure into binary data

func (*HWIDRecord) Unmarshal

func (h *HWIDRecord) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into the annotated structure

type HWPointerEntry

type HWPointerEntry struct {
	Ptr      uint32 `offset:"byte:0,endian:be" json:"ptr"`                    // Pointer value (offset 0x0)
	Reserved uint16 `offset:"byte:4,endian:be,reserved:true" json:"reserved"` // Reserved field (offset 0x4)
	CRC      uint16 `offset:"byte:6,endian:be" json:"crc"`                    // CRC16 value (offset 0x6)
}

HWPointerEntry represents a single hardware pointer entry (8 bytes) using annotations Based on image_layout_hw_pointer_entry from mstflint Note: In the actual firmware, the CRC is stored at offset 6, not offset 4

func (*HWPointerEntry) Marshal

func (h *HWPointerEntry) Marshal() ([]byte, error)

Marshal marshals HWPointerEntry into binary data

func (*HWPointerEntry) MarshalWithReserved

func (h *HWPointerEntry) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals HWPointerEntry including reserved fields

func (*HWPointerEntry) Unmarshal

func (h *HWPointerEntry) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into HWPointerEntry

func (*HWPointerEntry) UnmarshalWithReserved

func (h *HWPointerEntry) UnmarshalWithReserved(data []byte) error

UnmarshalWithReserved unmarshals binary data including reserved fields

type HWPointerEntryJSON

type HWPointerEntryJSON struct {
	Pointer uint32 `json:"pointer"`
	CRC     uint16 `json:"crc"`
}

HWPointerEntryJSON represents a hardware pointer entry in JSON

type HashTableEntry

type HashTableEntry struct {
	Type     uint32   `offset:"byte:0,endian:be" json:"type"`                    // Hash type/identifier
	Offset   uint32   `offset:"byte:4,endian:be" json:"offset"`                  // Offset in the image
	Size     uint32   `offset:"byte:8,endian:be" json:"size"`                    // Size of the hashed region
	Reserved uint32   `offset:"byte:12,endian:be,reserved:true" json:"reserved"` // Reserved field
	Hash     [32]byte `offset:"byte:16" json:"-"`                                // SHA-256 hash value - handled separately
}

HashTableEntry represents a single hash entry in the hashes table using annotations

func (*HashTableEntry) Marshal

func (h *HashTableEntry) Marshal() ([]byte, error)

Marshal marshals HashTableEntry into binary data

func (*HashTableEntry) MarshalJSON

func (h *HashTableEntry) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface for HashTableEntry

func (*HashTableEntry) MarshalWithReserved

func (h *HashTableEntry) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals HashTableEntry including reserved fields

func (*HashTableEntry) Unmarshal

func (h *HashTableEntry) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into HashTableEntry

func (*HashTableEntry) UnmarshalJSON

func (h *HashTableEntry) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface for HashTableEntry

func (*HashTableEntry) UnmarshalWithReserved

func (h *HashTableEntry) UnmarshalWithReserved(data []byte) error

UnmarshalWithReserved unmarshals binary data including reserved fields

type HashTableEntryJSON

type HashTableEntryJSON struct {
	Hash   string `json:"hash"` // Hex encoded
	Type   uint32 `json:"type"`
	Offset uint32 `json:"offset"`
	Size   uint32 `json:"size"`
}

HashTableEntryJSON represents a hash table entry in JSON

type HashesTableExtended

type HashesTableExtended struct {
	Header HashesTableHeaderExtended // offset 0x0
	HTOC   HTOC                      // offset 0x10
	Hashes [28]HTOCHash              // offset 0xf0
}

HashesTableExtended represents the complete hashes table structure Based on image_layout_hashes_table from mstflint

func (*HashesTableExtended) Marshal

func (h *HashesTableExtended) Marshal() ([]byte, error)

func (*HashesTableExtended) Unmarshal

func (h *HashesTableExtended) Unmarshal(data []byte) error

Marshal/Unmarshal methods for HashesTableExtended

type HashesTableHeader

type HashesTableHeader struct {
	Magic      uint32 `offset:"byte:0,endian:be" json:"magic"`                    // Should be a specific magic value
	Version    uint32 `offset:"byte:4,endian:be" json:"version"`                  // Version number
	Reserved1  uint32 `offset:"byte:8,endian:be,reserved:true" json:"reserved1"`  // Reserved field
	Reserved2  uint32 `offset:"byte:12,endian:be,reserved:true" json:"reserved2"` // Reserved field
	TableSize  uint32 `offset:"byte:16,endian:be" json:"table_size"`              // Size of the hashes table
	NumEntries uint32 `offset:"byte:20,endian:be" json:"num_entries"`             // Number of hash entries
	Reserved3  uint32 `offset:"byte:24,endian:be,reserved:true" json:"reserved3"` // Reserved field
	CRC        uint16 `offset:"byte:28,endian:be" json:"crc"`                     // CRC16 of the header
	Reserved4  uint16 `offset:"byte:30,endian:be,reserved:true" json:"reserved4"` // Reserved field
}

HashesTableHeader represents the hashes table header structure using annotations This is specific to FS5 format

func (*HashesTableHeader) Marshal

func (h *HashesTableHeader) Marshal() ([]byte, error)

Marshal marshals HashesTableHeader into binary data

func (*HashesTableHeader) MarshalWithReserved

func (h *HashesTableHeader) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals HashesTableHeader including reserved fields

func (*HashesTableHeader) Unmarshal

func (h *HashesTableHeader) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into HashesTableHeader

func (*HashesTableHeader) UnmarshalWithReserved

func (h *HashesTableHeader) UnmarshalWithReserved(data []byte) error

UnmarshalWithReserved unmarshals binary data including reserved fields

type HashesTableHeaderExtended

type HashesTableHeaderExtended struct {
	Magic    uint64 // offset 0x0 - should be HashesTableMagic
	Version  uint32 // offset 0x8
	Reserved uint32 // offset 0xc
}

HashesTableHeaderExtended represents the hashes table header structure Based on image_layout_hashes_table_header from mstflint

func (*HashesTableHeaderExtended) Marshal

func (h *HashesTableHeaderExtended) Marshal() ([]byte, error)

func (*HashesTableHeaderExtended) Unmarshal

func (h *HashesTableHeaderExtended) Unmarshal(data []byte) error

Marshal/Unmarshal methods for HashesTableHeaderExtended

type HashesTableHeaderJSON

type HashesTableHeaderJSON struct {
	Magic      uint32 `json:"magic"`
	Version    uint32 `json:"version"`
	Reserved1  uint32 `json:"reserved1"`
	Reserved2  uint32 `json:"reserved2"`
	TableSize  uint32 `json:"table_size"`
	NumEntries uint32 `json:"num_entries"`
	Reserved3  uint32 `json:"reserved3"`
	CRC        uint16 `json:"crc"`
	Reserved4  uint16 `json:"reserved4"`
}

HashesTableHeaderJSON represents the header in JSON

type HashesTableJSON

type HashesTableJSON struct {
	Header       HashesTableHeaderJSON `json:"header"`
	Entries      []HashTableEntryJSON  `json:"entries"`
	ReservedTail string                `json:"reserved_tail"` // Hex encoded
}

HashesTableJSON represents a hashes table section in JSON

type ITOCEntry

type ITOCEntry struct {
	// Byte 0-3: Type (bits 0-7), Size (bits 8-29), Param0 bits (30-33)
	Type       uint8  `offset:"bit:0,len:8,endian:be"`  // bits 0-7
	SizeDwords uint32 `offset:"bit:8,len:22,endian:be"` // bits 8-29 (size in dwords)
	Param0Low  uint32 `offset:"bit:30,len:4,endian:be"` // bits 30-33 (lower 4 bits of Param0)

	// Byte 4-7: Param0 bits (34-63)
	Param0High uint32 `offset:"bit:34,len:30,endian:be"` // bits 34-63 (upper 30 bits of Param0)

	// Byte 8-11: Param1 (bits 64-95)
	Param1 uint32 `offset:"byte:8,endian:be"` // bits 64-95

	// Byte 12-15: Reserved
	Reserved1 uint32 `offset:"byte:12,endian:be,reserved:true"` // bits 96-127

	// Byte 16-19: Reserved
	Reserved2 uint32 `offset:"byte:16,endian:be,reserved:true"` // bits 128-159

	// Byte 20-23: Flash address (in bytes, not dwords as the field name suggests)
	// Despite the field name, mstflint treats this as a byte address directly
	FlashAddrDwords uint32 `offset:"byte:20,endian:be"` // Flash address in bytes

	// Byte 24-25: Encrypted flag and CRC flags
	// Based on actual bit layout from legacy parser:
	// - bit 192: encrypted
	// - bits 193-204: reserved
	// - bits 205-207: CRC type field (3 bits)
	//   - 0: CRC in ITOC entry (section_crc field)
	//   - 1: No CRC validation
	//   - 2: CRC at end of section data
	Encrypted bool  `offset:"bit:192,endian:be"`                      // bit 192
	Reserved5 uint8 `offset:"bit:193,len:12,endian:be,reserved:true"` // bits 193-204
	CRCField  uint8 `offset:"bit:205,len:3,endian:be"`                // bits 205-207 (3 bits)

	// Byte 26-27: Section CRC
	SectionCRC uint16 `offset:"bit:208,endian:be"` // bits 208-223 (16 bits)

	// Byte 28-29: Reserved
	Reserved7 uint16 `offset:"byte:28,endian:be,reserved:true"` // bits 224-239

	// Byte 30-31: ITOC Entry CRC
	ITOCEntryCRC uint16 `offset:"byte:30,endian:be"` // bits 240-255
}

ITOCEntry represents an ITOC entry structure (32 bytes) using annotations Based on image_layout_itoc_entry from mstflint This structure has complex bit packing

func (*ITOCEntry) GetCRC

func (e *ITOCEntry) GetCRC() uint8

Compatibility helpers

func (*ITOCEntry) GetCRCType

func (e *ITOCEntry) GetCRCType() CRCType

GetCRCType returns the CRC type based on the CRCField value

func (*ITOCEntry) GetDeviceData

func (e *ITOCEntry) GetDeviceData() bool

GetDeviceData returns true if the device_data flag is set

func (*ITOCEntry) GetFlashAddr

func (e *ITOCEntry) GetFlashAddr() uint32

GetFlashAddr returns the flash address in bytes

func (*ITOCEntry) GetNoCRC

func (e *ITOCEntry) GetNoCRC() bool

GetNoCRC returns true if the CRC type is NONE

func (*ITOCEntry) GetParam0

func (e *ITOCEntry) GetParam0() uint32

GetParam0 returns the combined Param0 value

func (*ITOCEntry) GetSize

func (e *ITOCEntry) GetSize() uint32

GetSize returns the size in bytes

func (*ITOCEntry) GetType

func (e *ITOCEntry) GetType() uint16

GetType returns the type as uint16 for compatibility

func (*ITOCEntry) Marshal

func (e *ITOCEntry) Marshal() ([]byte, error)

Marshal marshals ITOCEntry into binary data

func (*ITOCEntry) ParseFields

func (e *ITOCEntry) ParseFields()

ParseFields parses the bit-packed fields from the raw data Based on image_layout_itoc_entry_unpack from mstflint

func (*ITOCEntry) SetCRC

func (e *ITOCEntry) SetCRC(c uint8)

func (*ITOCEntry) SetEncrypted

func (e *ITOCEntry) SetEncrypted(enc bool)

func (*ITOCEntry) SetFlashAddr

func (e *ITOCEntry) SetFlashAddr(a uint32)

func (*ITOCEntry) SetITOCEntryCRC

func (e *ITOCEntry) SetITOCEntryCRC(c uint16)

func (*ITOCEntry) SetParam0

func (e *ITOCEntry) SetParam0(p uint32)

func (*ITOCEntry) SetParam1

func (e *ITOCEntry) SetParam1(p uint32)

func (*ITOCEntry) SetSectionCRC

func (e *ITOCEntry) SetSectionCRC(c uint16)

func (*ITOCEntry) SetSize

func (e *ITOCEntry) SetSize(s uint32)

func (*ITOCEntry) SetType

func (e *ITOCEntry) SetType(t uint8)

func (*ITOCEntry) Unmarshal

func (e *ITOCEntry) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into ITOCEntry

type ITOCEntryJSON

type ITOCEntryJSON struct {
	Type            uint16 `json:"type"`
	DeviceData      bool   `json:"device_data"`
	NoHashCheck     bool   `json:"no_hash_check"`
	RelativeAddress bool   `json:"relative_address"`
	SectionPointer  uint32 `json:"section_pointer"`
	SectionSize     uint32 `json:"section_size"`
	FlashAddress    uint32 `json:"flash_address"`
	CRC             uint16 `json:"crc"`
}

ITOCEntryJSON represents an ITOC entry in JSON

type ITOCHeader

type ITOCHeader struct {
	Signature0   uint32 `offset:"byte:0,endian:be"`                // Should be ITOCSignature (offset 0x0)
	Signature1   uint32 `offset:"byte:4,endian:be"`                // offset 0x4
	Signature2   uint32 `offset:"byte:8,endian:be"`                // offset 0x8
	Signature3   uint32 `offset:"byte:12,endian:be"`               // offset 0xc
	Version      uint32 `offset:"byte:16,endian:be"`               // offset 0x10
	Reserved     uint32 `offset:"byte:20,endian:be,reserved:true"` // offset 0x14
	ITOCEntryCRC uint32 `offset:"byte:24,endian:be"`               // offset 0x18
	CRC          uint32 `offset:"byte:28,endian:be"`               // offset 0x1c
}

ITOCHeader represents the ITOC header structure (32 bytes) using annotations Based on image_layout_itoc_header from mstflint

func (*ITOCHeader) GetNumSections

func (h *ITOCHeader) GetNumSections(firmwareData []byte, itocOffset uint32) (int, error)

GetNumSections is a helper method for ITOCHeader to get the number of sections Note: This requires access to the firmware data and ITOC offset

func (*ITOCHeader) Marshal

func (h *ITOCHeader) Marshal() ([]byte, error)

Marshal marshals ITOCHeader into binary data

func (*ITOCHeader) Unmarshal

func (h *ITOCHeader) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into ITOCHeader

type ITOCHeaderJSON

type ITOCHeaderJSON struct {
	IdentifierLo      uint32 `json:"identifier_lo"`
	IdentifierHi      uint32 `json:"identifier_hi"`
	Version           uint8  `json:"version"`
	Reserved0         uint8  `json:"reserved0"`
	Reserved1         uint16 `json:"reserved1"`
	Reserved2         uint32 `json:"reserved2"`
	Reserved3         uint32 `json:"reserved3"`
	Reserved4         uint32 `json:"reserved4"`
	NextHeaderPointer uint32 `json:"next_header_pointer"`
	NextHeaderSize    uint32 `json:"next_header_size"`
	Padding           string `json:"padding,omitempty"`
}

ITOCHeaderJSON represents an ITOC header in JSON

type ITOCJSON

type ITOCJSON struct {
	Header  ITOCHeaderJSON  `json:"header"`
	Entries []ITOCEntryJSON `json:"entries"`
}

ITOCJSON represents an ITOC section in JSON

type ImageInfo

type ImageInfo struct {
	// DWORD 0 - offset 0x0 (32 bits total) - stored as big-endian in firmware
	// Original parseSecurityAttributes uses LSB=0 bit numbering on BE uint32:
	// - mccEn: bit 8, debugFW: bit 13, signedFW: bit 14, secureFW: bit 15
	// But annotation parser uses MSB=0 bit numbering, so we convert:
	// - mccEn: bit 8 (LSB=0) = bit 23 (MSB=0)
	// - debugFW: bit 13 (LSB=0) = bit 18 (MSB=0)
	// - signedFW: bit 14 (LSB=0) = bit 17 (MSB=0)
	// - secureFW: bit 15 (LSB=0) = bit 16 (MSB=0)
	Reserved0    uint8 `offset:"bit:0,len:8,endian:be" json:"reserved0"`      // Bits 0-7 (MSB=0) = bits 24-31 (LSB=0)
	MajorVersion uint8 `offset:"bit:8,len:8,endian:be" json:"major_version"`  // Bits 8-15 (MSB=0) = bits 16-23 (LSB=0)
	SecurityMode uint8 `offset:"bit:16,len:8,endian:be" json:"security_mode"` // Bits 16-23 (MSB=0) = bits 8-15 (LSB=0)
	SecureFW     bool  `offset:"bit:16,len:1,endian:be" json:"secure_fw"`     // Bit 16 (MSB=0) = bit 15 (LSB=0)
	SignedFW     bool  `offset:"bit:17,len:1,endian:be" json:"signed_fw"`     // Bit 17 (MSB=0) = bit 14 (LSB=0)
	DebugFW      bool  `offset:"bit:18,len:1,endian:be" json:"debug_fw"`      // Bit 18 (MSB=0) = bit 13 (LSB=0)
	MCCEnabled   bool  `offset:"bit:23,len:1,endian:be" json:"mcc_enabled"`   // Bit 23 (MSB=0) = bit 8 (LSB=0)
	MinorVersion uint8 `offset:"bit:24,len:8,endian:be" json:"minor_version"` // Bits 24-31 (MSB=0) = bits 0-7 (LSB=0)

	// DWORD 1-4 - offset 0x4 - FW Version
	FWVerMajor    uint16 `offset:"byte:4,endian:be" json:"fw_ver_major"`            // offset 0x4
	Reserved2     uint16 `offset:"byte:6,endian:be,reserved:true" json:"reserved2"` // offset 0x6
	FWVerMinor    uint16 `offset:"byte:8,endian:be" json:"fw_ver_minor"`            // offset 0x8
	FWVerSubminor uint16 `offset:"byte:10,endian:be" json:"fw_ver_subminor"`        // offset 0xa

	// Date/time fields - TIME at offset 0xc, DATE at offset 0x10
	Reserved3a uint8  `offset:"byte:12,reserved:true" json:"reserved3a"`       // offset 0xc byte 0
	Hour       uint8  `offset:"byte:13,hex_as_dec:true" json:"hour"`           // offset 0xc byte 1
	Minutes    uint8  `offset:"byte:14,hex_as_dec:true" json:"minutes"`        // offset 0xc byte 2
	Seconds    uint8  `offset:"byte:15,hex_as_dec:true" json:"seconds"`        // offset 0xc byte 3
	Year       uint16 `offset:"byte:16,endian:be,hex_as_dec:true" json:"year"` // offset 0x10 - BCD year (e.g. 0x2024 = 2024)
	Month      uint8  `offset:"byte:18,hex_as_dec:true" json:"month"`          // offset 0x12 - BCD month (e.g. 0x06 = 6)
	Day        uint8  `offset:"byte:19,hex_as_dec:true" json:"day"`            // offset 0x13 - BCD day (e.g. 0x27 = 27)

	// MIC version - offset 0x14
	MICVerMajor    uint16 `offset:"byte:20,endian:be" json:"mic_ver_major"`           // offset 0x14
	Reserved4      uint16 `offset:"byte:22,endian:be,reserved:true" json:"reserved4"` // offset 0x16
	MICVerSubminor uint16 `offset:"byte:24,endian:be" json:"mic_ver_subminor"`        // offset 0x18
	MICVerMinor    uint16 `offset:"byte:26,endian:be" json:"mic_ver_minor"`           // offset 0x1a

	// PCI IDs - offset 0x1c
	PCIDeviceID    uint16 `offset:"byte:28,endian:be" json:"pci_device_id"`    // offset 0x1c
	PCIVendorID    uint16 `offset:"byte:30,endian:be" json:"pci_vendor_id"`    // offset 0x1e
	PCISubsystemID uint16 `offset:"byte:32,endian:be" json:"pci_subsystem_id"` // offset 0x20
	PCISubVendorID uint16 `offset:"byte:34,endian:be" json:"pci_subvendor_id"` // offset 0x22

	// PSID - offset 0x24
	PSID [16]byte `offset:"byte:36" json:"-"` // offset 0x24-0x33 (will be handled separately in MarshalJSON)

	// Padding/alignment - offset 0x34
	Reserved5a uint16 `offset:"byte:52,endian:be,reserved:true" json:"reserved5a"` // offset 0x34-0x35

	// VSD vendor ID - offset 0x36
	VSDVendorID uint16 `offset:"byte:54,endian:be" json:"vsd_vendor_id"` // offset 0x36-0x37

	// VSD - offset 0x38
	VSD [208]byte `offset:"byte:56" json:"-"` // offset 0x38-0x107 (will be handled separately in MarshalJSON)

	// Image size - offset 0x108
	ImageSizeData [8]byte `offset:"byte:264" json:"image_size_data"` // offset 0x108-0x10f

	// Reserved - offset 0x110
	Reserved6 [8]byte `offset:"byte:272,reserved:true" json:"reserved6"` // offset 0x110-0x117

	// Supported HW IDs - offset 0x118
	SupportedHWID [4]uint32 `offset:"byte:280,endian:be" json:"supported_hw_ids"` // offset 0x118-0x127

	// INI File number and reserved - offset 0x128
	INIFileNum uint32 `offset:"byte:296,endian:be" json:"ini_file_num"` // offset 0x128-0x12b

	// Big reserved section - offset 0x12c
	Reserved7 [148]byte `offset:"byte:300,reserved:true" json:"reserved7"` // offset 0x12c-0x1bf

	// Product version - offset 0x1c0
	ProductVer [16]byte `offset:"byte:448" json:"-"` // offset 0x1c0-0x1cf (will be handled separately in MarshalJSON)

	// Description - offset 0x1d0
	Description [256]byte `offset:"byte:464" json:"-"` // offset 0x1d0-0x2cf (will be handled separately in MarshalJSON)

	// Reserved - offset 0x2d0
	Reserved8 [48]byte `offset:"byte:720,reserved:true" json:"reserved8"` // offset 0x2d0-0x2ff

	// Module versions - offset 0x300
	ModuleVersions [64]byte `offset:"byte:768" json:"module_versions"` // offset 0x300-0x33f

	// Name (part number) - offset 0x340
	Name [64]byte `offset:"byte:832" json:"-"` // offset 0x340-0x37f (will be handled separately in MarshalJSON)

	// PRS name - offset 0x380
	PRSName [128]byte `offset:"byte:896" json:"-"` // offset 0x380-0x3ff (will be handled separately in MarshalJSON)
}

ImageInfo represents the full IMAGE_INFO section structure using annotations Based on mstflint's connectx4_image_info structure

func (*ImageInfo) GetDay

func (i *ImageInfo) GetDay() uint8

func (*ImageInfo) GetDescriptionString

func (i *ImageInfo) GetDescriptionString() string

GetDescriptionString returns a description string

func (*ImageInfo) GetFWReleaseDateString

func (i *ImageInfo) GetFWReleaseDateString() string

GetFWReleaseDateString returns the firmware release date as a string

func (*ImageInfo) GetFWVersionString

func (i *ImageInfo) GetFWVersionString() string

GetFWVersionString returns the firmware version as a string

func (*ImageInfo) GetHour

func (i *ImageInfo) GetHour() uint8

func (*ImageInfo) GetMICVersionString

func (i *ImageInfo) GetMICVersionString() string

GetMICVersionString returns the MIC version as a string

func (*ImageInfo) GetMajorVersion

func (i *ImageInfo) GetMajorVersion() uint8

func (*ImageInfo) GetMinorVersion

func (i *ImageInfo) GetMinorVersion() uint8

func (*ImageInfo) GetMinutes

func (i *ImageInfo) GetMinutes() uint8

func (*ImageInfo) GetMonth

func (i *ImageInfo) GetMonth() uint8

func (*ImageInfo) GetNameString

func (i *ImageInfo) GetNameString() string

GetNameString returns the firmware name

func (*ImageInfo) GetPRSNameString

func (i *ImageInfo) GetPRSNameString() string

GetPRSNameString returns the PRS name

func (*ImageInfo) GetPSIDString

func (i *ImageInfo) GetPSIDString() string

GetPSIDString returns the PSID as a string

func (*ImageInfo) GetPartNumberString

func (i *ImageInfo) GetPartNumberString() string

GetPartNumberString returns the part number as a string

func (*ImageInfo) GetProductVerString

func (i *ImageInfo) GetProductVerString() string

GetProductVerString returns the product version string

func (*ImageInfo) GetSeconds

func (i *ImageInfo) GetSeconds() uint8

GetSeconds returns the seconds

func (*ImageInfo) GetSecurityAndVersion

func (i *ImageInfo) GetSecurityAndVersion() uint32

GetSecurityAndVersion reconstructs the SecurityAndVersion field from individual bitfields

func (*ImageInfo) GetSecurityAttributesString

func (i *ImageInfo) GetSecurityAttributesString() string

GetSecurityAttributesString returns a string describing security attributes

func (*ImageInfo) GetSecurityMode

func (i *ImageInfo) GetSecurityMode() uint32

GetSecurityMode returns the security mode bits

func (*ImageInfo) GetVSDString

func (i *ImageInfo) GetVSDString() string

GetVSDString returns the VSD as a string

func (*ImageInfo) GetYear

func (i *ImageInfo) GetYear() uint16

func (*ImageInfo) IsDebugFW

func (i *ImageInfo) IsDebugFW() bool

func (*ImageInfo) IsMCCEnabled

func (i *ImageInfo) IsMCCEnabled() bool

func (*ImageInfo) IsSecureFW

func (i *ImageInfo) IsSecureFW() bool

func (*ImageInfo) IsSignedFW

func (i *ImageInfo) IsSignedFW() bool

func (*ImageInfo) Marshal

func (i *ImageInfo) Marshal() ([]byte, error)

Marshal marshals ImageInfo into binary data

func (*ImageInfo) MarshalJSON

func (i *ImageInfo) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (*ImageInfo) MarshalWithReserved

func (i *ImageInfo) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals ImageInfo including reserved fields

func (*ImageInfo) Unmarshal

func (i *ImageInfo) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into ImageInfo

func (*ImageInfo) UnmarshalJSON

func (i *ImageInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

func (*ImageInfo) UnmarshalWithReserved

func (i *ImageInfo) UnmarshalWithReserved(data []byte) error

UnmarshalWithReserved unmarshals binary data including reserved fields

type ImageInfoExtended

type ImageInfoExtended struct {
	// Flags (bits in first dword)
	LongKeys                  uint8 `bin:"bitfield=1"` // bit 6
	DebugFWTokensSupported    uint8 `bin:"bitfield=1"` // bit 7
	MccEn                     uint8 `bin:"bitfield=1"` // bit 8
	SignedVendorNvconfigFiles uint8 `bin:"bitfield=1"` // bit 9
	SignedMlnxNvconfigFiles   uint8 `bin:"bitfield=1"` // bit 10
	FrcSupported              uint8 `bin:"bitfield=1"` // bit 11
	CSTokensSupported         uint8 `bin:"bitfield=1"` // bit 12
	DebugFW                   uint8 `bin:"bitfield=1"` // bit 13
	SignedFW                  uint8 `bin:"bitfield=1"` // bit 14
	SecureFW                  uint8 `bin:"bitfield=1"` // bit 15

	// Version info
	MinorVersion uint8 // bits 16-23
	MajorVersion uint8 // bits 24-31

	// Firmware version
	FWVersion  FWVersion     // offset 0x4-0x14
	MicVersion TripleVersion // offset 0x14-0x1c

	// PCI IDs
	PCIVendorID    uint16 // offset 0x1c.0-0x1c.15
	PCIDeviceID    uint16 // offset 0x1c.16-0x1c.31
	PCISubVendorID uint16 // offset 0x20.0-0x20.15
	PCISubsystemID uint16 // offset 0x20.16-0x20.31

	// PSID and VSD
	PSID        [17]byte  // offset 0x24-0x34 (null-terminated string)
	VSDVendorID uint16    // offset 0x34
	Reserved1   uint16    // offset 0x36
	VSD         [209]byte // offset 0x38-0x108 (null-terminated string)

	// Image size
	ImageSizeStruct ImageSize // offset 0x108-0x110

	// Supported HW IDs
	SupportedHWID [4]uint32 // offset 0x118-0x128

	// INI file number
	INIFileNum uint32 // offset 0x128

	// Reserved space
	Reserved2 [148]uint8 // offset 0x12c-0x1c0

	// Product version
	ProdVer [17]byte // offset 0x1c0-0x1d0 (null-terminated string)

	// Description
	Description [257]byte // offset 0x1d0-0x2d0 (null-terminated string)

	// Reserved space
	Reserved3 [48]uint8 // offset 0x2d1-0x300

	// Module versions
	ModuleVersionsStruct ModuleVersions // offset 0x300-0x340

	// Name
	Name [65]byte // offset 0x340-0x380 (null-terminated string)

	// PRS name
	PRSName [129]byte // offset 0x380-0x400 (null-terminated string)
}

Extended ImageInfo structure with all fields from mstflint Based on image_layout_image_info from mstflint

func (*ImageInfoExtended) Marshal

func (i *ImageInfoExtended) Marshal() ([]byte, error)

func (*ImageInfoExtended) Unmarshal

func (i *ImageInfoExtended) Unmarshal(data []byte) error

Marshal/Unmarshal methods for ImageInfoExtended

type ImageInfoJSON

type ImageInfoJSON struct {
	// Security and version info
	SecurityAndVersion uint32 `json:"security_and_version"`
	MinorVersion       uint8  `json:"minor_version"`
	SecurityMode       uint8  `json:"security_mode"`
	MajorVersion       uint8  `json:"major_version"`
	Reserved0          uint8  `json:"reserved0"`
	MCCEnabled         bool   `json:"mcc_enabled"`
	DebugFW            bool   `json:"debug_fw"`
	SignedFW           bool   `json:"signed_fw"`
	SecureFW           bool   `json:"secure_fw"`

	// FW version fields
	FWVerMajor    uint16 `json:"fw_ver_major"`
	Reserved2     uint16 `json:"reserved2"`
	FWVerMinor    uint16 `json:"fw_ver_minor"`
	FWVerSubminor uint16 `json:"fw_ver_subminor"`

	// Date/time fields
	Reserved3a uint8  `json:"reserved3a"`
	Hour       uint8  `json:"hour"`
	Minutes    uint8  `json:"minutes"`
	Seconds    uint8  `json:"seconds"`
	Day        uint8  `json:"day"`
	Month      uint8  `json:"month"`
	Year       uint16 `json:"year"`

	// MIC version fields
	MICVerMajor    uint16 `json:"mic_ver_major"`
	Reserved4      uint16 `json:"reserved4"`
	MICVerSubminor uint16 `json:"mic_ver_subminor"`
	MICVerMinor    uint16 `json:"mic_ver_minor"`

	// PCI IDs
	PCIDeviceID    uint16 `json:"pci_device_id"`
	PCIVendorID    uint16 `json:"pci_vendor_id"`
	PCISubsystemID uint16 `json:"pci_subsystem_id"`
	PCISubVendorID uint16 `json:"pci_subvendor_id"`

	// PSID
	PSID string `json:"psid"`

	// VSD info
	Reserved5a  uint16 `json:"reserved5a"`
	VSDVendorID uint16 `json:"vsd_vendor_id"`
	VSD         string `json:"vsd"`

	// Image size data
	ImageSizeData []uint8 `json:"image_size_data"`
	Reserved6     []uint8 `json:"reserved6"`

	// Supported HW IDs
	SupportedHWIDs []uint32 `json:"supported_hw_ids"`

	// INI file num
	INIFileNum uint32  `json:"ini_file_num"`
	Reserved7  []uint8 `json:"reserved7"`

	// Product version
	ProductVer    string  `json:"product_ver"`
	ProductVerRaw []uint8 `json:"product_ver_raw"`

	// Description
	Description string  `json:"description"`
	Reserved8   []uint8 `json:"reserved8"`

	// Module versions
	ModuleVersions []uint8 `json:"module_versions"`

	// Name fields
	Name    string `json:"name"`
	PRSName string `json:"prs_name"`

	// Human-readable versions for convenience
	FWVersion          string `json:"fw_version"`
	FWReleaseDate      string `json:"fw_release_date"`
	MICVersion         string `json:"mic_version"`
	SecurityAttributes string `json:"security_attributes"`
}

ImageInfoJSON is a JSON-serializable version of ImageInfo that can be directly marshaled/unmarshaled

func (*ImageInfoJSON) FromImageInfo

func (j *ImageInfoJSON) FromImageInfo(info *ImageInfo)

FromImageInfo converts ImageInfo to ImageInfoJSON

func (*ImageInfoJSON) ToImageInfo

func (j *ImageInfoJSON) ToImageInfo() *ImageInfo

ToImageInfo converts ImageInfoJSON back to ImageInfo

type ImageSignature

type ImageSignature struct {
	SignatureType uint32     `offset:"byte:0,endian:be" json:"signature_type"` // offset 0x0
	Signature     [256]uint8 `offset:"byte:4" json:"-"`                        // offset 0x4 - Handled separately in MarshalJSON/UnmarshalJSON
}

ImageSignature represents the image signature structure using annotations Based on image_layout_image_signature from mstflint

func (*ImageSignature) Marshal

func (s *ImageSignature) Marshal() ([]byte, error)

Marshal marshals ImageSignature into binary data

func (*ImageSignature) MarshalJSON

func (s *ImageSignature) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface for ImageSignature

func (*ImageSignature) Unmarshal

func (s *ImageSignature) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into ImageSignature

func (*ImageSignature) UnmarshalJSON

func (s *ImageSignature) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface for ImageSignature

type ImageSignature2

type ImageSignature2 struct {
	SignatureType uint32     `offset:"byte:0,endian:be" json:"signature_type"` // offset 0x0
	Signature     [512]uint8 `offset:"byte:4" json:"-"`                        // offset 0x4 - Handled separately in MarshalJSON/UnmarshalJSON
}

ImageSignature2 represents the extended image signature structure using annotations Based on image_layout_image_signature_2 from mstflint

func (*ImageSignature2) Marshal

func (s *ImageSignature2) Marshal() ([]byte, error)

Marshal marshals ImageSignature2 into binary data

func (*ImageSignature2) MarshalJSON

func (s *ImageSignature2) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface for ImageSignature2

func (*ImageSignature2) Unmarshal

func (s *ImageSignature2) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into ImageSignature2

func (*ImageSignature2) UnmarshalJSON

func (s *ImageSignature2) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface for ImageSignature2

type ImageSignatureJSON

type ImageSignatureJSON struct {
	SignatureType uint32 `json:"signature_type"`
	Signature     string `json:"signature"`         // Hex encoded
	Padding       string `json:"padding,omitempty"` // Hex encoded padding data
}

ImageSignatureJSON represents image signature sections in JSON

type ImageSize

type ImageSize struct {
	LogStep    uint8    // log of next address in bytes to search for an image
	Reserved   [3]uint8 // padding to make it 32-bit aligned
	RunFromAny uint8    // bit 31: this image can run from any partition
	MaxSize    uint32   // Max possible size in bytes of image
}

ImageSize represents the image size structure Based on image_layout_image_size from mstflint

func (*ImageSize) Marshal

func (i *ImageSize) Marshal() ([]byte, error)

func (*ImageSize) Unmarshal

func (i *ImageSize) Unmarshal(data []byte) error

Marshal/Unmarshal methods for ImageSize

type InSectionCRCPolicy

type InSectionCRCPolicy uint8

InSectionCRCPolicy defines how to handle the 4-byte trailer for IN_SECTION CRC sections during reassembly.

const (
	// InSectionCRCPolicySoftware: calculate CRC16 in software on section payload (without trailer)
	InSectionCRCPolicySoftware InSectionCRCPolicy = iota
	// InSectionCRCPolicyHardware: calculate hardware CRC16 (rare for trailer; HW pointers handled elsewhere)
	InSectionCRCPolicyHardware
	// InSectionCRCPolicyBlank: write 0xFFFFFFFF sentinel as trailer (observed in several sections)
	InSectionCRCPolicyBlank
)

func GetInSectionCRCPolicy

func GetInSectionCRCPolicy(sectionType uint16) InSectionCRCPolicy

GetInSectionCRCPolicy returns the policy for adding the trailing 4-byte word for sections that use CRCInSection. This centralizes behavior used by the reassembler. Notes: - TOOLS_AREA: policy is Software (CRC over first 60 bytes; the reassembler passes the payload without trailer). - BOOT2: trailer is usually 0xFFFFFFFF; the internal CRC is validated separately. - DEV_INFO/MFG_INFO/IMAGE_INFO/SIGNATURES/PUBLIC_KEYS/FORBIDDEN_VERSIONS/HASHES_TABLE: trailer is observed as 0xFFFFFFFF. - All other sections default to Software.

type MacsJSON

type MacsJSON struct {
	Reserved1    uint16 `json:"reserved1"`
	Step         uint8  `json:"step"`
	NumAllocated uint8  `json:"num_allocated"`
	Reserved2    uint32 `json:"reserved2"`
	UID          uint64 `json:"uid"`
}

MacsJSON represents MAC info in JSON

type MagicPatternStruct

type MagicPatternStruct struct {
	Magic    uint64 `offset:"byte:0,endian:be"`               // Should be MagicPattern constant
	Reserved uint64 `offset:"byte:8,endian:be,reserved:true"` // Reserved/padding
}

MagicPatternStruct represents the firmware magic pattern structure This is found at various offsets in the firmware image

func (*MagicPatternStruct) Marshal

func (m *MagicPatternStruct) Marshal() ([]byte, error)

Marshal marshals the annotated structure into binary data

func (*MagicPatternStruct) Unmarshal

func (m *MagicPatternStruct) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into the annotated structure

type MfgInfo

type MfgInfo struct {
	// PSID - offset 0x0
	PSID [16]byte `offset:"byte:0" json:"-"` // "MT_0000000911" (will be handled separately in MarshalJSON)

	// Unknown fields - offset 0x10
	Reserved1 [12]byte `offset:"byte:16,reserved:true" json:"reserved1"` // offset 0x10-0x1b
	Flags     uint32   `offset:"byte:28,endian:be" json:"flags"`         // offset 0x1c - observed 0x01000001

	// GUID allocation info - offset 0x20
	Guids UidEntry `offset:"byte:32" json:"guids"` // offset 0x20-0x2f - GUID allocation info

	// MAC allocation info - offset 0x30
	Macs UidEntry `offset:"byte:48" json:"macs"` // offset 0x30-0x3f - MAC allocation info

	// Trailing padding (variable): different families use different total sizes.
	// Observed: 0x100 (256) on some CX6Dx firmwares and 0x140 (320) on CX5.
	// To match mstflint (image_layout_mfg_info) behavior and avoid magic sizes,
	// model the tail as a slice starting at 0x40 so we accept either layout.
	// CRC/size for this section come from the DTOC/ITOC entry, not from an
	// embedded trailer.
	Reserved2 []byte `offset:"byte:64,reserved:true" json:"reserved2"`
}

MfgInfo represents the MFG_INFO section structure using annotations Based on mstflint's image_layout_mfg_info structure and hex dump analysis

func (*MfgInfo) GetPSIDString

func (m *MfgInfo) GetPSIDString() string

GetPSIDString returns PSID as a cleaned string

func (*MfgInfo) Marshal

func (m *MfgInfo) Marshal() ([]byte, error)

Marshal marshals MfgInfo into binary data

func (*MfgInfo) MarshalJSON

func (m *MfgInfo) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (*MfgInfo) Unmarshal

func (m *MfgInfo) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into MfgInfo

func (*MfgInfo) UnmarshalJSON

func (m *MfgInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type MfgInfoJSON

type MfgInfoJSON struct {
	PSID        []byte `json:"psid"`
	PartNumber  []byte `json:"part_number"`
	Revision    []byte `json:"revision"`
	ProductName []byte `json:"product_name"`
	Reserved    []byte `json:"reserved"`
}

MfgInfoJSON is a JSON-serializable version of MfgInfo

type ModuleVersion

type ModuleVersion struct {
	Major  uint16 `bin:"BE,bitfield=12"` // offset 0x0.20-0x0.31 (12 bits)
	Minor  uint16 `bin:"BE,bitfield=12"` // offset 0x0.8-0x0.19 (12 bits)
	Branch uint8  `bin:"BE"`             // offset 0x0.0-0x0.7
}

ModuleVersion represents a module version structure Based on image_layout_module_version from mstflint

func (*ModuleVersion) Marshal

func (m *ModuleVersion) Marshal() ([]byte, error)

func (*ModuleVersion) Unmarshal

func (m *ModuleVersion) Unmarshal(data []byte) error

Marshal/Unmarshal methods for ModuleVersion

type ModuleVersions

type ModuleVersions struct {
	Core           ModuleVersion // offset 0x0
	Phy            ModuleVersion // offset 0x4
	Kernel         ModuleVersion // offset 0x8
	IronImage      ModuleVersion // offset 0xc
	HostManagement ModuleVersion // offset 0x10
	Mad            ModuleVersion // offset 0x14
	Reserved       [40]uint8     // padding to 64 bytes
}

ModuleVersions represents module versions structure Based on image_layout_module_versions from mstflint

func (*ModuleVersions) Marshal

func (m *ModuleVersions) Marshal() ([]byte, error)

func (*ModuleVersions) Unmarshal

func (m *ModuleVersions) Unmarshal(data []byte) error

Marshal/Unmarshal methods for ModuleVersions

type NVData

type NVData struct {
	Version   uint32    `offset:"0x0,endian:be"`               // NV data version
	DataSize  uint32    `offset:"0x4,endian:be"`               // Size of NV data
	Reserved1 uint32    `offset:"0x8,endian:be,reserved:true"` // Reserved
	Reserved2 uint32    `offset:"0xc,endian:be,reserved:true"` // Reserved
	Reserved3 [48]uint8 `offset:"0x10,reserved:true"`          // Reserved padding
}

NVData represents the NV_DATA sections (NV_DATA0, NV_DATA1, NV_DATA2) with annotations

func (*NVData) Marshal

func (n *NVData) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*NVData) MarshalWithReserved

func (n *NVData) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals to binary data including reserved fields

func (*NVData) Unmarshal

func (n *NVData) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

func (*NVData) UnmarshalWithReserved

func (n *NVData) UnmarshalWithReserved(data []byte) error

UnmarshalWithReserved unmarshals binary data including reserved fields

type NVDataJSON

type NVDataJSON struct {
	Version        uint32 `json:"version"`
	DataSize       uint32 `json:"data_size"`
	ActualDataSize int    `json:"actual_data_size"`
}

NVDataJSON represents NV_DATA section data in JSON

type OperationKey

type OperationKey struct {
	KeyModifier uint64 // offset 0x0
	Key         uint64 // offset 0x8
}

OperationKey represents an operation key structure Based on image_layout_operation_key from mstflint

func (*OperationKey) Marshal

func (o *OperationKey) Marshal() ([]byte, error)

func (*OperationKey) Unmarshal

func (o *OperationKey) Unmarshal(data []byte) error

Marshal/Unmarshal methods for OperationKey

type ProgrammableHWFW

type ProgrammableHWFW struct {
	Version     uint32    `offset:"0x0,endian:be"`      // Firmware version
	HWType      uint32    `offset:"0x4,endian:be"`      // Hardware type
	FWSize      uint32    `offset:"0x8,endian:be"`      // Firmware size
	Checksum    uint32    `offset:"0xc,endian:be"`      // Firmware checksum
	LoadAddress uint32    `offset:"0x10,endian:be"`     // Load address in hardware
	EntryPoint  uint32    `offset:"0x14,endian:be"`     // Entry point address
	Reserved    [40]uint8 `offset:"0x18,reserved:true"` // Reserved
}

ProgrammableHWFW represents PROGRAMMABLE_HW_FW sections with annotations

func (*ProgrammableHWFW) Marshal

func (p *ProgrammableHWFW) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*ProgrammableHWFW) MarshalWithReserved

func (p *ProgrammableHWFW) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals to binary data including reserved fields

func (*ProgrammableHWFW) Unmarshal

func (p *ProgrammableHWFW) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

func (*ProgrammableHWFW) UnmarshalWithReserved

func (p *ProgrammableHWFW) UnmarshalWithReserved(data []byte) error

UnmarshalWithReserved unmarshals binary data including reserved fields

type ProgrammableHWFWJSON

type ProgrammableHWFWJSON struct {
	Version     uint32 `json:"version"`
	HWType      uint32 `json:"hw_type"`
	FWSize      uint32 `json:"fw_size"`
	Checksum    uint32 `json:"checksum"`
	LoadAddress string `json:"load_address"`
	EntryPoint  string `json:"entry_point"`
	DataSize    int    `json:"data_size"`
}

ProgrammableHWFWJSON represents PROGRAMMABLE_HW_FW section data in JSON

type PublicKey

type PublicKey struct {
	Reserved uint32     `offset:"byte:0,endian:be,reserved:true" json:"reserved"` // offset 0x0
	UUID     [16]uint8  `offset:"byte:4" json:"-"`                                // offset 0x4 - Handled separately in MarshalJSON/UnmarshalJSON
	Key      [256]uint8 `offset:"byte:20" json:"-"`                               // offset 0x14 (20 decimal) - Handled separately in MarshalJSON/UnmarshalJSON
}

PublicKey represents a public key structure using annotations Based on image_layout_file_public_keys from mstflint

func (*PublicKey) Marshal

func (p *PublicKey) Marshal() ([]byte, error)

Marshal marshals PublicKey into binary data

func (*PublicKey) MarshalJSON

func (p *PublicKey) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface for PublicKey

func (*PublicKey) Unmarshal

func (p *PublicKey) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into PublicKey

func (*PublicKey) UnmarshalJSON

func (p *PublicKey) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface for PublicKey

type PublicKey2

type PublicKey2 struct {
	Reserved uint32     `offset:"byte:0,endian:be,reserved:true" json:"reserved"` // offset 0x0
	UUID     [16]uint8  `offset:"byte:4" json:"-"`                                // offset 0x4 - Handled separately in MarshalJSON/UnmarshalJSON
	Key      [512]uint8 `offset:"byte:20" json:"-"`                               // offset 0x14 (20 decimal) - Handled separately in MarshalJSON/UnmarshalJSON
}

PublicKey2 represents an extended public key structure using annotations Based on image_layout_file_public_keys_2 from mstflint

func (*PublicKey2) Marshal

func (p *PublicKey2) Marshal() ([]byte, error)

Marshal marshals PublicKey2 into binary data

func (*PublicKey2) MarshalJSON

func (p *PublicKey2) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface for PublicKey2

func (*PublicKey2) Unmarshal

func (p *PublicKey2) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into PublicKey2

func (*PublicKey2) UnmarshalJSON

func (p *PublicKey2) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface for PublicKey2

type PublicKeyBlock

type PublicKeyBlock struct {
	KeyType   uint32 `bin:"BE"` // Type of key (RSA-2048, RSA-4096, etc.)
	KeyLength uint32 `bin:"BE"` // Length of key data
	KeyID     uint32 `bin:"BE"` // Key identifier
	Reserved  uint32 `bin:"BE"` // Reserved field
	PublicKey []byte `bin:""`   // Variable length public key data
}

PublicKeyBlock represents a public key block Used for PUBLIC_KEYS_2048 and PUBLIC_KEYS_4096 sections

type PublicKeyJSON

type PublicKeyJSON struct {
	Index    int    `json:"index,omitempty"`
	Reserved uint32 `json:"reserved"`
	UUID     string `json:"uuid"` // Hex encoded
	Key      string `json:"key"`  // Hex encoded
}

PublicKeyJSON represents a public key entry in JSON

type PublicKeys

type PublicKeys struct {
	Keys [8]PublicKey `offset:"byte:0" json:"keys"` // offset 0x0
}

PublicKeys represents an array of public keys using annotations Based on image_layout_public_keys from mstflint

func (*PublicKeys) Marshal

func (p *PublicKeys) Marshal() ([]byte, error)

Marshal marshals PublicKeys into binary data

func (*PublicKeys) MarshalWithReserved

func (p *PublicKeys) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals PublicKeys including reserved fields

func (*PublicKeys) Unmarshal

func (p *PublicKeys) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into PublicKeys

type PublicKeys2

type PublicKeys2 struct {
	Keys [8]PublicKey2 `offset:"byte:0" json:"keys"` // offset 0x0
}

PublicKeys2 represents an array of extended public keys using annotations Based on image_layout_public_keys_2 from mstflint

func (*PublicKeys2) Marshal

func (p *PublicKeys2) Marshal() ([]byte, error)

Marshal marshals PublicKeys2 into binary data

func (*PublicKeys2) MarshalWithReserved

func (p *PublicKeys2) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals PublicKeys2 including reserved fields

func (*PublicKeys2) Unmarshal

func (p *PublicKeys2) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into PublicKeys2

type RSAPublicKey

type RSAPublicKey struct {
	KeyType   uint32     `offset:"0x0,endian:be"` // RSA key type (2048, 4096, etc)
	KeySize   uint32     `offset:"0x4,endian:be"` // Key size in bytes
	Exponent  uint32     `offset:"0x8,endian:be"` // Public exponent (usually 65537)
	Reserved1 uint32     `offset:"0xc,endian:be"` // Reserved
	Modulus   [512]uint8 `offset:"0x10"`          // RSA modulus (up to 4096 bits)
	Reserved2 [496]uint8 `offset:"0x210"`         // Padding to 1024 bytes
}

RSAPublicKey represents the RSA_PUBLIC_KEY section with annotations

func (*RSAPublicKey) Marshal

func (r *RSAPublicKey) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*RSAPublicKey) MarshalWithReserved

func (r *RSAPublicKey) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals to binary data including reserved fields

func (*RSAPublicKey) Unmarshal

func (r *RSAPublicKey) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

func (*RSAPublicKey) UnmarshalWithReserved

func (r *RSAPublicKey) UnmarshalWithReserved(data []byte) error

UnmarshalWithReserved unmarshals binary data including reserved fields

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader provides endian-aware reading capabilities

func NewBigEndianReader

func NewBigEndianReader(r io.ReaderAt) *Reader

NewBigEndianReader creates a new big-endian reader

func (*Reader) ReadAt

func (r *Reader) ReadAt(p []byte, off int64) (int, error)

ReadAt implements io.ReaderAt

func (*Reader) ReadBytes

func (r *Reader) ReadBytes(off int64, size int) ([]byte, error)

ReadBytes reads a byte slice at the specified offset

func (*Reader) ReadUint32At

func (r *Reader) ReadUint32At(off int64) (uint32, error)

ReadUint32At reads a uint32 at the specified offset

func (*Reader) ReadUint64At

func (r *Reader) ReadUint64At(off int64) (uint64, error)

ReadUint64At reads a uint64 at the specified offset

type ResetCapabilities

type ResetCapabilities struct {
	ResetVerEn       uint8  `offset:"bit:0,len:1,endian:be"` // bit 0
	Reserved1        uint8  `offset:"bit:1,len:7,endian:be"` // bits 1-7
	VersionVectorVer uint8  `offset:"byte:1,endian:be"`      // bits 8-15
	Reserved2        uint16 `offset:"byte:2,endian:be"`      // bits 16-31
}

ResetCapabilities represents reset capabilities with annotations

func (*ResetCapabilities) Marshal

func (r *ResetCapabilities) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*ResetCapabilities) Unmarshal

func (r *ResetCapabilities) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type ResetInfo

type ResetInfo struct {
	Data [256]uint8 `offset:"0x0"` // Full 256-byte section
}

ResetInfo represents the RESET_INFO section structure with annotations

func (*ResetInfo) Marshal

func (r *ResetInfo) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*ResetInfo) MarshalWithReserved

func (r *ResetInfo) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals to binary data including reserved fields

func (*ResetInfo) Unmarshal

func (r *ResetInfo) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

func (*ResetInfo) UnmarshalWithReserved

func (r *ResetInfo) UnmarshalWithReserved(data []byte) error

UnmarshalWithReserved unmarshals binary data including reserved fields

type ResetInfoJSON

type ResetInfoJSON struct {
	HardReset uint32 `json:"hard_reset"`
	SoftReset uint32 `json:"soft_reset"`
	Reserved  uint32 `json:"reserved"`
}

ResetInfoJSON represents reset information in JSON

type ResetVersion

type ResetVersion struct {
	Major    uint16 `offset:"bit:0,len:16,endian:be"` // bits 0-15
	Branch   uint8  `offset:"bit:16,len:4,endian:be"` // bits 16-19
	Minor    uint8  `offset:"bit:20,len:8,endian:be"` // bits 20-27
	Reserved uint8  `offset:"bit:28,len:4,endian:be"` // bits 28-31
}

ResetVersion represents reset version structure with annotations

func (*ResetVersion) Marshal

func (r *ResetVersion) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*ResetVersion) Unmarshal

func (r *ResetVersion) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type RootCertificates

type RootCertificates struct {
	Version   uint32   `offset:"0x0,endian:be"`     // Version
	CertCount uint32   `offset:"0x4,endian:be"`     // Number of certificates
	Reserved  [8]uint8 `offset:"0x8,reserved:true"` // Reserved
}

RootCertificates represents ROOT_CERTIFICATES sections with annotations

func (*RootCertificates) Marshal

func (r *RootCertificates) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*RootCertificates) Unmarshal

func (r *RootCertificates) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type SectionJSON

type SectionJSON struct {
	// Metadata fields
	Type         uint16 `json:"type"`
	TypeName     string `json:"type_name"`
	Offset       uint64 `json:"offset"`
	Size         uint32 `json:"size"`
	CRCType      string `json:"crc_type"`
	IsEncrypted  bool   `json:"is_encrypted"`
	IsDeviceData bool   `json:"is_device_data"`

	// Indicates if this section has raw data that needs binary file
	HasRawData bool `json:"has_raw_data"`

	// Type-specific data (one of these will be populated)
	ImageInfo         *ImageInfoJSON         `json:"image_info,omitempty"`
	DeviceInfo        *DevInfoJSON           `json:"device_info,omitempty"`
	MfgInfo           *MfgInfoJSON           `json:"mfg_info,omitempty"`
	HashesTable       *HashesTableJSON       `json:"hashes_table,omitempty"`
	ImageSignature    *ImageSignatureJSON    `json:"signature,omitempty"`
	PublicKeys        []PublicKeyJSON        `json:"keys,omitempty"`
	ForbiddenVersions *ForbiddenVersionsJSON `json:"forbidden_versions,omitempty"`
	FS4HWPointers     *FS4HWPointersJSON     `json:"fs4_hw_pointers,omitempty"`
	FS5HWPointers     *FS5HWPointersJSON     `json:"fs5_hw_pointers,omitempty"`
	ITOC              *ITOCJSON              `json:"itoc,omitempty"`
	DTOC              *DTOCJSON              `json:"dtoc,omitempty"`
	ResetInfo         *ResetInfoJSON         `json:"reset_info,omitempty"`
	ToolsAreaExtended *ToolsAreaExtendedJSON `json:"tools_area_extended,omitempty"`

	// DTOC sections
	VPD_R0           *VPD_R0JSON           `json:"vpd_r0,omitempty"`
	FWNVLog          *FWNVLogJSON          `json:"fw_nv_log,omitempty"`
	NVData           *NVDataJSON           `json:"nv_data,omitempty"`
	CRDumpMaskData   *CRDumpMaskDataJSON   `json:"crdump_mask_data,omitempty"`
	FWInternalUsage  *FWInternalUsageJSON  `json:"fw_internal_usage,omitempty"`
	ProgrammableHWFW *ProgrammableHWFWJSON `json:"programmable_hw_fw,omitempty"`
	DigitalCertPtr   *DigitalCertPtrJSON   `json:"digital_cert_ptr,omitempty"`
	DigitalCertRW    *DigitalCertRWJSON    `json:"digital_cert_rw,omitempty"`

	// For sections with padding
	Padding string `json:"padding,omitempty"` // Hex encoded padding data
}

Generic section JSON wrapper that includes both metadata and type-specific data

type SectionType

type SectionType uint16

SectionType represents a firmware section type

func (SectionType) MarshalJSON

func (s SectionType) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (*SectionType) UnmarshalJSON

func (s *SectionType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type SecureBootSignatures

type SecureBootSignatures struct {
	BootSignature        [128]uint32 `offset:"0x0,endian:be"`   // offset 0x0 - boot signature of data
	CriticalSignature    [128]uint32 `offset:"0x200,endian:be"` // offset 0x200 - fw critical signature of itcos
	NonCriticalSignature [128]uint32 `offset:"0x400,endian:be"` // offset 0x400 - fw non critical signatures
}

SecureBootSignatures represents the secure boot signatures structure with annotations

func (*SecureBootSignatures) Marshal

func (s *SecureBootSignatures) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*SecureBootSignatures) Unmarshal

func (s *SecureBootSignatures) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

type SecurityModeMask

type SecurityModeMask struct {
	MCC_EN                  uint32
	DEBUG_FW                uint32
	SIGNED_FW               uint32
	SECURE_FW               uint32
	DEV_FW                  uint32
	CS_TOKEN                uint32
	DBG_TOKEN               uint32
	CRYPTO_TO_COMMISSIONING uint32
	RMCS_TOKEN              uint32
	RMDT_TOKEN              uint32
}

SecurityModeMask defines the security mode flags Based on mstflint's security_mode_mask enum

type SignatureBlock

type SignatureBlock struct {
	SignatureType   uint32 `bin:"BE"` // Type of signature (RSA-2048, RSA-4096, etc.)
	SignatureLength uint32 `bin:"BE"` // Length of signature data
	Reserved1       uint32 `bin:"BE"` // Reserved field
	Reserved2       uint32 `bin:"BE"` // Reserved field
	Signature       []byte `bin:""`   // Variable length signature data
}

SignatureBlock represents a firmware signature block Used for IMAGE_SIGNATURE_256 and IMAGE_SIGNATURE_512 sections

type ToolsArea

type ToolsArea struct {
	BinaryHeader BinaryVersion `offset:"byte:0"`
}

ToolsArea represents the tools area header structure

func (*ToolsArea) Marshal

func (t *ToolsArea) Marshal() ([]byte, error)

Marshal marshals the annotated structure into binary data

func (*ToolsArea) Unmarshal

func (t *ToolsArea) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into the annotated structure

type ToolsAreaExtended

type ToolsAreaExtended struct {
	TLVRC       uint32    `offset:"byte:0,endian:be"`      // offset 0x0
	CRCFlag     uint32    `offset:"byte:4,endian:be"`      // offset 0x4
	TotalLength uint32    `offset:"byte:8,endian:be"`      // offset 0x8
	TypeLength  uint32    `offset:"byte:12,endian:be"`     // offset 0xc
	TypeData    [16]uint8 `offset:"byte:16"`               // offset 0x10
	Reserved    [32]uint8 `offset:"byte:32,reserved:true"` // offset 0x20
}

ToolsAreaExtended represents the tools area structure using annotations Based on image_layout_tools_area from mstflint

func (*ToolsAreaExtended) Marshal

func (t *ToolsAreaExtended) Marshal() ([]byte, error)

Marshal marshals ToolsAreaExtended into binary data

func (*ToolsAreaExtended) Unmarshal

func (t *ToolsAreaExtended) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into ToolsAreaExtended

type ToolsAreaExtendedJSON

type ToolsAreaExtendedJSON struct {
	Data string `json:"data"` // Hex encoded
}

ToolsAreaExtendedJSON represents extended tools area in JSON

type TripleVersion

type TripleVersion struct {
	Major    uint16 `bin:"BE"` // offset 0x0.16-0x0.31
	Reserved uint16 `bin:"BE"` // offset 0x0.0-0x0.15 (padding)
	Minor    uint16 `bin:"BE"` // offset 0x4.16-0x4.31
	Subminor uint16 `bin:"BE"` // offset 0x4.0-0x4.15
}

TripleVersion represents a triple version structure Based on image_layout_TRIPPLE_VERSION from mstflint

func (*TripleVersion) Marshal

func (t *TripleVersion) Marshal() ([]byte, error)

func (*TripleVersion) Unmarshal

func (t *TripleVersion) Unmarshal(data []byte) error

Marshal/Unmarshal methods for TripleVersion

type UIDEntry

type UIDEntry struct {
	NumAllocated     uint8     // offset 0x0.0-0x0.7
	Reserved1        uint8     // offset 0x0.8-0x0.15
	Step             uint16    // offset 0x0.16-0x0.31
	NumOfGuids       uint8     // offset 0x4.16-0x4.23
	AllocatedUIDMask uint8     // offset 0x4.24-0x4.31
	Reserved2        uint16    // offset 0x4.0-0x4.15
	GUID0H           uint32    // offset 0x8
	GUID0L           uint32    // offset 0xc
	Reserved3        [16]uint8 // offset 0x10-0x1f
}

UIDEntry represents a UID entry structure Based on image_layout_uid_entry from mstflint

func (*UIDEntry) Marshal

func (u *UIDEntry) Marshal() ([]byte, error)

func (*UIDEntry) Unmarshal

func (u *UIDEntry) Unmarshal(data []byte) error

Marshal/Unmarshal methods for UIDEntry

type UidEntry

type UidEntry struct {
	Reserved1    uint16 `offset:"byte:0,endian:be,reserved:true" json:"reserved1"` // reserved (0x0000)
	Step         uint8  `offset:"byte:2" json:"step"`                              // Step size (not used for CX4+)
	NumAllocated uint8  `offset:"byte:3" json:"num_allocated"`                     // Number of allocated UIDs
	Reserved2    uint32 `offset:"byte:4,endian:be,reserved:true" json:"reserved2"` // reserved
	UID          uint64 `offset:"byte:8,endian:be" json:"uid"`                     // Base UID value
}

UidEntry represents UID allocation information using annotations Based on mstflint's image_layout_uid_entry structure

func (UidEntry) GetNumAllocated

func (u UidEntry) GetNumAllocated() int

Helper methods to preserve legacy API usage

func (UidEntry) GetUID

func (u UidEntry) GetUID() uint64

func (*UidEntry) Marshal

func (u *UidEntry) Marshal() ([]byte, error)

Marshal marshals UidEntry into binary data

func (*UidEntry) Unmarshal

func (u *UidEntry) Unmarshal(data []byte) error

Unmarshal unmarshals binary data into UidEntry

type VPD_R0

type VPD_R0 struct {
	ID       [2]uint8  `offset:"0x0"`               // Should be "VPD_R0"
	Length   uint16    `offset:"0x2,endian:be"`     // Length of VPD data
	Reserved [60]uint8 `offset:"0x4,reserved:true"` // Reserved/padding
}

VPD_R0 represents the VPD_R0 section (Vital Product Data) with annotations

func (*VPD_R0) Marshal

func (v *VPD_R0) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*VPD_R0) MarshalWithReserved

func (v *VPD_R0) MarshalWithReserved() ([]byte, error)

MarshalWithReserved marshals to binary data including reserved fields

func (*VPD_R0) Unmarshal

func (v *VPD_R0) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

func (*VPD_R0) UnmarshalWithReserved

func (v *VPD_R0) UnmarshalWithReserved(data []byte) error

UnmarshalWithReserved unmarshals binary data including reserved fields

type VPD_R0JSON

type VPD_R0JSON struct {
	ID       string `json:"id"`
	Length   uint16 `json:"length"`
	DataSize int    `json:"data_size"`
}

VPD_R0JSON represents VPD_R0 section data in JSON

type VersionVector

type VersionVector struct {
	ResetCapabilities ResetCapabilities `offset:"0x0"`  // offset 0x0
	Scratchpad        ResetVersion      `offset:"0x4"`  // offset 0x4 - cores SP
	ICMContext        ResetVersion      `offset:"0x8"`  // offset 0x8
	PCI               ResetVersion      `offset:"0xc"`  // offset 0xc - PCI domain
	PHY               ResetVersion      `offset:"0x10"` // offset 0x10 - PHY domain
	INI               ResetVersion      `offset:"0x14"` // offset 0x14
	Reserved1         ResetVersion      `offset:"0x18"` // offset 0x18
	Reserved2         ResetVersion      `offset:"0x1c"` // offset 0x1c
	Reserved3         ResetVersion      `offset:"0x20"` // offset 0x20
	Reserved4         ResetVersion      `offset:"0x24"` // offset 0x24
	Reserved5         ResetVersion      `offset:"0x28"` // offset 0x28
	Reserved6         ResetVersion      `offset:"0x2c"` // offset 0x2c
	Reserved7         ResetVersion      `offset:"0x30"` // offset 0x30 - total 52 bytes
}

VersionVector represents the version vector structure with annotations

func (*VersionVector) Marshal

func (v *VersionVector) Marshal() ([]byte, error)

Marshal marshals to binary data

func (*VersionVector) Unmarshal

func (v *VersionVector) Unmarshal(data []byte) error

Unmarshal unmarshals binary data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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