nrf

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoFirmwareSigned = errors.New("firmware is not signed")

Functions

func DetectSDKVersion

func DetectSDKVersion(r io.ReaderAt) (string, error)

func DumpVerifyingKey

func DumpVerifyingKey(b []byte) ([]byte, error)

func HexFileToBinary

func HexFileToBinary(b []byte) ([]byte, error)

func UnmarshalDfuFile

func UnmarshalDfuFile(name string) (*dfu.Packet, error)

UnmarshalDfuFile parses the dat file and returns an init packet.

func VerifySignature

func VerifySignature(vk, cmd, sig []byte) error

VerifySignature verifies firmware signatures using ECDSA P-256 or Ed25519 public keys. pem format is also supported.

Types

type Application

type Application struct {
	BinFile string `json:"bin_file"`
	DatFile string `json:"dat_file"`
}

type DfuContents

type DfuContents struct {
	Manifest Manifest `json:"manifest"`
}

type DfuInfo

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

func OpenDfuFile

func OpenDfuFile(name string) (*DfuInfo, error)

func (*DfuInfo) Signature

func (d *DfuInfo) Signature() []byte

Signature returns the signature contained in the init packet

func (*DfuInfo) String

func (d *DfuInfo) String() string

func (*DfuInfo) Verify

func (d *DfuInfo) Verify(key []byte) error

Verify verifies the signature of OTA dfu files

type DfuSettingAttrs

type DfuSettingAttrs struct {
	Crc          uint32
	Version      uint32
	AppVersion   uint32
	BlVersion    uint32
	BankLayout   uint32
	BankCr       uint32
	Bank0ImgSize uint32
	Bank0ImgCrc  uint32
	Bank0Code    uint32
	Reserve      [12]uint8
	// soft device size
	SdSize   uint32
	Reserve2 [40]uint8
}

type Firmware

type Firmware struct {
	Attr *DfuSettingAttrs
	// contains filtered or unexported fields
}

func OpenFirmware

func OpenFirmware(name string) (*Firmware, error)

func (*Firmware) Arch

func (f *Firmware) Arch() string

func (*Firmware) ExtractApp

func (f *Firmware) ExtractApp() ([]byte, error)

func (*Firmware) ExtractBootloader

func (f *Firmware) ExtractBootloader() ([]byte, error)

type Hash

type Hash struct {
	SoftDevice string `json:"softDevice"`
	Signature  string `json:"signature"`
}

func GenSignatureFromSDK

func GenSignatureFromSDK(name, version string) ([]Hash, error)

type ImageTLV

type ImageTLV struct {
	ItType uint8
	Pad    uint8
	ItSize uint16
}

type ImageTLVInfo

type ImageTLVInfo struct {
	Magic     uint16
	TotalSize uint16
}

ImageTLVInfo is information about TLV(tag-length-value). Magic and total size of TLV area.

type ImgVersion

type ImgVersion struct {
	Major    uint8
	Minor    uint8
	Revision uint16
	BuildNum uint32
}

type MCUBoot

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

func DetectMCUBoot

func DetectMCUBoot(name string) (*MCUBoot, error)

func (*MCUBoot) ExtractImage

func (b *MCUBoot) ExtractImage() ([]byte, error)

func (*MCUBoot) Header

func (b *MCUBoot) Header() *MCUBootImgHeader

func (*MCUBoot) ReadTLVArea

func (b *MCUBoot) ReadTLVArea() (*TLVArea, error)

type MCUBootImgHeader

type MCUBootImgHeader struct {
	Magic            uint32
	LoadAddr         uint32
	Size             uint16
	ProtectedTLVSize uint16
	ImgSize          uint32
	Flags            uint32
	Ver              ImgVersion
	Pad              uint32
}

func (*MCUBootImgHeader) IsEncrypted

func (m *MCUBootImgHeader) IsEncrypted() bool

type Manifest

type Manifest struct {
	App Application `json:"application"`
}

type SDKSignatures

type SDKSignatures struct {
	Signatures []Signatures `json:"signatures"`
}

type Signatures

type Signatures struct {
	SdkVersion string `json:"sdkVersion"`
	Hashes     []Hash `json:"hashes"`
}

type TLVArea

type TLVArea struct {
	ImageHash []byte
	KeyHash   []byte
	Signature []byte
}

func (*TLVArea) VerifyPK

func (a *TLVArea) VerifyPK(key []byte) bool

type TLVType

type TLVType int
const (
	ImageTLVKeyHash       TLVType = 0x01 // hash of the public key
	ImageTLVSHA256        TLVType = 0x10 // SHA256 of image hdr and body
	ImageTLVRsa2048PSS    TLVType = 0x20 // RSA2048 of hash output
	ImageTLVEcdsa224      TLVType = 0x21 // ECDSA of hash output - Not supported anymore
	ImageTLVEcdsaSig      TLVType = 0x22 // ECDSA of hash output
	ImageTLVRsa3072PSS    TLVType = 0x23 // RSA3072 of hash output
	ImageTLVED25519       TLVType = 0x24 // ED25519 of hash output
	ImageTLVEncRsa2048    TLVType = 0x30 // Key encrypted with RSA-OAEP-2048
	ImageTLVEncKW         TLVType = 0x31 // Key encrypted with AES-KW-128 or 256
	ImageTLVEncEC256      TLVType = 0x32 // Key encrypted with ECIES-P256
	ImageTLVEncX25519     TLVType = 0x33 // Key encrypted with ECIES-X25519
	ImageTLVEncDependency TLVType = 0x40 // Image depends on other image
	ImageTLVEncSecCnt     TLVType = 0x50 // security counter
	ImageBootRecord       TLVType = 0x60 // measured boot record
)

Directories

Path Synopsis
Code generated from Pkl module `MemoryConfig`.
Code generated from Pkl module `MemoryConfig`.
arch
Code generated from Pkl module `MemoryConfig`.
Code generated from Pkl module `MemoryConfig`.

Jump to

Keyboard shortcuts

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