# tomking062/unisoc_chipram_signcheck_exploit architecture

> Architecture diagram of the GitHub repository tomking062/unisoc_chipram_signcheck_exploit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tomking062/unisoc_chipram_signcheck_exploit
- Repository: https://github.com/tomking062/unisoc_chipram_signcheck_exploit

## Overview

This repository provides three firmware-patching workflows for Unisoc secure-boot images: post-verification patch-framework generation, pre-verification image recombination, and POSTROM/chipram image modification. In the first workflow, magic32 or magic64 prepares an image, then difftool can encode differences into its patch data. The other two workflows are separate command-line tools. POSTROM patching also recalculates SHA-256 hashes and updates image metadata. The POSTROM implementation and format definitions are excerpted; the README documents the broader method capabilities. Edges reflect those excerpts or README statements, not an assumed end-to-end device flashing process.

Main entry points: [`Patch-Pre-Verification_postrom/patcher.c`](https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Pre-Verification_postrom/patcher.c) (POSTROM image patcher), [`Patch-Post-Verification/diff_tool/difftool.c`](https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Post-Verification/diff_tool/difftool.c) (Patch data generator), [`Patch-Post-Verification/magic32.cpp`](https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Post-Verification/magic32.cpp) (magic32 processor), [`Patch-Post-Verification/magic64.cpp`](https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Post-Verification/magic64.cpp) (magic64 processor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_post["Post-verification patching"]
  node_magic32["magic32 processor<br/>[magic32.cpp]"]
  node_magic64["magic64 processor<br/>[magic64.cpp]"]
  node_framework["Runtime patch framework<br/>[magic32.cpp]"]
  node_diff["Patch data generator<br/>[difftool.c]"]
end

subgraph group_pre["Pre-verification patching"]
  node_pre_sml["SML patcher<br/>[bsp_sign_fxxker.c]"]
  node_pre_uboot["UBOOT patcher"]
end

subgraph group_postrom["POSTROM patching"]
  node_postrom_tool["POSTROM image patcher<br/>[patcher.c]"]
end

subgraph group_hash["Hash and formats"]
  node_format["Secure image formats<br/>[sprdsec_header.h]"]
  node_sha_api["SHA-256 API<br/>[sha256.h]"]
  node_hash_types["Hash context types<br/>[hash-internal.h]"]
  node_sha_impl["SHA-256 implementation<br/>[patcher.c]"]
end

node_operator(("Firmware engineer"))
node_firmware["Firmware inputs"]
node_readyimage["Patched image"]
node_preimage["Pre-patched image"]
node_postrom_image["Modified merged image"]

node_operator -->|"provides"| node_firmware
node_firmware -->|"processes ARM32"| node_magic32
node_firmware -->|"processes ARM64"| node_magic64
node_magic32 -->|"embeds framework"| node_framework
node_magic64 -->|"embeds framework"| node_framework
node_framework -->|"applies patches"| node_readyimage
node_operator -->|"runs tool"| node_diff
node_firmware -->|"provides modified input"| node_diff
node_magic32 -->|"prepares original"| node_diff
node_magic64 -->|"prepares original"| node_diff
node_diff -->|"writes patch data"| node_readyimage
node_operator -->|"runs tool"| node_pre_sml
node_operator -->|"runs tool"| node_pre_uboot
node_firmware -->|"supplies image pair"| node_pre_sml
node_firmware -->|"supplies image pair"| node_pre_uboot
node_pre_sml -->|"writes recombined image"| node_preimage
node_pre_uboot -->|"writes recombined image"| node_preimage
node_operator -->|"runs tool"| node_postrom_tool
node_firmware -->|"provides merged input"| node_postrom_tool
node_postrom_tool -->|"updates image"| node_postrom_image
node_postrom_tool -->|"reads metadata"| node_format
node_postrom_tool -->|"calculates hashes"| node_sha_impl
node_sha_impl -->|"implements API"| node_sha_api
node_sha_api -->|"uses context type"| node_hash_types

click node_magic32 "https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Post-Verification/magic32.cpp"
click node_magic64 "https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Post-Verification/magic64.cpp"
click node_framework "https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Post-Verification/magic32.cpp"
click node_diff "https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Post-Verification/diff_tool/difftool.c"
click node_pre_sml "https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Pre-Verification/bsp_sign_fxxker.c"
click node_pre_uboot "https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Pre-Verification/bsp_sign_fxxker_for_uboot.c"
click node_postrom_tool "https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Pre-Verification_postrom/patcher.c"
click node_format "https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Pre-Verification_postrom/sprdsec_header.h"
click node_sha_api "https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Pre-Verification_postrom/mincrypt/sha256.h"
click node_hash_types "https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Pre-Verification_postrom/mincrypt/hash-internal.h"
click node_sha_impl "https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Pre-Verification_postrom/patcher.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_magic32,node_magic64,node_framework,node_diff toneBlue
class node_pre_sml,node_pre_uboot toneAmber
class node_postrom_tool toneMint
class node_format,node_sha_api,node_hash_types,node_sha_impl toneRose
class node_operator,node_firmware,node_readyimage,node_preimage,node_postrom_image toneIndigo
```

## Components

### Post-verification patching

- [magic32 processor](https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Post-Verification/magic32.cpp): `Patch-Post-Verification/magic32.cpp`
- [magic64 processor](https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Post-Verification/magic64.cpp): `Patch-Post-Verification/magic64.cpp`
- [Runtime patch framework](https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Post-Verification/magic32.cpp): `Patch-Post-Verification/magic32.cpp`
- [Patch data generator](https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Post-Verification/diff_tool/difftool.c): `Patch-Post-Verification/diff_tool/difftool.c`

### Pre-verification patching

- [SML patcher](https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Pre-Verification/bsp_sign_fxxker.c): `Patch-Pre-Verification/bsp_sign_fxxker.c`
- [UBOOT patcher](https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Pre-Verification/bsp_sign_fxxker_for_uboot.c): `Patch-Pre-Verification/bsp_sign_fxxker_for_uboot.c`

### POSTROM patching

- [POSTROM image patcher](https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Pre-Verification_postrom/patcher.c): `Patch-Pre-Verification_postrom/patcher.c`

### Hash and formats

- [Secure image formats](https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Pre-Verification_postrom/sprdsec_header.h): `Patch-Pre-Verification_postrom/sprdsec_header.h`
- [SHA-256 API](https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Pre-Verification_postrom/mincrypt/sha256.h): `Patch-Pre-Verification_postrom/mincrypt/sha256.h`
- [Hash context types](https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Pre-Verification_postrom/mincrypt/hash-internal.h): `Patch-Pre-Verification_postrom/mincrypt/hash-internal.h`
- [SHA-256 implementation](https://github.com/tomking062/unisoc_chipram_signcheck_exploit/blob/main/Patch-Pre-Verification_postrom/patcher.c): `Patch-Pre-Verification_postrom/patcher.c`

### Other components

- **Firmware engineer**
- **Firmware inputs**
- **Patched image**
- **Pre-patched image**
- **Modified merged image**

## Connections

- Firmware engineer → Firmware inputs: provides (evidence: `readme.md`)
- Firmware inputs → magic32 processor: processes ARM32 (evidence: `readme.md`)
- Firmware inputs → magic64 processor: processes ARM64 (evidence: `readme.md`)
- magic32 processor → Runtime patch framework: embeds framework (evidence: `readme.md`)
- magic64 processor → Runtime patch framework: embeds framework (evidence: `readme.md`)
- Runtime patch framework → Patched image: applies patches (evidence: `readme.md`)
- Firmware engineer → Patch data generator: runs tool (evidence: `readme.md`)
- Firmware inputs → Patch data generator: provides modified input (evidence: `Patch-Post-Verification/diff_tool/difftool.c`)
- magic32 processor → Patch data generator: prepares original (evidence: `readme.md`)
- magic64 processor → Patch data generator: prepares original (evidence: `readme.md`)
- Patch data generator → Patched image: writes patch data (evidence: `Patch-Post-Verification/diff_tool/difftool.c`)
- Firmware engineer → SML patcher: runs tool (evidence: `readme.md`)
- Firmware engineer → UBOOT patcher: runs tool (evidence: `readme.md`)
- Firmware inputs → SML patcher: supplies image pair (evidence: `Patch-Pre-Verification/bsp_sign_fxxker.c`)
- Firmware inputs → UBOOT patcher: supplies image pair (evidence: `Patch-Pre-Verification/bsp_sign_fxxker_for_uboot.c`)
- SML patcher → Pre-patched image: writes recombined image (evidence: `Patch-Pre-Verification/bsp_sign_fxxker.c`)
- UBOOT patcher → Pre-patched image: writes recombined image (evidence: `Patch-Pre-Verification/bsp_sign_fxxker_for_uboot.c`)
- Firmware engineer → POSTROM image patcher: runs tool (evidence: `Patch-Pre-Verification_postrom/patcher.c`)
- Firmware inputs → POSTROM image patcher: provides merged input (evidence: `Patch-Pre-Verification_postrom/patcher.c`)
- POSTROM image patcher → Modified merged image: updates image (evidence: `Patch-Pre-Verification_postrom/patcher.c`)
- POSTROM image patcher → Secure image formats: reads metadata (evidence: `Patch-Pre-Verification_postrom/patcher.c`)
- POSTROM image patcher → SHA-256 implementation: calculates hashes (evidence: `Patch-Pre-Verification_postrom/patcher.c`)
- SHA-256 implementation → SHA-256 API: implements API (evidence: `Patch-Pre-Verification_postrom/patcher.c`)
- SHA-256 API → Hash context types: uses context type (evidence: `Patch-Pre-Verification_postrom/mincrypt/sha256.h`)
