Replies: 2 comments
-
|
TODO:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Addenum:
// Ported from the 010-Editor template available at https://github.com/ramikg/airoha-firmware-parser
#pragma author ramikg, mos9527
#pragma description Airoha Encrypted Firmware Package
#pragma endian little
enum CompressionType : u8 {
None = 0,
Lzma = 1,
LzmaAes = 2,
};
enum IntegrityCheckType : u8 {
Crc32 = 0,
Sha256 = 1,
Sha256Rsa = 2,
};
enum TlvType : u16 {
BasicInfo = 0x11,
MoverInfo = 0x12,
VersionInfo = 0x13,
IntegrityVerifyInfo = 0x14,
DeviceNameInfo = 0x20,
DeviceTypeInfo = 0x21,
IsNvdmIncompatibleFlag = 0xF0,
};
fn tlv_type_name(TlvType value) {
match (value) {
(TlvType::BasicInfo): return "BASIC_INFO";
(TlvType::MoverInfo): return "MOVER_INFO";
(TlvType::VersionInfo): return "VERSION_INFO";
(TlvType::IntegrityVerifyInfo): return "INTEGRITY_VERIFY_INFO";
(TlvType::DeviceNameInfo): return "DEVICE_NAME_INFO";
(TlvType::DeviceTypeInfo): return "DEVICE_TYPE_INFO";
(TlvType::IsNvdmIncompatibleFlag): return "IS_NVDM_INCOMPATIBLE_FLAG";
(_): return "UNKNOWN";
}
};
struct Sha256Checksum {
u8 bytes[32];
};
struct Section {
u32 source_offset [[comment("Offset within the encrypted package")]];
u32 decompressed_size;
u32 dest_offset [[comment("Destination offset in flash")]];
};
struct BasicInfo {
CompressionType compression_type;
IntegrityCheckType integrity_check_type;
u32 firmware_offset;
u32 firmware_size;
};
struct BasicInfoTlv {
TlvType type [[format("tlv_type_name")]];
u16 length;
BasicInfo value [[inline]];
};
struct VersionInfo {
char version_string[parent.length];
};
struct MoverInfo {
u32 number_of_sections;
Section sections_table[number_of_sections] [[inline]];
};
struct IntegrityVerifyInfo {
u32 number_of_checksums;
Sha256Checksum checksums[number_of_checksums] [[name("SHA256 Checksums")]];
};
struct DeviceNameInfo {
char device_name[parent.length];
};
struct DeviceTypeInfo {
char device_type[parent.length];
};
struct IsNvdmIncompatibleFlag {
u8 is_nvdm_incompatible;
if (parent.length > sizeof(is_nvdm_incompatible)) {
u8 reserved[parent.length - sizeof(is_nvdm_incompatible)];
}
};
struct UnknownTlvValue {
u8 value[parent.length];
};
struct TlvOrTerminator {
TlvType type [[format("tlv_type_name")]];
if (type == 0xFFFF) {
break;
} else {
u16 length;
match (type) {
(TlvType::BasicInfo): BasicInfo value [[inline]];
(TlvType::VersionInfo): VersionInfo value [[inline]];
(TlvType::MoverInfo): MoverInfo value [[inline]];
(TlvType::IntegrityVerifyInfo): IntegrityVerifyInfo value [[inline]];
(TlvType::DeviceNameInfo): DeviceNameInfo value [[inline]];
(TlvType::DeviceTypeInfo): DeviceTypeInfo value [[inline]];
(TlvType::IsNvdmIncompatibleFlag): IsNvdmIncompatibleFlag value [[inline]];
(_): UnknownTlvValue value [[inline]];
}
}
};
struct AirohaFirmware {
Sha256Checksum file_checksum [[comment("SHA-256 over bytes from 0x100 to EOF")]];
u8 padding1[224];
BasicInfoTlv basic_info [[name("BASIC_INFO")]];
TlvOrTerminator tlvs[while(true)] [[name("TLVs")]];
if ($ < basic_info.value.firmware_offset) {
padding[basic_info.value.firmware_offset - $];
}
u8 firmware[basic_info.value.firmware_size] [[name("Encrypted/Compressed Firmware Body")]];
};
AirohaFirmware firmware @ 0x00; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Coming from #44. The AES/IV pair for the offical firmware can be found via burte-forcing LZMA headers with a flash dump.
https://github.com/ramikg/airoha-firmware-parser can be used to operate on the files directly should a KEY/IV pair be found. The POC script here prove to be sufficent to locate the keys should a flash dump and a firmware file be provided. (coded by GPT5.5, referencing https://github.com/HelgeSverre/sony-vp-extract)
Here's an non-exhaustive list of all AES Key/IV pairs Airoha devices used:
--reverse-key-and-ivflag. E.g.Beta Was this translation helpful? Give feedback.
All reactions