apk

    Read-only APK (ZIP) container parser: entry index and raw bytes, v1/v2/v3/v3.1 signature verification, resources.arsc and ELF recon, for Android package tooling.

    apk
    android
    zip
    signature
    verity
    Download zip
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    42 minutes ago
    Downloads
    1

    #hnlyxiaobing/apk

    把 APK(ZIP 容器)读成可信的条目索引与原始字节,供上层清单与代码解析消费。

    本包是独立发布单元。完整说明(能力边界、公开 API、依赖、验证、风险与未决)见本仓库 README.md;公开签名以 pkg.generated.mbti 为准。

    许可:Apache-2.0。

    EntryName

    type EntryName = String

    条目名(ZIP 内以 / 分隔的相对路径)。

    ContainerIndex

    pub trait ContainerIndex {
    fn entry(Self, String) -> Bytes raise ApkError
    fn entries(Self) -> Array[ZipEntryRef]
    }

    容器只读索引契约;实现方必须保证 entry 不做任何解压以外的语义解释。

    ApkError

    pub suberror ApkError {
    UnexpectedEof(Int)
    NotAZip(String)
    BadCentralDirectory(Int, String)
    Zip64Unsupported(String)
    EntryNotFound(String)
    BadSigningBlock(Int, String)
    UnsupportedSignatureScheme(String)
    BadAlignment(String, Int)
    BadResourceTable(Int, String)
    BadElf(Int, String)
    } derive(
    Debug
    )

    APK 错误模型。

    ApkError::to_repr

    Abi

    pub(all) enum Abi {
    ArmeabiV7a
    Arm64V8a
    X86
    X86_64
    Unknown(String)
    }

    Android ABI 分类。

    Apk

    pub(all) struct Apk {
    source : Bytes
    entries : Array[ZipEntryRef]
    signing_block_off : UInt64?
    }

    APK 容器视图。持有原始 Bytes 与索引;纯值,无外部句柄、无需释放。

    Apk::certificate_infos

    fn Apk::certificate_infos(self : Apk) -> Array[CertificateInfo] raise ApkError

    聚合 APK 中全部证书 DER(v1 PKCS#7 + v2/v3/v3.1 signer)并按 DER 字节去重。

    Apk::dex_files

    fn Apk::dex_files(self : Apk) -> Array[DexEntry] raise ApkError

    返回 classes*.dex 列表(按名字典序排序,只给字节,不解析 DEX)。

    Apk::entries

    fn Apk::entries(self : Apk) -> Array[ZipEntryRef]

    返回全部 ZIP 条目索引(中央目录顺序)。

    Apk::entry

    fn Apk::entry(self : Apk, name : String) -> Bytes raise ApkError

    按条目名返回解压后的原始字节;未命中返回 EntryNotFound。

    Apk::entry_capped

    fn Apk::entry_capped(self : Apk, name : String, limit : Int64) -> Bytes? raise ApkError

    限额提取(W2 解压炸弹内存防线):输出超过 limit 时返回 None(fail-closed,不产出部分数据)。

    与 Apk::entry 的区别仅在内存上界:在调用一次性 inflate 之前就按「声明尺寸」与 「DEFLATE 理论最大膨胀比 1032:1」双预检建立 sound 上界,使伪造声明尺寸的恶意条目 无法先耗尽内存再被拒(闭合 B8)。解析错误(条目不存在、坏 CRC、尺寸不符、非法 deflate 流等)仍 raise 既有 ApkError;limit <= 0 视为用法错误,按既有变体 BadCentralDirectory(0, "invalid limit") 报告。

    Apk::integrity_checks

    fn Apk::integrity_checks(self : Apk) -> Array[IntegrityCheck]

    批量完整性巡检:遍历全部条目,逐条目解压并核对尺寸与 CRC-32,返回不中断的值化结论, 供 CI 合规初筛一次拿到全容器完整性。对齐 SignatureCheck 的既有值化风格。

    • 条目级失败(坏 CRC、尺寸不符、不可解压等)值化为 ok == false + error, 不中断其余条目、不新增错误变体(复用既有 extract_data 的 ApkError);
    • 目录条目(名以 / 结尾)跳过(不计入返回数组)。

    关于 raise:本函数不声明 raise。中央目录索引在 Apk::open 时已完成结构校验, 此后的逐条目解压失败均可值化为 ok == false,不存在独立于条目的「容器级失败」路径; 声明一个永不触发的 raise 类型会被 moon check --deny-warn 判为 unused-error-type 警告, 故按实现实情省略(dev-plan W1 草案的 raise ApkError 在此落地为「不 raise」)。

    内存口径:逐条目解压、即查即弃,不聚合全部字节;返回数组只持有标量结论, 不持有解压内容。

    Apk::manifest

    fn Apk::manifest(self : Apk) -> ManifestRef raise ApkError

    返回 AndroidManifest.xml 的原始 AXML 字节(供 axml::parse 消费)。

    Apk::native_libs

    fn Apk::native_libs(self : Apk, abi : Abi?) -> Array[NativeLib] raise ApkError

    返回指定 ABI 的 lib/<abi>/*.so 列表;abi = None 返回全部并各自标注 ABI。

    ABI 归类只依据 lib/<abi>/ 目录名(与 aapt2 native-code 口径一致),不解析 ELF 内容;内容侧交叉校验用 NativeLib::elf_abi()。

    Apk::open

    fn Apk::open(source : Bytes) -> Apk raise ApkError

    打开一个 APK 字节流并构建中央目录索引。

    • 参数:source 为完整 APK 字节;所有权由调用方保留,Apk 只做只读引用。
    • 返回:Apk 纯值索引;不解压业务条目(惰性,见 Apk::entry)。
    • 错误:EOCD / 中央目录 / ZIP64 / 签名块 / 结构截断均以 ApkError 传播(带偏移)。
    • 线程:无可变全局状态,索引只读,可并发查询。
    • 非目标:不反编译、不签名、不打包、不修改 ZIP、不做证书链验证。
    • 实现要点:定位 EOCD(拒绝 ZIP64 标记与 ZIP64 locator)、解析中央目录、 校验每个 local file header 并计算数据区 4 字节对齐标志、定位 APK Signing Block。

    Apk::resource_table

    fn Apk::resource_table(self : Apk) -> ResourceTableRef? raise ApkError

    返回 resources.arsc 引用(仅全局字符串池);无该条目返回 None。

    这是轻量索引路径(只切出全局字符串池 chunk,不展开包/类型)。完整展开用 Apk::resource_table_full()。

    Apk::resource_table_full

    fn Apk::resource_table_full(self : Apk) -> ResTable? raise ApkError

    返回 resources.arsc 的完整展开结果(全局字符串池 + package/typeSpec/ type 条目/复杂 bag);无该条目返回 None。

    解析规则见 arsc.mbt 顶部文档;畸形结构报 BadResourceTable / UnexpectedEof(带 arsc 内绝对偏移),不 panic。

    Apk::signature_checks

    fn Apk::signature_checks(self : Apk) -> Array[SignatureCheck] raise ApkError

    返回每个已识别签名方案的结构 + 摘要校验结论。

    与 Apk::signatures() 使用同一套结构解析;SignatureCheck.signature_verified 恒为 false(未做公钥验签),digest_ok 只代表摘要一致。

    Apk::signatures

    fn Apk::signatures(self : Apk) -> Array[SignatureInfo] raise ApkError

    返回已识别的签名方案摘要。

    • v1:META-INF/*.RSA|*.DSA|*.EC 存在即识别;证书从 PKCS#7 提取(解析失败时为空), block_id 为 0。verified 需 MANIFEST 条目摘要与 .SF 清单摘要全部一致。
    • v2/v3/v3.1:解析 APK Signing Block 的 ID-value 对(0x7109871a / 0xf05368c0 / 0x1b93ad61),从 signer 结构按长度前缀提取 DER 证书与摘要记录;verified 需 APK 内容分块摘要(SHA-256)与签名块中的摘要一致。
    • 未知 ID-value 对(如 verity padding)跳过;块内没有任何受支持方案时报 UnsupportedSignatureScheme;块结构异常报 BadSigningBlock。

    边界:verified = 结构 + 摘要校验通过,≠ 签名有效(无 RSA/ECDSA 验签)。 逐项结论见 Apk::signature_checks()。

    Apk::verify_signatures

    fn Apk::verify_signatures(self : Apk) -> Array[SignatureVerification] raise ApkError

    对每个已识别签名方案做签名值验签,返回新类型 SignatureVerification 列表。

    顺序与 signature_checks() 一致(v1 优先,v2/v3/v3.1 按块内顺序、按方案排序)。 不抛错即表示结构可解析;单个方案验签失败记录在该方案 crypto_verified=false 中, 不中断整体遍历。

    Apk::verity

    fn Apk::verity(self : Apk) -> VerityInfo? raise ApkError

    读取 verity 签名块(ID 0x42726577)的结构信息;无该块返回 None。

    遍历 APK Signing Block 的 ID-value 对,找到 verity 块后尽力解析声明字段; 所有解析失败以缺省值表示(不 raise、不 panic),由调用方决定如何使用。 树重算恒不执行,tree_recomputed_ok 恒为 false。

    Apk::verity_tree_check

    fn Apk::verity_tree_check(self : Apk) -> VerityTreeCheck? raise ApkError

    对字节流做 fs-verity 根重算并与 v2/v3/v3.1 声明的 verity 摘要根比对。

    • 收集 v2/v3/v3.1 signer 的 digests,找到 algorithm 为 0x0421/0x0423/0x0425 且值 40 字节的 摘要(提取声明根与 source_len);无则返回 None。
    • 有声明时构造 fs-verity 源并重算根,比对一致 tree_recomputed_ok=true。
    • 解析失败一律值化(tree_recomputed_ok=false、字段缺省),不 panic、不新增错误变体。

    CertificateInfo

    pub(all) struct CertificateInfo {
    version : Int
    serial_hex : String
    issuer : String
    subject : String
    not_before : String
    not_after : String
    signature_algo_oid : String
    public_key_algo_oid : String
    public_key_bits : Int
    sha256_fingerprint_hex : String
    }

    单个 X.509 证书的结构事实(不含信任结论)。

    DartSnapshotRef

    pub(all) struct DartSnapshotRef {
    marker : String
    offset : UInt64
    in_section : String
    }

    Dart 快照引用的符号定位(W8 — 仅识别,不做快照语义)。

    把 dart_markers 的「字节模式命中」升级为「marker 符号在动态符号表中的偏移与节名」, 为外部 Dart 快照解析器提供字节偏移。绝不进入快照语义(对象图 / 指令表 / 版本语义 一律不做,与 elf.mbt 既有上限一致)。

    只匹配既有 4 个 _kDart* 预设 marker 名(elf_dart_marker_names 前 4 项); 未定义符号(st_shndx == 0)跳过;无节头表(被 strip)时 in_section 为空串。

    DexEntry

    pub(all) struct DexEntry {
    name : String
    bytes : Bytes
    }

    DEX 条目:只给名字与原始字节,不调用 dex 库。

    EcCurve

    pub(all) enum EcCurve {
    P256
    P384
    Unknown
    }

    支持的椭圆曲线(纯加法公开枚举)。

    ElfClass

    pub(all) enum ElfClass {
    Elf32
    Elf64
    }

    ELF 位宽(EI_CLASS:1 → Elf32,2 → Elf64)。

    ElfInfo

    pub(all) struct ElfInfo {
    elf_class : ElfClass
    machine : Int
    needed : Array[String]
    dynamic_symbols : Array[ElfSymbol]
    jni_exports : Array[String]
    dart_markers : Array[String]
    }

    NativeLib::elf_info() 的只读结构化结果(全部是 apk 自有值类型与 String)。
    • jni_exports:dynamic_symbols 中 defined == true 且名字以 Java_ 开头者, 按 dynsym 顺序;
    • dart_markers:命中的预设 marker 名,去重、按预设顺序(字节模式命中,非快照解析)。

    ElfSymbol

    pub(all) struct ElfSymbol {
    name : String
    defined : Bool
    }

    动态符号表中的一条符号。name 来自 DT_STRTAB; defined = st_shndx != SHN_UNDEF(0)(未定义即导入符号)。

    IntegrityCheck

    pub(all) struct IntegrityCheck {
    name : String
    declared_size : UInt64
    actual_size : UInt64?
    crc32_expected : UInt
    crc32_actual : UInt?
    ok : Bool
    aligned : Bool
    error : String
    }

    单条目完整性巡检结论(W1 批量完整性报告的值化出口)。

    语义:ok == true 当且仅当「解压成功 且 尺寸一致 且 CRC-32 一致」; 与 Apk::entry 的 raise 行为逐条目一致——ok == false 的条目,其 entry(name) 必然 raise 对应的 ApkError,反之亦然。

    ManifestRef

    pub(all) struct ManifestRef {
    entry_name : String
    raw : Bytes
    }

    Manifest 引用:只给二进制 AXML 原始字节,由调用方交给 axml::parse。

    NativeLib

    pub(all) struct NativeLib {
    abi : Abi
    path : String
    bytes : Bytes
    }

    native 库条目:按 ABI 归类后的路径与原始字节。

    NativeLib::dart_snapshot_refs

    fn NativeLib::dart_snapshot_refs(self : NativeLib) -> Array[DartSnapshotRef] raise ApkError

    返回 Dart 快照引用的符号定位数组;无命中返回空。

    只解析 _kDart* 开头的 4 个预设 marker;marker 命中但为未定义符号(st_shndx==0)时 跳过不产出;按 marker 预设顺序输出(不对应 dynsym 顺序)。

    NativeLib::elf_abi

    fn NativeLib::elf_abi(self : NativeLib) -> Abi raise ApkError

    从 ELF 头读取内容侧 ABI(交叉校验用,不替代 NativeLib.abi 的目录归类)。

    只读 ELF 头:magic \x7fELF、EI_CLASS(1=32/2=64)、EI_DATA(必须 1=小端)、 e_machine(18..19 小端)。返回:
    • EM_ARM(40) → ArmeabiV7a;EM_AARCH64(183) → Arm64V8a;
    • EM_386(3) → X86;EM_X86_64(62) → X86_64;
    • EM_RISCV(243) / EM_MIPS(8) / 其他 → Unknown(...)(保留机器类型)。

    非法 ELF(magic/class/data 异常、头截断)报 BadElf(offset, detail),不 panic。 典型用途:发现「目录写 x86_64、内容其实是 arm64」的错标 APK。

    NativeLib::elf_info

    fn NativeLib::elf_info(self : NativeLib) -> ElfInfo raise ApkError

    ELF 只读结构化侦察:解析 ELF 头 / program headers / PT_DYNAMIC, 产出依赖库名、动态符号表、JNI 导出名与 Dart AOT 字节 marker。 全部入参只读(self.bytes),无状态、可并发;越界 / 截断 / 坏结构一律 ApkError::BadElf(offset, reason),不 panic、不返回部分结果的静默成功。

    NativeLib::jni_exports

    fn NativeLib::jni_exports(self : NativeLib) -> Array[String] raise ApkError

    便利函数:JNI 导出名。内部委托 elf_info(),不重复解析逻辑。

    NativeLib::needed_libraries

    fn NativeLib::needed_libraries(self : NativeLib) -> Array[String] raise ApkError

    便利函数:DT_NEEDED 依赖库名。内部委托 elf_info(),不重复解析逻辑。

    ResBag

    pub(all) struct ResBag {
    parent : UInt
    maps : Array[ResMap]
    }

    复杂条目(bag):父资源 id + 映射数组(AOSP ResTable_map_entry)。

    ResConfig

    pub(all) struct ResConfig {
    size : Int
    mcc : Int
    mnc : Int
    language : String
    country : String
    orientation : Int
    touchscreen : Int
    density : Int
    keyboard : Int
    navigation : Int
    input_flags : Int
    screen_width : Int
    screen_height : Int
    sdk_version : Int
    screen_layout : Int
    ui_mode : Int
    smallest_screen_width_dp : Int
    screen_width_dp : Int
    screen_height_dp : Int
    locale_script : String
    color_mode : Int
    raw : Bytes
    }

    一个资源配置(AOSP ResTable_config);未覆盖字段完整保留在 raw。

    ResConfig::is_default

    fn ResConfig::is_default(self : ResConfig) -> Bool

    该配置是否为默认配置(全部 qualifier 字段为 0 / 空)。

    ResDataType

    pub(all) enum ResDataType {
    Null
    Reference
    Attribute
    String
    Float
    Dimension
    Fraction
    DynamicReference
    DynamicAttribute
    IntDec
    IntHex
    IntBoolean
    IntColorArgb8
    IntColorRgb8
    IntColorArgb4
    IntColorRgb4
    Unknown(Int)
    }

    Res_value.dataType(AOSP Res_value::TYPE_* 全集);未知值保留原始字节。

    ResEntry

    pub(all) struct ResEntry {
    key : Int
    key_name : String
    flags : Int
    value : ResEntryValue
    }

    单个资源条目(AOSP ResTable_entry)。 flags 保留 FLAG_COMPLEX(0x0001)/FLAG_PUBLIC(0x0002)/FLAG_WEAK(0x0004)/FLAG_COMPACT(0x0008)。

    ResEntryValue

    pub(all) enum ResEntryValue {
    Simple(ResValue)
    Complex(ResBag)
    }

    条目取值:简单值(含 compact 编码)或复杂 bag。

    ResLookup

    pub(all) struct ResLookup {
    package_name : String
    type_name : String
    entry_name : String
    type_id : Int
    entry_id : Int
    config : ResConfig
    entry : ResEntry
    }

    资源 id 查询命中:包/类型/条目名 + 最优配置与该配置下的条目。

    ResMap

    pub(all) struct ResMap {
    name : UInt
    value : ResValue
    }

    bag 内的一对 name/value(AOSP ResTable_map)。

    ResPackage

    pub(all) struct ResPackage {
    id : Int
    name : String
    type_id_offset : Int
    type_strings : Array[String]
    key_strings : Array[String]
    types : Array[ResTypeSpec]
    }

    一个资源包(AOSP ResTable_package)。

    ResTable

    pub(all) struct ResTable {
    global_strings : Array[String]
    packages : Array[ResPackage]
    package_count : Int
    }

    resources.arsc 完整解析结果:全局值字符串池 + 包数组。

    ResTable::find_id

    fn ResTable::find_id(self : ResTable, type_name : String, entry_name : String) -> UInt?

    按名字查资源 id:(类型名, 条目名) → id;未命中返回 None。

    ResTable::lookup

    fn ResTable::lookup(self : ResTable, id : UInt) -> ResLookup?

    资源 id(0xPPTTNNNN)→ (包, 类型, 条目, 最优值) 查询。

    选择策略:默认配置优先(同一资源存在多个配置变体时返回 qualifier 全零的配置); 无默认配置时返回 chunk 顺序中的第一个命中。未命中返回 None。

    ResTable::lookup_all

    fn ResTable::lookup_all(self : ResTable, id : UInt) -> Array[ResLookup]

    资源 id 的全部配置命中(按 chunk 顺序)。

    ResTable::package_by_id

    fn ResTable::package_by_id(self : ResTable, id : Int) -> ResPackage?

    按包 id 查找包。

    ResTypeConfig

    pub(all) struct ResTypeConfig {
    id : Int
    flags : Int
    config : ResConfig
    entries : Array[ResEntry?]
    }

    一个(类型, 配置)资源组(AOSP ResTable_type)。 entries 下标即 entry index,None 表示该配置下此条目不存在(NO_ENTRY)。

    ResTypeSpec

    pub(all) struct ResTypeSpec {
    id : Int
    types_count : Int
    entry_count : Int
    spec_flags : Array[UInt]
    configs : Array[ResTypeConfig]
    }

    一个资源类型(RES_TABLE_TYPE_SPEC_TYPE + 其全部配置变体)。

    ResValue

    pub(all) struct ResValue {
    data_type : ResDataType
    data : UInt
    }

    单个 Res_value(32 位数据 + 类型)。

    ResourceTableRef

    pub(all) struct ResourceTableRef {
    entry_name : String
    raw : Bytes
    global_string_pool : Bytes
    }

    resources.arsc 轻量索引:只读全局字符串池,不展开包/类型/配置项。 global_string_pool 为 arsc 中全局字符串池 chunk 的完整原始字节(含 chunk 头)。 完整展开用 Apk::resource_table_full()(返回 apk 自有的 ResTable 值类型)。

    SignatureCheck

    pub(all) struct SignatureCheck {
    scheme : SignatureScheme
    structure_ok : Bool
    digest_ok : Bool
    digest_algorithm : String
    entries_checked : Int
    entries_failed : Int
    signature_verified : Bool
    detail : String
    }

    签名校验结论(结构 + 摘要,不含公钥验签)。

    SignatureInfo

    pub(all) struct SignatureInfo {
    scheme : SignatureScheme
    block_id : UInt
    certificates : Array[Bytes]
    verified : Bool
    }

    签名块摘要。certificates 保存 DER 原始字节,不做证书链校验。 v2/v3/v3.1 的证书从签名块 signer 结构中按长度前缀定位提取; v1(JAR 签名)的证书从 META-INF/*.RSA|*.DSA|*.EC 的 PKCS#7 封装中提取。

    verified 语义(重要):为 true 当且仅当「签名结构解析通过 且 本地可验证的 摘要全部一致」——v1 为 MANIFEST 条目摘要 + .SF 对 MANIFEST 的摘要;v2/v3/v3.1 为 APK 内容分块摘要(SHA-256)。它不表示签名有效:本库没有 RSA/ECDSA 公钥验签能力, 不校验证书链,也不做签名值验证。需要逐项判定时用 Apk::signature_checks(), 其中 signature_verified 恒为 false。

    SignatureScheme

    pub(all) enum SignatureScheme {
    V1
    V2
    V3
    V31
    }

    APK 签名方案(v1 = JAR 签名;v2/v3/v3.1 = APK Signing Block)。

    SignatureVerification

    pub(all) struct SignatureVerification {
    scheme : SignatureScheme
    structure_ok : Bool
    digest_ok : Bool
    crypto_verified : Bool
    algo : String
    detail : String
    }

    单个签名方案的验签结论(新类型,纯加法 API;旧类型语义不变)。

    VerityInfo

    pub(all) struct VerityInfo {
    block_id : UInt
    version : Int
    hash_algorithm : String
    block_size : Int
    salt_hex : String
    root_hash_hex : String
    tree_size : UInt64
    tree_recomputed_ok : Bool
    } derive(
    Debug
    )

    VerityTreeCheck

    pub(all) struct VerityTreeCheck {
    block_id : UInt
    hash_algorithm : String
    block_size : Int
    salt_hex : String
    declared_root_hash_hex : String
    recomputed_root_hash_hex : String
    tree_recomputed_ok : Bool
    source_len : UInt64
    }

    fs-verity Merkle 根重算结论(与 v2/v3/v3.1 声明摘要比对)。

    block_id 恒为 0x42726577(标识这是 verity 能力,尽管该块本身不承载 root hash)。 tree_recomputed_ok 为 true 仅当「声明了 verity 摘要」且「重算根 == 声明根」;否则 false (fail-closed)。verity_tree_check() 返回 None 表示该 APK 的 v2/v3/v3.1 中无 verity 摘要。

    ZipEntryRef

    pub(all) struct ZipEntryRef {
    name : String
    compressed_size : UInt64
    uncompressed_size : UInt64
    crc32 : UInt
    compression_method : Int
    local_header_off : UInt64
    is_aligned : Bool
    }

    ZIP 中央目录条目的最小索引。偏移为条目结构在原 Bytes 内的位置。 local_header_off 为 local file header 偏移;数据区偏移 = local_header_off + 30 + local 文件名长 + local 扩展域长。is_aligned 表示数据区偏移是否 4 字节对齐(zipalign 约定)。

    ecdsa_verify_raw

    fn ecdsa_verify_raw(curve : EcCurve, pubkey_x_hex : String, pubkey_y_hex : String, msg_hash_hex : String, sig_r_hex : String, sig_s_hex : String) -> Bool

    ECDSA 验签公开入口(纯加法 API,里程碑 a 的门禁承载点)。

    各参数为无前缀十六进制字符串。任一畸形/越界输入均值化返回 false(fail-closed, 不 panic)。不接入 v2/v3/v3.1 与 v1(里程碑 b/c 留空)。

    Example

    test {
    // P-256 / SHA-256("sample"),RFC 6979 A.2.5 标准向量(真签名验签通过)。
    assert_true(
    ecdsa_verify_raw(
    EcCurve::P256,
    "60fed4ba255a9d31c961eb74c6356d68c049b8923b61fa6ce669622e60f29fb6",
    "7903fe1008b8bc99a41ae9e95628bc64f2f1b20c2d7e9f5177a3c294d4462299",
    "af2bdbe1aa9b6ec1e2ade1d694f41fc71a831d0268e9891562113d8a62add1bf",
    "efd48b2aacb6a8fd1140dd9cd45e81d69d2c877b56aaf991c34d0ea84eaf3716",
    "f7cb1c942d657c41d436c7a1b6e29f65f3e900dbb9aff4064dc4ab2f843acda8",
    ),
    )
    }

    parse_certificate

    fn parse_certificate(der : Bytes) -> CertificateInfo raise ApkError

    解析单个 X.509 证书 DER 字节;结构非法 raise BadSigningBlock。

    parse_resources_arsc

    fn parse_resources_arsc(data : Bytes) -> ResTable raise ApkError

    解析一段完整 resources.arsc 字节流(含 RES_TABLE_TYPE 头,不含 ZIP 封装)。

    • 参数:data 只读,调用方持有;不转移、不缓存。
    • 返回:ResTable 纯值;无句柄、可跨线程共享。
    • 错误:UnexpectedEof(offset) / BadResourceTable(offset, detail),均为绝对字节偏移。
    • 降级:未知 chunk 跳过;未知 ResDataType 保留在 Unknown;字符串池下标越界在 key_name 中以占位文本呈现(与 axml 语义对齐),结构越界仍报错。