Repository navigation
Protocol Keys
StreetPass uses four kinds of keys. ctrpass never ships any of them. They come from the user's own console.
Implemented in: keys, streetpass::linkkey.
| Key | Size | Needed for | Used at |
|---|---|---|---|
Slot 0x2E normal key |
16 bytes | Exchanges | Encrypts the HMAC digest into the link key (Link Setup) |
streetpassHmacKey |
16 bytes | Exchanges | HMAC-SHA1 key for the link key, used with one trailing zero byte (17 bytes) |
Slot 0x31 normal key |
16 bytes | Reading or building Miis | AES-CCM key that wraps Mii records (Mii Records) |
| Title signing key | 32 bytes per title | Building signed messages; checking received ones | HMAC-SHA256 key for the container trailer (CEC Messages) |
flowchart TD
k2e["slot 0x2E key"] --> lk["Link key"]
hm["streetpassHmacKey"] --> lk
lk --> ccmp["CCMP on every data frame"]
k31["slot 0x31 key"] --> mii["Mii record wrap and unwrap"]
tk["Title signing key"] --> sig["Container trailer: sign and verify"]
Without the slot 0x2E key and the HMAC key, ctrpass can still scan for consoles and read message files, but it cannot exchange. Without the slot 0x31 key, it can carry Plaza messages but cannot read or build their Mii. Without a title's signing key, it cannot build a new message for that title, and it stores received messages for that title without checking them.
The console's AES engine derives a normal key from a key pair, X and Y. ctrpass does the same when the key file has KeyX and KeyY instead of KeyN:
normal = rotl128( (rotl128(X, 2) XOR Y) + C, 87 )
C = 0x1FF9E9AAC5FE0408024591DC5D52768A
X, Y and C are 128-bit big-endian numbers. The addition wraps at 2^128.
ctrpass reads a text file of name=hex lines, the same format as a console's aes_keys.txt. Names are matched without regard to case. Lines without = are ignored.
| Entry | Meaning |
|---|---|
slot0x2EKeyN |
Slot 0x2E normal key |
slot0x2EKeyX, slot0x2EKeyY
|
Slot 0x2E key pair, used when KeyN is missing |
streetpassHmacKey |
The HMAC key, 16 bytes |
slot0x31KeyN, or slot0x31KeyX and slot0x31KeyY
|
Slot 0x31 key, optional |
titleKeyXXXXXXXX |
Signing key for title XXXXXXXX (hex), 32 bytes, optional |
The slot 0x2E key and the HMAC key are required. A present entry with the wrong length is an error.
ctrpass's key types never print their values.
| Key | Source |
|---|---|
| Slot keys | The console's own aes_keys.txt dump |
streetpassHmacKey |
The decrypted StreetPass system module (code.bin) |
| Title signing keys | Each title's MBoxInfo____ file, offset 0x10, in a CEC save image or folder |
The HMAC key is a 16-character ASCII string followed by a zero byte. In the module, a development key string 0123456789abcdef\0 sits 0x14 bytes after it. ctrpass finds the development string, steps back 0x14 bytes, and checks that the 16 bytes there are letters, digits, _, - or ., followed by a zero byte. A file offset can be given instead of searching.
Title keys are read from every MBoxInfo____ found in a CEC save image or folder. An all-zero key means no key is set. When importing into a store that already holds a different key for a title, ctrpass reports a conflict and keeps the store's key. When writing a key file, a new entry replaces the line of the same name and every other line is kept.
How to set up
- Overview and requirements
- Choosing a Wi-Fi adapter
- Building and installing
- Making the key file
- Desktop app
- Command line
- Messages and emulators
- Troubleshooting
Plugins
Protocol
- Overview
- Discovery
- Link setup
- Frames and CCMP
- YY transport
- Exchange flow
- Exchange objects
- CEC messages
- CEC message boxes
- Mii records
- Mii Plaza
- Keys
ctrpass library
Linux