# libimobiledevice/idevicerestore architecture

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

- Interactive diagram: https://gitdiagram.com/libimobiledevice/idevicerestore
- Repository: https://github.com/libimobiledevice/idevicerestore

## Overview

idevicerestore is a command-line iOS firmware restoration tool. The main workflow selects or downloads firmware, prepares signing data, communicates with the device across its operating modes, and runs the restore. The graph also preserves documented capabilities and substantial firmware-format, baseband, and transfer modules. The excerpts show only portions of the orchestration and restore code, so several internal links are marked unverified rather than asserted as observed calls.

Main entry points: [`src/idevicerestore.c`](https://github.com/libimobiledevice/idevicerestore/blob/master/src/idevicerestore.c) (Restore workflow), [`src/restore.c`](https://github.com/libimobiledevice/idevicerestore/blob/master/src/restore.c) (Restore session), [`src/common.c`](https://github.com/libimobiledevice/idevicerestore/blob/master/src/common.c) (Client state), [`src/dfu.c`](https://github.com/libimobiledevice/idevicerestore/blob/master/src/dfu.c) (DFU mode)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Restore orchestration"]
  node_app["Restore workflow<br/>[idevicerestore.c]"]
  node_shared["Client state<br/>[common.c]"]
end

subgraph group_device["Device modes"]
  node_dfu["DFU mode<br/>[dfu.c]"]
  node_recovery["Recovery mode<br/>[recovery.c]"]
  node_normal["Normal mode<br/>[normal.c]"]
end

subgraph group_firmware["Firmware and signing"]
  node_downloads["Firmware downloads<br/>[download.c]"]
  node_ipsw["IPSW archive<br/>[ipsw.c]"]
  node_tss["Signing records<br/>[idevicerestore.c]"]
  node_ace3["Ace3 payload<br/>[ace3.c]"]
  node_img3["IMG3 stitching<br/>[img3.c]"]
  node_img4["IMG4 stitching<br/>[img4.c]"]
end

subgraph group_protocols["Restore protocols"]
  node_restore["Restore session<br/>[restore.c]"]
  node_asr["Filesystem transfer<br/>[asr.c]"]
  node_fdr["FDR service<br/>[fdr.c]"]
  node_fls["Baseband FLS<br/>[fls.c]"]
  node_ftab["Baseband FTAB<br/>[ftab.c]"]
  node_mbn["Baseband MBN<br/>[mbn.c]"]
end

node_user(("CLI user"))
node_apple(("Apple signing service"))
node_device_actor(("iOS device"))

node_user -->|"starts"| node_app
node_app -->|"extracts firmware"| node_ipsw
node_app -->|"creates payload"| node_ace3
node_app -.->|"downloads firmware"| node_downloads
node_app -.->|"requests signing"| node_tss
node_tss -->|"requests tickets"| node_apple
node_app -.->|"handles DFU"| node_dfu
node_app -.->|"handles recovery"| node_recovery
node_app -.->|"checks device"| node_normal
node_app -.->|"runs restore"| node_restore
node_restore -->|"restores firmware"| node_device_actor
node_restore -.->|"transfers filesystem"| node_asr
node_restore -.->|"uses FDR service"| node_fdr
node_restore -.->|"uses baseband data"| node_fls
node_restore -.->|"uses baseband tables"| node_ftab
node_restore -.->|"uses baseband images"| node_mbn
node_app -.->|"stitches images"| node_img3
node_app -.->|"stitches images"| node_img4
node_app -.->|"uses shared state"| node_shared

click node_app "https://github.com/libimobiledevice/idevicerestore/blob/master/src/idevicerestore.c"
click node_shared "https://github.com/libimobiledevice/idevicerestore/blob/master/src/common.c"
click node_downloads "https://github.com/libimobiledevice/idevicerestore/blob/master/src/download.c"
click node_ipsw "https://github.com/libimobiledevice/idevicerestore/blob/master/src/ipsw.c"
click node_tss "https://github.com/libimobiledevice/idevicerestore/blob/master/src/idevicerestore.c"
click node_ace3 "https://github.com/libimobiledevice/idevicerestore/blob/master/src/ace3.c"
click node_img3 "https://github.com/libimobiledevice/idevicerestore/blob/master/src/img3.c"
click node_img4 "https://github.com/libimobiledevice/idevicerestore/blob/master/src/img4.c"
click node_dfu "https://github.com/libimobiledevice/idevicerestore/blob/master/src/dfu.c"
click node_recovery "https://github.com/libimobiledevice/idevicerestore/blob/master/src/recovery.c"
click node_normal "https://github.com/libimobiledevice/idevicerestore/blob/master/src/normal.c"
click node_restore "https://github.com/libimobiledevice/idevicerestore/blob/master/src/restore.c"
click node_asr "https://github.com/libimobiledevice/idevicerestore/blob/master/src/asr.c"
click node_fdr "https://github.com/libimobiledevice/idevicerestore/blob/master/src/fdr.c"
click node_fls "https://github.com/libimobiledevice/idevicerestore/blob/master/src/fls.c"
click node_ftab "https://github.com/libimobiledevice/idevicerestore/blob/master/src/ftab.c"
click node_mbn "https://github.com/libimobiledevice/idevicerestore/blob/master/src/mbn.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_app,node_shared,node_user toneBlue
class node_dfu,node_recovery,node_normal toneAmber
class node_downloads,node_ipsw,node_tss,node_ace3,node_img3,node_img4 toneMint
class node_restore,node_asr,node_fdr,node_fls,node_ftab,node_mbn toneRose
class node_apple,node_device_actor toneIndigo
```

## Components

### Restore orchestration

- [Restore workflow](https://github.com/libimobiledevice/idevicerestore/blob/master/src/idevicerestore.c): `src/idevicerestore.c`
- [Client state](https://github.com/libimobiledevice/idevicerestore/blob/master/src/common.c): `src/common.c`

### Device modes

- [DFU mode](https://github.com/libimobiledevice/idevicerestore/blob/master/src/dfu.c): `src/dfu.c`
- [Recovery mode](https://github.com/libimobiledevice/idevicerestore/blob/master/src/recovery.c): `src/recovery.c`
- [Normal mode](https://github.com/libimobiledevice/idevicerestore/blob/master/src/normal.c): `src/normal.c`

### Firmware and signing

- [Firmware downloads](https://github.com/libimobiledevice/idevicerestore/blob/master/src/download.c): `src/download.c`
- [IPSW archive](https://github.com/libimobiledevice/idevicerestore/blob/master/src/ipsw.c): `src/ipsw.c`
- [Signing records](https://github.com/libimobiledevice/idevicerestore/blob/master/src/idevicerestore.c): `src/idevicerestore.c`
- [Ace3 payload](https://github.com/libimobiledevice/idevicerestore/blob/master/src/ace3.c): `src/ace3.c`
- [IMG3 stitching](https://github.com/libimobiledevice/idevicerestore/blob/master/src/img3.c): `src/img3.c`
- [IMG4 stitching](https://github.com/libimobiledevice/idevicerestore/blob/master/src/img4.c): `src/img4.c`

### Restore protocols

- [Restore session](https://github.com/libimobiledevice/idevicerestore/blob/master/src/restore.c): `src/restore.c`
- [Filesystem transfer](https://github.com/libimobiledevice/idevicerestore/blob/master/src/asr.c): `src/asr.c`
- [FDR service](https://github.com/libimobiledevice/idevicerestore/blob/master/src/fdr.c): `src/fdr.c`
- [Baseband FLS](https://github.com/libimobiledevice/idevicerestore/blob/master/src/fls.c): `src/fls.c`
- [Baseband FTAB](https://github.com/libimobiledevice/idevicerestore/blob/master/src/ftab.c): `src/ftab.c`
- [Baseband MBN](https://github.com/libimobiledevice/idevicerestore/blob/master/src/mbn.c): `src/mbn.c`

### Other components

- **CLI user**
- **Apple signing service**
- **iOS device**

## Connections

- CLI user → Restore workflow: starts (evidence: `README.md`)
- Restore workflow → IPSW archive: extracts firmware (evidence: `src/idevicerestore.c`)
- Restore workflow → Ace3 payload: creates payload (evidence: `src/idevicerestore.c`)
- Restore workflow → Firmware downloads: downloads firmware
- Restore workflow → Signing records: requests signing (evidence: `src/idevicerestore.c`)
- Signing records → Apple signing service: requests tickets (evidence: `README.md`)
- Restore workflow → DFU mode: handles DFU
- Restore workflow → Recovery mode: handles recovery
- Restore workflow → Normal mode: checks device
- Restore workflow → Restore session: runs restore
- Restore session → iOS device: restores firmware (evidence: `README.md`)
- Restore session → Filesystem transfer: transfers filesystem
- Restore session → FDR service: uses FDR service
- Restore session → Baseband FLS: uses baseband data
- Restore session → Baseband FTAB: uses baseband tables
- Restore session → Baseband MBN: uses baseband images
- Restore workflow → IMG3 stitching: stitches images
- Restore workflow → IMG4 stitching: stitches images
- Restore workflow → Client state: uses shared state
