eeprom

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MagicNumber = uint16(0xFEAD)
)

Variables

This section is empty.

Functions

func ReadInventoryFromFile

func ReadInventoryFromFile(filePathSpec string, publicKey ed25519.PublicKey) (*eeinvpb.Inventory, error)

func VerifySignature

func VerifySignature(content *Content, publicKey ed25519.PublicKey) bool

VerifySignature verifies the signature of the Content instance using the provided public key

func WriteInventoryToFile

func WriteInventoryToFile(filePathSpec string, inventory *eeinvpb.Inventory, privateKey ed25519.PrivateKey) error

Types

type Content

type Content struct {
	MagicNumber uint16   // 0xFEAD
	Len         uint16   // Length of the payload
	Signature   [64]byte // ED25519 Signature of the payload (only the actual payload length)
	Payload     []byte   // Payload of the EEPROM data (marshaled protobuf)
}

Content defines the layout of the EEPROM inventory data structure

func NewContent

func NewContent(payload []byte, privateKey ed25519.PrivateKey) (*Content, error)

NewContent creates a new Content instance with the given payload and signs it with the provided private key

func Unmarshal

func Unmarshal(data []byte) (*Content, error)

Unmarshal deserializes the byte slice into a Content instance

func (*Content) Marshal

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

Marshal serializes the Content instance into a byte slice

type EEPROMFile

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

func NewEEPROMFile

func NewEEPROMFile(spec string) (*EEPROMFile, error)

NewEEPROMFile creates a new EEPROMFile instance the filePath is the path plus the offset and size in the form "path@offset:size"

func (*EEPROMFile) Close

func (e *EEPROMFile) Close() error

Close closes the file

func (*EEPROMFile) Read

func (e *EEPROMFile) Read() ([]byte, error)

Read reads the EEPROM data from the file

func (*EEPROMFile) Write

func (e *EEPROMFile) Write(data []byte) error

Write writes the EEPROM data to the file

Jump to

Keyboard shortcuts

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