Skip to content

Getting your keys

Fin edited this page Nov 14, 2026 · 3 revisions

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/.

Check what Tuxchange can see

python3 tools/lp_extract_keys.py

The 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

1. aes_keys.txt: the AES keyslots

On your console:

  1. Start GodMode9 on your modded (boot9strap) 3DS.
    • Hold START while booting and select GodMode9 if prompted.
  2. 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/
  3. Insert SD Card into computer and copy aes_keys.txt to Tuxchange config:
mkdir -p ~/.config/tuxchange
cp /path/to/sd/gm9/aes_keys.txt ~/.config/tuxchange/
chmod 600 ~/.config/tuxchange/aes_keys.txt
What 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.

2. tuxchange.keys: 2 constants from your dumps

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.)
  1. Open the NAND Title manager
    • Press HOME -> Title manager -> [1:] NAND / TWL
    • A list of system apps and titles should appear.
  2. Find the 'cecd' entry.
    • Look for 0004013000002602 (1125pseg-ciuser)
  3. Select the entry and open the title directory
    • Press A on that entry you found.
    • Select 'Open title folder'
  4. Extract cecd's code.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
  5. 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.

The cecd HMAC key

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.bin

In the unlikely case that a future system update causes cecd lays them out differently, find the retail string yourself and pass --cecd-offset.

A title's message HMAC key

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.)
  1. Open the NAND filesystem
    • Navigate to '[1:] SYSNAND CTRNAND' in the GodMode9 main menu.
  2. Go to data/[yourid]/sysdata/00010026 directory
    • You should see one file: '00000000'
  3. 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.
  4. Copy partitionA.bin to your SD card
    • If mounted correctly, you should see 'partitionA.bin'
    • Press A on this file and 'Copy to 0:/gm9/out'.
  5. 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.

Once your CEC store has been extracted, run:

python3 tools/lp_extract_keys.py --cec-store /path/to/CEC-partition.bin

It 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.

Where the files are looked for

In order of priority:

  1. $TUXCHANGE_KEYS (for aes_keys.txt) or $TUXCHANGE_KEYFILE (for tuxchange.keys)
  2. $TUXCHANGE_KEYDIR/
  3. $XDG_CONFIG_HOME/tuxchange/, which is ~/.config/tuxchange/ by default
  4. /etc/tuxchange/, which is where the service finds them
  5. 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)

Keep them private

tuxchange.keys is written with mode 0600 with the file in '.gitignore'.

Clone this wiki locally