Documentation
¶
Index ¶
- func NewHardwareCRC16Handler(calculator interfaces.CRCCalculator) interfaces.SectionCRCHandler
- func NewHardwareCRCCalculator() interfaces.CRCCalculator
- func NewInSectionCRC16Handler(calculator interfaces.CRCCalculator) interfaces.SectionCRCHandler
- func NewSoftwareCRC16Handler(calculator interfaces.CRCCalculator) interfaces.SectionCRCHandler
- func NewSoftwareCRCCalculator() interfaces.CRCCalculator
- type BaseCRCHandler
- func (h *BaseCRCHandler) GetCRCOffset() int
- func (h *BaseCRCHandler) GetCalculator() interfaces.CRCCalculator
- func (h *BaseCRCHandler) HasEmbeddedCRC() bool
- func (h *BaseCRCHandler) ValidateCRCType(crcType types.CRCType, supportedTypes ...types.CRCType) error
- func (h *BaseCRCHandler) VerifyCRC(data []byte, expectedCRC uint32, crcType types.CRCType, ...) error
- func (h *BaseCRCHandler) VerifyCRC16(data []byte, expectedCRC uint32, crcType types.CRCType, ...) error
- type Boot2CRCHandler
- type CRCStrategy
- type DefaultCRCHandler
- type GenericCRCCalculator
- func (c *GenericCRCCalculator) Calculate(data []byte) uint32
- func (c *GenericCRCCalculator) CalculateImageCRC(data []byte, sizeInDwords int) uint16
- func (c *GenericCRCCalculator) CalculateWithParams(data []byte, polynomial, initial, xorOut uint32) uint32
- func (c *GenericCRCCalculator) GetType() types.CRCType
- type HandlerStrategy
- type HardwareCRC16Strategy
- type HardwareCRCStrategy
- type InSectionCRC16Strategy
- type NoCRCHandler
- type SoftwareCRC16Strategy
- type SoftwareCRCStrategy
- type ToolsAreaCRCHandler
- type UnifiedCRCHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHardwareCRC16Handler ¶
func NewHardwareCRC16Handler(calculator interfaces.CRCCalculator) interfaces.SectionCRCHandler
NewHardwareCRC16Handler creates a new hardware CRC16 handler
func NewHardwareCRCCalculator ¶
func NewHardwareCRCCalculator() interfaces.CRCCalculator
NewHardwareCRCCalculator creates a new hardware CRC calculator
func NewInSectionCRC16Handler ¶
func NewInSectionCRC16Handler(calculator interfaces.CRCCalculator) interfaces.SectionCRCHandler
NewInSectionCRC16Handler creates a new in-section CRC16 handler
func NewSoftwareCRC16Handler ¶
func NewSoftwareCRC16Handler(calculator interfaces.CRCCalculator) interfaces.SectionCRCHandler
NewSoftwareCRC16Handler creates a new software CRC16 handler
func NewSoftwareCRCCalculator ¶
func NewSoftwareCRCCalculator() interfaces.CRCCalculator
NewSoftwareCRCCalculator creates a new software CRC calculator
Types ¶
type BaseCRCHandler ¶
type BaseCRCHandler struct {
// contains filtered or unexported fields
}
BaseCRCHandler provides common CRC handling functionality that can be embedded in specific CRC handlers
func NewBaseCRCHandler ¶
func NewBaseCRCHandler(calculator interfaces.CRCCalculator, crcOffset int, hasEmbeddedCRC bool) *BaseCRCHandler
NewBaseCRCHandler creates a new base CRC handler
func (*BaseCRCHandler) GetCRCOffset ¶
func (h *BaseCRCHandler) GetCRCOffset() int
GetCRCOffset returns the offset where CRC is stored
func (*BaseCRCHandler) GetCalculator ¶
func (h *BaseCRCHandler) GetCalculator() interfaces.CRCCalculator
GetCalculator returns the CRC calculator
func (*BaseCRCHandler) HasEmbeddedCRC ¶
func (h *BaseCRCHandler) HasEmbeddedCRC() bool
HasEmbeddedCRC returns whether CRC is embedded in the section
func (*BaseCRCHandler) ValidateCRCType ¶
func (h *BaseCRCHandler) ValidateCRCType(crcType types.CRCType, supportedTypes ...types.CRCType) error
ValidateCRCType checks if the CRC type is supported
type Boot2CRCHandler ¶
type Boot2CRCHandler struct {
*BaseCRCHandler
// contains filtered or unexported fields
}
Boot2CRCHandler implements CRC handling specifically for BOOT2 sections Based on mstflint's CheckBoot2 implementation
func NewBoot2CRCHandler ¶
func NewBoot2CRCHandler() *Boot2CRCHandler
NewBoot2CRCHandler creates a new BOOT2 CRC handler
func (*Boot2CRCHandler) CalculateCRC ¶
CalculateCRC calculates CRC16 for BOOT2 section BOOT2 format: - Header (16 bytes): magic(4) + size_dwords(4) + reserved(8) - Data (size_dwords * 4 bytes) - CRC is at offset (size_dwords + 3) * 4 CRC is calculated over (size_dwords + 3) dwords, excluding the CRC dword
type CRCStrategy ¶
type CRCStrategy interface {
Calculate(calc *parser.CRCCalculator, data []byte) uint32
GetType() types.CRCType
}
CRCStrategy defines the strategy for CRC calculation
type DefaultCRCHandler ¶
type DefaultCRCHandler struct {
// contains filtered or unexported fields
}
DefaultCRCHandler provides default CRC handling for sections
func NewDefaultCRCHandler ¶
func NewDefaultCRCHandler() *DefaultCRCHandler
NewDefaultCRCHandler creates a new default CRC handler
func (*DefaultCRCHandler) CalculateCRC ¶
CalculateCRC calculates the CRC for the section data
func (*DefaultCRCHandler) GetCRCOffset ¶
func (h *DefaultCRCHandler) GetCRCOffset() int
GetCRCOffset returns the offset of CRC within the section data (if CRC is embedded)
func (*DefaultCRCHandler) HasEmbeddedCRC ¶
func (h *DefaultCRCHandler) HasEmbeddedCRC() bool
HasEmbeddedCRC returns true if CRC is stored within the section data
type GenericCRCCalculator ¶
type GenericCRCCalculator struct {
// contains filtered or unexported fields
}
GenericCRCCalculator implements CRC calculation using a strategy
func NewGenericCRCCalculator ¶
func NewGenericCRCCalculator(strategy CRCStrategy) *GenericCRCCalculator
NewGenericCRCCalculator creates a new generic CRC calculator with a strategy
func (*GenericCRCCalculator) Calculate ¶
func (c *GenericCRCCalculator) Calculate(data []byte) uint32
Calculate calculates CRC for the given data using the strategy
func (*GenericCRCCalculator) CalculateImageCRC ¶
func (c *GenericCRCCalculator) CalculateImageCRC(data []byte, sizeInDwords int) uint16
CalculateImageCRC calculates CRC for firmware image data (handles endianness)
func (*GenericCRCCalculator) CalculateWithParams ¶
func (c *GenericCRCCalculator) CalculateWithParams(data []byte, polynomial, initial, xorOut uint32) uint32
CalculateWithParams calculates CRC with specific parameters (uses default calculation)
func (*GenericCRCCalculator) GetType ¶
func (c *GenericCRCCalculator) GetType() types.CRCType
GetType returns the CRC type from the strategy
type HandlerStrategy ¶
type HandlerStrategy interface {
CalculateCRC(calculator interfaces.CRCCalculator, data []byte, crcType types.CRCType) (uint32, error)
ValidCRCTypes() []types.CRCType
}
HandlerStrategy defines the strategy for CRC calculation in handlers
type HardwareCRC16Strategy ¶
type HardwareCRC16Strategy struct{}
HardwareCRC16Strategy implements hardware CRC16 calculation
func (*HardwareCRC16Strategy) CalculateCRC ¶
func (h *HardwareCRC16Strategy) CalculateCRC(calculator interfaces.CRCCalculator, data []byte, crcType types.CRCType) (uint32, error)
func (*HardwareCRC16Strategy) ValidCRCTypes ¶
func (h *HardwareCRC16Strategy) ValidCRCTypes() []types.CRCType
type HardwareCRCStrategy ¶
type HardwareCRCStrategy struct{}
HardwareCRCStrategy implements hardware CRC calculation strategy
func (*HardwareCRCStrategy) Calculate ¶
func (h *HardwareCRCStrategy) Calculate(calc *parser.CRCCalculator, data []byte) uint32
func (*HardwareCRCStrategy) GetType ¶
func (h *HardwareCRCStrategy) GetType() types.CRCType
type InSectionCRC16Strategy ¶
type InSectionCRC16Strategy struct{}
InSectionCRC16Strategy implements in-section CRC16 calculation
func (*InSectionCRC16Strategy) CalculateCRC ¶
func (i *InSectionCRC16Strategy) CalculateCRC(calculator interfaces.CRCCalculator, data []byte, crcType types.CRCType) (uint32, error)
func (*InSectionCRC16Strategy) ValidCRCTypes ¶
func (i *InSectionCRC16Strategy) ValidCRCTypes() []types.CRCType
type NoCRCHandler ¶
type NoCRCHandler struct{}
NoCRCHandler implements a handler for sections without CRC
func NewNoCRCHandler ¶
func NewNoCRCHandler() *NoCRCHandler
NewNoCRCHandler creates a new no-CRC handler
func (*NoCRCHandler) CalculateCRC ¶
CalculateCRC returns 0 as there's no CRC
func (*NoCRCHandler) GetCRCOffset ¶
func (h *NoCRCHandler) GetCRCOffset() int
GetCRCOffset returns -1 as there's no CRC
func (*NoCRCHandler) HasEmbeddedCRC ¶
func (h *NoCRCHandler) HasEmbeddedCRC() bool
HasEmbeddedCRC returns false as there's no CRC
type SoftwareCRC16Strategy ¶
type SoftwareCRC16Strategy struct{}
SoftwareCRC16Strategy implements software CRC16 calculation
func (*SoftwareCRC16Strategy) CalculateCRC ¶
func (s *SoftwareCRC16Strategy) CalculateCRC(calculator interfaces.CRCCalculator, data []byte, crcType types.CRCType) (uint32, error)
func (*SoftwareCRC16Strategy) ValidCRCTypes ¶
func (s *SoftwareCRC16Strategy) ValidCRCTypes() []types.CRCType
type SoftwareCRCStrategy ¶
type SoftwareCRCStrategy struct{}
SoftwareCRCStrategy implements software CRC calculation strategy
func (*SoftwareCRCStrategy) Calculate ¶
func (s *SoftwareCRCStrategy) Calculate(calc *parser.CRCCalculator, data []byte) uint32
func (*SoftwareCRCStrategy) GetType ¶
func (s *SoftwareCRCStrategy) GetType() types.CRCType
type ToolsAreaCRCHandler ¶
type ToolsAreaCRCHandler struct {
*BaseCRCHandler
// contains filtered or unexported fields
}
ToolsAreaCRCHandler implements CRC handling specifically for TOOLS_AREA sections
func NewToolsAreaCRCHandler ¶
func NewToolsAreaCRCHandler() *ToolsAreaCRCHandler
NewToolsAreaCRCHandler creates a new TOOLS_AREA CRC handler
func (*ToolsAreaCRCHandler) CalculateCRC ¶
CalculateCRC calculates CRC16 for TOOLS_AREA (first 60 bytes)
type UnifiedCRCHandler ¶
type UnifiedCRCHandler struct {
*BaseCRCHandler
// contains filtered or unexported fields
}
UnifiedCRCHandler implements a unified CRC handler using strategies
func NewUnifiedCRCHandler ¶
func NewUnifiedCRCHandler(calculator interfaces.CRCCalculator, strategy HandlerStrategy, crcOffset int, hasEmbeddedCRC bool) *UnifiedCRCHandler
NewUnifiedCRCHandler creates a new unified CRC handler
func (*UnifiedCRCHandler) CalculateCRC ¶
CalculateCRC calculates CRC using the strategy