Repository navigation
Getting your keys
Tuxchange contains no console keys and cannot derive a StreetPass exchange without them. The protocol is authenticated and encrypted with values that are on the console, so you supply them from your own hardware.
You need two files in ~/.config/tuxchange/.
python3 tools/lp_extract_keys.pyThe above command with no argument shows what's present, it is a good idea to run it after each step.
Example output:
aes_keys.txt /home/you/.config/tuxchange/aes_keys.txt
keyslot 0x2E present
keyslot 0x31 present
tuxchange.keys /home/you/.config/tuxchange/tuxchange.keys
cecd_hmac_retail present
title_hmac_00020800 present
all key material present
On your console:
- Start GodMode9 on your modded (boot9strap) 3DS.
- Hold START while booting and select GodMode9 if prompted.
- Run the 'DumpKeys' script, which exports `sdcard/gm9/aes_keys.txt'.
- Press HOME -> Scripts... -> DumpKeys
- If missing, download DumpKeys here
and place in
<3DS SD Card>/gm9/scripts/
- Insert SD Card into computer and copy
aes_keys.txtto Tuxchange config:
mkdir -p ~/.config/tuxchange
cp /path/to/sd/gm9/aes_keys.txt ~/.config/tuxchange/
chmod 600 ~/.config/tuxchange/aes_keys.txtWhat it is used for
Tuxchange uses two slots from it:
| Slot | What it is for |
|---|---|
0x2E |
the slot cecd runs the StreetPass CCMP link key through |
0x31 |
the APT key that wraps the Mii container inside a StreetPass Mii Plaza message |
It reads KeyX and KeyY and runs the 3DS key scrambler over them.
Two values Tuxchange needs are fixed strings compiled into binaries on the console, so they come
out of dumps you take yourself. They come from the StreetPass daemon the 3DS OS uses called cecd.
Extracting code.bin
On your console, with GodMode9 open (see 1.)
- Open the NAND Title manager
- Press HOME -> Title manager -> [1:] NAND / TWL
- A list of system apps and titles should appear.
- Find the 'cecd' entry.
- Look for
0004013000002602 (1125pseg-ciuser)
- Look for
- Select the entry and open the title directory
- Press A on that entry you found.
- Select 'Open title folder'
- Extract
cecd'scode.bin- Press A on '00000016.app'
- Press NCCH image options... -> Extract .code
- If done correctly, your SD card should contain
gm9/out/0004013000002602.dec.code
- Copy to your computer and rename to
code.bin- Insert the SD card into your computer and put the '...dec.code' file you dumped somewhere safe
with the file renamed to 'code.bin', e.g. at
~/code.bin - We will use this file in the next step.
- Insert the SD card into your computer and put the '...dec.code' file you dumped somewhere safe
with the file renamed to 'code.bin', e.g. at
cecd hashes the link key with a 17-byte HMAC key: 16 ASCII characters plus the trailing NUL, which
is part of the key. You need a decrypted code.bin for the cecd system module (title
0004013000002602), see 'Extracting code.bin'.
How the extractor works
The extractor finds the string without needing an offset. The development key is the sixteen lowercase hex digits in order, a generic test string with nothing secret about it. The extractor searches for that and takes the string in the slot immediately before it, where the retail key lives.
python3 tools/lp_extract_keys.py --cecd /path/to/cecd/code.binIn the unlikely case that a future system update causes cecd lays them out differently, find the
retail string yourself and pass --cecd-offset.
Every StreetPass-enabled title signs its messages with its own 32-byte HMAC key, kept in that title's
MBoxInfo____ file in the console's CEC store. Tuxchange needs Mii Plaza's (00020800) to build
a message a console will accept.
Extracting CEC store
On your console, with GodMode9 open (see 1.)
- Open the NAND filesystem
- Navigate to '[1:] SYSNAND CTRNAND' in the GodMode9 main menu.
- Go to
data/[yourid]/sysdata/00010026directory- You should see one file: '00000000'
- Mount CEC partition
- Press A on '00000000'
- Select 'Mount as DISA image'
- Press A for yes to enter the path of the mounted CEC partition.
- Copy
partitionA.binto your SD card- If mounted correctly, you should see 'partitionA.bin'
- Press A on this file and 'Copy to 0:/gm9/out'.
- Copy to your computer and rename to
CEC-partition.bin- Insert the SD card into your computer and put the 'partitionA.bin' file you dumped somewhere safe
with the file renamed to 'CEC-partition.bin', e.g. at
~/CEC-partition.bin - We will use this file in the next step.
- Insert the SD card into your computer and put the 'partitionA.bin' file you dumped somewhere safe
with the file renamed to 'CEC-partition.bin', e.g. at
Once your CEC store has been extracted, run:
python3 tools/lp_extract_keys.py --cec-store /path/to/CEC-partition.binIt reads every title's key, so Tuxchange can exchange for any title you have. You can give optionally more sources in separate runs, because the file is merged on each time.
Once done, move onto Installation.
In order of priority:
-
$TUXCHANGE_KEYS(foraes_keys.txt) or$TUXCHANGE_KEYFILE(fortuxchange.keys) $TUXCHANGE_KEYDIR/-
$XDG_CONFIG_HOME/tuxchange/, which is~/.config/tuxchange/by default -
/etc/tuxchange/, which is where the service finds them - the current directory
sudo ./install/install.sh install copies your files to /etc/tuxchange/, (only if they are
not already there. If you dump new ones after installing, you can copy them across yourself)
tuxchange.keys is written with mode 0600 with the file in '.gitignore'.