Python library for converting Nintendo 3DS CIA files to decrypted CCI files
Project description
CIA to CCI Converter
A Python library with C/C++ bindings for converting Nintendo 3DS CIA (CTR Importable Archive) files to decrypted CCI (CTR Cart Image) files.
Features
- Zero External Dependencies: All tools (ctrtool, makerom) are statically linked into Python extension modules
- Full Decryption Support: Extracts and decrypts CXI components using AES keys
- Native Performance: C/C++ implementation with Python bindings via pybind11
- Cross-Platform: Works on macOS, Linux, and Windows
- Clean Python API: High-level interface for easy integration
- Low-Level Access: Direct access to ctrtool and makerom functionality
What This Tool Does
This library replicates the functionality of command-line tools ctrtool and makerom from the Project_CTR repository, packaged as a convenient Python library.
The conversion process:
- Extracts contents from CIA files
- Reads metadata (Title ID, Product Code) from CXI
- Extracts and decrypts CXI components (ExeFS, RomFS, extended header)
- Generates RSF configuration file with system calls and service access
- Rebuilds decrypted CXI with all components
- Creates final decrypted CCI file
Requirements
System Requirements
- Python: 3.8 or higher
- Platform: macOS, Linux, or Windows
- Build Tools (for building from source):
- CMake 3.18+
- C++17 compatible compiler (GCC 7+, Clang 5+, MSVC 2019+)
- Python development headers
AES Keys (Required)
This tool requires Nintendo 3DS AES keys for decryption. You must provide your own keys at:
~/.3ds/aes_keys.txt
Important: This project does NOT include or provide AES keys. You must obtain them legally through your own means.
Installation
From Source
# Clone the repository with submodules
git clone --recursive https://github.com/reyrodrigues/cia-to-cci.git
cd cia-to-cci
# Build and install
pip install .
Development Installation
# Install in editable mode
pip install -e .
# Run tests
pytest tests/
Usage
Command-Line Interface
After installation, you can use the cia-to-cci command:
# Basic usage - converts game.cia to game.cci
cia-to-cci game.cia
# Specify output path
cia-to-cci game.cia -o output.cci
# Use custom AES keys file
cia-to-cci game.cia --keys /path/to/aes_keys.txt
# Keep temporary files for debugging
cia-to-cci game.cia --keep-temp
# Show help
cia-to-cci --help
You can also run it as a Python module:
python -m cia_to_cci game.cia
Python API
Basic Conversion
from cia_to_cci import convert_cia_to_cci
# Convert CIA to decrypted CCI
output_path = convert_cia_to_cci("game.cia", "game.cci")
print(f"Converted successfully: {output_path}")
Advanced Usage
from cia_to_cci import CIAConverter
from pathlib import Path
# Create converter with custom AES keys path
converter = CIAConverter(aes_keys_path=Path("custom/path/aes_keys.txt"))
# Convert with automatic output naming
output = converter.convert(Path("game.cia"))
Low-Level API
from cia_to_cci import ctrtool, makerom
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as temp_dir:
temp_path = Path(temp_dir)
# Step 1: Extract CIA contents
main_content = ctrtool.extract_cia("game.cia", temp_path)
# Step 2: Get CXI metadata
info = ctrtool.get_cxi_info(main_content)
print(f"Title ID: {info.title_id}")
print(f"Product Code: {info.product_code}")
# Step 3: Extract CXI components
ctrtool.extract_cxi(
cxi_path=main_content,
exheader_path=temp_path / "exheader.bin",
exefs_dir=temp_path / "exefs",
romfs_path=temp_path / "romfs.bin",
logo_path=temp_path / "logo.bin",
plain_path=temp_path / "plain.bin",
decompress_code=True
)
# Step 4: Build decrypted CXI
cxi_output = makerom.build_cxi(
output_path=temp_path / "decrypted.cxi",
rsf_path=temp_path / "build.rsf",
exheader_path=temp_path / "exheader.bin",
code_path=temp_path / "exefs/code.bin",
icon_path=temp_path / "exefs/icon.bin",
banner_path=temp_path / "exefs/banner.bin",
romfs_path=temp_path / "romfs.bin"
)
# Step 5: Build final CCI
cci_output = makerom.build_cci(
output_path="game.cci",
content_path=cxi_output
)
Building from Source
Prerequisites
Install build dependencies:
macOS:
brew install cmake python3
Ubuntu/Debian:
sudo apt-get install cmake python3-dev build-essential
Windows:
- Install Visual Studio 2019 or later with C++ build tools
- Install CMake
- Python 3.8+ from python.org
Build Steps
# Clone with submodules
git clone --recursive https://github.com/reyrodrigues/cia-to-cci.git
cd cia-to-cci
# Create virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate.bat
# Install in development mode
pip install -e .
Build Configuration
The project uses CMake for building native extensions. Build options:
# Release build (default) - optimized binaries
pip install -e .
# Debug build - for development
CMAKE_BUILD_TYPE=Debug pip install -e .
Project Structure
cia_to_cci/
├── src/
│ └── cia_to_cci/
│ ├── __init__.py # Main package exports
│ ├── converter.py # High-level conversion API
│ ├── ctrtool.py # ctrtool wrapper
│ ├── makerom.py # makerom wrapper
│ └── _bindings/ # C++ pybind11 bindings
├── native/
│ ├── project_ctr/ # Git submodule: Project_CTR
│ ├── ctrtool_wrapper/ # C++ wrapper for ctrtool
│ └── makerom_wrapper/ # C wrapper for makerom
├── tests/ # Unit and integration tests
├── CMakeLists.txt # Root build configuration
└── pyproject.toml # Python package metadata
Dependencies
This project incorporates code from:
- Project_CTR - ctrtool and makerom (MIT License)
- Copyright (c) 2014 3DSGuy
- Copyright (c) 2014 applestash
- Copyright (c) 2015-2022 Jakcron
All dependencies are statically linked, so no external installation is required.
Troubleshooting
"Failed to load cryptographic keys"
Ensure your AES keys file exists at ~/.3ds/aes_keys.txt and contains valid keys.
Build fails on macOS
Make sure you have Xcode Command Line Tools installed:
xcode-select --install
Build fails on Linux
Install Python development headers:
sudo apt-get install python3-dev
Build fails on Windows
Make sure you have:
- Visual Studio 2019 or later with C++ build tools installed
- CMake in your PATH
- Run the build from a Visual Studio Developer Command Prompt
ImportError when importing module
Rebuild the extension modules:
pip install --force-reinstall -e .
Legal Notice
Important: This tool is intended for legal use only, such as:
- Backup and preservation of games you legally own
- Development and homebrew purposes
- Educational use
Users are responsible for complying with all applicable laws regarding:
- Copyright and intellectual property
- DMCA and anti-circumvention statutes
- Software licensing agreements
This project does NOT provide or include:
- Nintendo 3DS AES keys
- Copyrighted game files
- Any circumvention tools
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
Testing
# Run tests
pytest tests/
# Run with coverage
pytest --cov=cia_to_cci tests/
License
This project is licensed under the MIT License - see the LICENSE file for details.
This project incorporates code from Project_CTR, which is also MIT licensed.
Acknowledgments
- 3DSGuy, applestash, and Jakcron for the original ctrtool and makerom implementations
- Project_CTR contributors for maintaining the tools
Disclaimer: This tool is provided as-is for educational and legal purposes only. The authors are not responsible for any misuse of this software.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cia_to_cci-0.1.7.tar.gz.
File metadata
- Download URL: cia_to_cci-0.1.7.tar.gz
- Upload date:
- Size: 2.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2975aa3a6001281d977cdb506c41e2630dcecca8ca86c953bd9c09ddd7a59b44
|
|
| MD5 |
ec6a6cc15b75224fae1b16a1261b82a3
|
|
| BLAKE2b-256 |
b1dedfcafe46dc8c4896a3dfb070bc4744e9e929232dcc51ec52fcf6023afd3c
|
File details
Details for the file cia_to_cci-0.1.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: cia_to_cci-0.1.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5331a282ba4705e5278d016cf466135209e0931dbcd90b2ae4c5606235a203f3
|
|
| MD5 |
6722d2f6c6d91d76f0f0ba1a395149d7
|
|
| BLAKE2b-256 |
327d7d6e3ed9d95e311d113168ffbb41087bbb263fdf5de3d098ed3b0e8c6b69
|
File details
Details for the file cia_to_cci-0.1.7-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: cia_to_cci-0.1.7-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1d0f595b76066dec32e16dee6c5acfcda7e7270f3d0dd0460aa35655594612d
|
|
| MD5 |
e22ebe0cf857787551c76d3e27b4b182
|
|
| BLAKE2b-256 |
f651dc8eb85d12f7848ea87f4859bd81d9449b9fabc98ffaf9c0186fbade4840
|
File details
Details for the file cia_to_cci-0.1.7-cp312-cp312-macosx_10_14_x86_64.whl.
File metadata
- Download URL: cia_to_cci-0.1.7-cp312-cp312-macosx_10_14_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.12, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
339d065d0d5ae22399b677a53f9a398ac700053c0d2ff2b0095ded39bc7e208e
|
|
| MD5 |
69ca33d8da6d20a6996b577ab29ddd43
|
|
| BLAKE2b-256 |
c1a4c1a107548dd76e6e2064979cc2da85ec64ea05790fdd16069fd8ede86f45
|
File details
Details for the file cia_to_cci-0.1.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: cia_to_cci-0.1.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f2bf6a2678e1f290140442b198ee831721a9090f42db1826506253567458fc1
|
|
| MD5 |
f0f6d7cbd8b87dce6f7c91b19beaf9e8
|
|
| BLAKE2b-256 |
233300788bc188a282888f68db6cf69cedec9d23bfceb5db4b24a08c21e0a6a2
|
File details
Details for the file cia_to_cci-0.1.7-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: cia_to_cci-0.1.7-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5af0457a4854c61491ced297e5532a30d16a4fd78d643d425016250f2ef79f1
|
|
| MD5 |
79603d7509603d8d3fbc380496fcd080
|
|
| BLAKE2b-256 |
5d0e833a1d5b3ed2d88dba0e332f88cea8af83e5b81f7a55600d899f12fb00ba
|
File details
Details for the file cia_to_cci-0.1.7-cp311-cp311-macosx_10_14_x86_64.whl.
File metadata
- Download URL: cia_to_cci-0.1.7-cp311-cp311-macosx_10_14_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.11, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca35fed81a3bf5575430a0efb3c46e4de8e5ad9e1322dbb9071c1505bb9dcc28
|
|
| MD5 |
6ef2e07d93ecf18f6200b34747e1d75f
|
|
| BLAKE2b-256 |
122e1b854f784cc75714ee4994a0671c18939ba1defe5f444c0115dae0ac5134
|
File details
Details for the file cia_to_cci-0.1.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: cia_to_cci-0.1.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ac39a3fc83544922909b035df2369004e440a371bddabc0d9a3ef3b4332086e
|
|
| MD5 |
f60d04e591fac5338ade6b2a4f86d56b
|
|
| BLAKE2b-256 |
c8126c10c70010d43e08f0852810622c179b8c0565ab7eb2e8ff9691cdb6bce1
|
File details
Details for the file cia_to_cci-0.1.7-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: cia_to_cci-0.1.7-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df0a4eaa33949cce76f89532d4d84966f2eef6069b612214aac295ee7ad07b35
|
|
| MD5 |
b64dcbb6f3fac554f97c6a06ec240d98
|
|
| BLAKE2b-256 |
e363244a100968383f7cac9a5a49769f29ef0fbdac1d6148c8a0f266c02db29d
|
File details
Details for the file cia_to_cci-0.1.7-cp310-cp310-macosx_10_14_x86_64.whl.
File metadata
- Download URL: cia_to_cci-0.1.7-cp310-cp310-macosx_10_14_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.10, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9d24541d02c52d319f0e850ed92a53e9dd726427c58a6b6091304d6dfb7763e
|
|
| MD5 |
6695b54d01f3e4fe1f9b4941b0d8710f
|
|
| BLAKE2b-256 |
d62c4d09809615619f213c2a34339b4cb3a47b7479e6bf9f0987aec9936da682
|
File details
Details for the file cia_to_cci-0.1.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: cia_to_cci-0.1.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
baebdc955b3b3b78ee43aca0e2ebe8342315b00e3801d9cb625e98da9a17f136
|
|
| MD5 |
10d4565cbd4fa325754e08d1717f95ab
|
|
| BLAKE2b-256 |
a62f67f77bf09dd7a51ecd39e7797f3b11704145f2ec326e9ff9f49812b45b7b
|
File details
Details for the file cia_to_cci-0.1.7-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: cia_to_cci-0.1.7-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23567da03054c55a43bea0bda682e5074f1940ba3a72c3194f00795fd49cabba
|
|
| MD5 |
e982ba927346c33b7efb154438088dab
|
|
| BLAKE2b-256 |
f84e9f9e635febaae1a6ebbd1e3488f60777bc23212f521f25dbabf7fb4a9ec0
|
File details
Details for the file cia_to_cci-0.1.7-cp39-cp39-macosx_10_14_x86_64.whl.
File metadata
- Download URL: cia_to_cci-0.1.7-cp39-cp39-macosx_10_14_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.9, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebce5e066135374a8947b57244a6d1be4614cb9c72967b335c67a1726f1e878d
|
|
| MD5 |
cedd4a8592c02effd4ecff8b23d64993
|
|
| BLAKE2b-256 |
b0e9d139583a4a09ae345382ad4d50175afb19635ef29dd14372326676621511
|
File details
Details for the file cia_to_cci-0.1.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: cia_to_cci-0.1.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4194ad0a79b1fde51a58925516a12e5537c73c4d8a1d7dbc4f315070fbf5c8ba
|
|
| MD5 |
d1581fe9d7e0fb68807c82dce32d431a
|
|
| BLAKE2b-256 |
cbff3aaad5dbdc9c678fa3ffc3f9b5020f156c665a7fbdfd32f917b60db4927a
|
File details
Details for the file cia_to_cci-0.1.7-cp38-cp38-macosx_11_0_arm64.whl.
File metadata
- Download URL: cia_to_cci-0.1.7-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9df433377d0ccebd45d0557628ef387f89416fe40ad83fe3aaec76b6a00a62f
|
|
| MD5 |
a03bc70a9ae0d2355a4588498a55c5e4
|
|
| BLAKE2b-256 |
725656e7d56af11d03550f030f7e9adbd65307f9eac95923d13467c5e76d38c0
|
File details
Details for the file cia_to_cci-0.1.7-cp38-cp38-macosx_10_14_x86_64.whl.
File metadata
- Download URL: cia_to_cci-0.1.7-cp38-cp38-macosx_10_14_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.8, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e5864d28b97d0f804feb656bda45924b1f68a412ec8d06253349509c58afe6e
|
|
| MD5 |
6063e22b7e45554693f635caf676cd5c
|
|
| BLAKE2b-256 |
67cc37a5f64c51b1088802eaaaa62df1d5460ea0a4cadaf0b05dbc20804877ea
|