Repository navigation
Protocol Mii Records
A Mii is a 96-byte (0x60) record. Mii Plaza messages carry one, encrypted with AES-CCM under the slot 0x31 key. This page covers the record, the checks a receiver applies, and the encryption. Where the record sits inside a Plaza body is on Mii Plaza Messages.
All integers are little-endian unless stated.
Implemented in: mii::record, mii::wrap.
| Offset | Size | Field |
|---|---|---|
0x00 |
1 | Version, 3 for a new record |
0x01 |
1 | Bit 0: copying allowed |
0x00 |
4 | Also read as a bit field word: region lock, character set, page, slot, origin (below) |
0x04 |
8 | System ID |
0x0c |
4 | Mii ID |
0x10 |
6 | Creator MAC |
0x18 |
2 | Flags: gender, birthday, favourite colour, favourite |
0x1a |
20 | Name, 10 UTF-16LE units, zero-padded |
0x2e |
1 | Height |
0x2f |
1 | Weight |
0x30 |
24 | Appearance bit fields; bit 0 of 0x30 is "sharing disabled" |
0x48 |
20 | Creator name, 10 UTF-16LE units, zero-padded |
0x5c |
2 | Padding, zero when sent |
0x5e |
2 | CRC-16, big-endian |
A Mii database keeps the first 0x5c bytes. ctrpass turns such a stored record into a full record by adding the padding and the CRC.
Each field is read as a little-endian word starting at the given byte, then shifted right by shift and masked to width bits. The range is what a receiver accepts.
| Field | Byte | Shift | Width | Accepted |
|---|---|---|---|---|
| region_lock | 0x00 |
10 | 2 | 0-3 |
| char_set | 0x00 |
12 | 2 | 0-3 |
| page | 0x00 |
16 | 4 | 0-9 |
| slot | 0x00 |
20 | 4 | 0-9 |
| origin | 0x00 |
28 | 3 | 1-3 |
| gender | 0x18 |
0 | 1 | 0-1 |
| favourite_colour | 0x18 |
10 | 4 | 0-11 |
| height | 0x2e |
0 | 8 | 0-128 |
| weight | 0x2f |
0 | 8 | 0-128 |
| face_shape | 0x30 |
1 | 4 | 0-11 |
| skin_colour | 0x30 |
5 | 3 | 0-5 |
| wrinkles | 0x30 |
8 | 4 | 0-11 |
| makeup | 0x30 |
12 | 4 | 0-11 |
| hair_style | 0x32 |
0 | 8 | 0-131 |
| hair_colour | 0x32 |
8 | 3 | 0-7 |
| hair_flip | 0x32 |
11 | 1 | 0-1 |
| eye_type | 0x34 |
0 | 6 | 0-59 |
| eye_colour | 0x34 |
6 | 3 | 0-5 |
| eye_scale | 0x34 |
9 | 4 | 0-7 |
| eye_aspect | 0x34 |
13 | 3 | 0-6 |
| eye_rotation | 0x36 |
0 | 5 | 0-7 |
| eye_spacing | 0x36 |
5 | 4 | 0-12 |
| eye_y | 0x36 |
9 | 5 | 0-18 |
| eyebrow_type | 0x38 |
0 | 5 | 0-23 |
| eyebrow_colour | 0x38 |
5 | 3 | 0-7 |
| eyebrow_scale | 0x38 |
8 | 4 | 0-8 |
| eyebrow_aspect | 0x38 |
12 | 3 | 0-6 |
| eyebrow_rotation | 0x3a |
0 | 5 | 0-11 |
| eyebrow_spacing | 0x3a |
5 | 4 | 0-12 |
| eyebrow_y | 0x3a |
9 | 5 | 3-18 |
| nose_type | 0x3c |
0 | 5 | 0-17 |
| nose_scale | 0x3c |
5 | 4 | 0-8 |
| nose_y | 0x3c |
9 | 5 | 0-18 |
| mouth_type | 0x3e |
0 | 6 | 0-35 |
| mouth_colour | 0x3e |
6 | 3 | 0-4 |
| mouth_scale | 0x3e |
9 | 4 | 0-8 |
| mouth_aspect | 0x3e |
13 | 3 | 0-6 |
| mouth_y | 0x40 |
0 | 5 | 0-18 |
| moustache_type | 0x40 |
5 | 3 | 0-5 |
| beard_type | 0x42 |
0 | 3 | 0-5 |
| facial_hair_colour | 0x42 |
3 | 3 | 0-7 |
| moustache_scale | 0x42 |
6 | 4 | 0-8 |
| moustache_y | 0x42 |
10 | 5 | 0-16 |
| glasses_type | 0x44 |
0 | 4 | 0-8 |
| glasses_colour | 0x44 |
4 | 3 | 0-5 |
| glasses_scale | 0x44 |
7 | 4 | 0-7 |
| glasses_y | 0x44 |
11 | 5 | 0-20 |
| mole | 0x46 |
0 | 1 | 0-1 |
| mole_scale | 0x46 |
1 | 4 | 0-8 |
| mole_x | 0x46 |
5 | 5 | 0-16 |
| mole_y | 0x46 |
10 | 5 | 0-30 |
The flags word at 0x18 also holds:
| Bits | Field |
|---|---|
| 1-4 | Birth month |
| 5-9 | Birth day |
| 14 | Favourite |
CRC-16 with polynomial 0x1021, initial value 0, no reflection, no final XOR, over bytes 0x00 to 0x5d. It is stored big-endian at 0x5e.
A receiving Mii Plaza drops a record when any of these hold:
| Issue | Rule |
|---|---|
| CRC | The CRC does not match. |
| Identity | Bytes 0x0c to 0x15 (Mii ID and creator MAC) are all zero; or byte 0x0c has bit 5 set; or byte 0x0c has bit 7 clear while sharing is not disabled. |
| Range | Any bit field above is outside its accepted range. |
| Birthday | Month or day is zero but not both, month is above 12, or day is past the end of the month (February allows 29). |
| Name | The name is empty. |
| Characters | The name or creator name contains % or \. |
Mii IDs made by a console have 0x9 in the high nibble of byte 0x0c. ctrpass gives new Miis an ID whose byte 0x0c is 0x90 to 0x9f.
A sender clears the favourite bit, zeroes the padding at 0x5c and recomputes the CRC. ctrpass does this every time it puts a Mii into a message body, for any game whose plugin has a Mii field, then refuses the Mii if any issue above remains.
Inside a message the record is "wrapped" into 0x70 bytes with AES-CCM under the slot 0x31 normal key.
| Offset | Size | Field |
|---|---|---|
0x00 |
8 | Nonce: record bytes 0x0c to 0x13 (Mii ID and the first 4 bytes of the creator MAC), in the clear |
0x08 |
0x58 |
The rest of the record, encrypted |
0x60 |
16 | CCM tag |
The encrypted part is the record with its nonce bytes taken out: bytes 0x00-0x0b followed by bytes 0x14-0x5f.
CCM parameters:
| Parameter | Value |
|---|---|
| Cipher | AES-128 |
| Key | Slot 0x31 normal key |
| Nonce | 12 bytes: the 8 nonce bytes then 4 zero bytes |
| Tag | 16 bytes |
| Associated data | None |
| Tag input | The 0x58-byte plaintext padded with zeros to 0x60 bytes |
The tag is computed over the zero-padded plaintext, but only the first 0x58 bytes of ciphertext are kept. To unwrap:
- Run CCM encryption over the ciphertext padded to
0x60. Because CCM encryption is a counter mode, this yields the plaintext. - Run CCM encryption over that plaintext padded to
0x60to get the expected tag. - Compare with the stored tag in constant time.
- Put the 8 nonce bytes back at
0x0c.
flowchart LR
rec["Record, 0x60"] --> split["Take out bytes 0x0c-0x13"]
split --> n["Nonce, 8 bytes"]
split --> body["Body, 0x58 bytes"]
body --> pad["Pad to 0x60"]
pad --> ccm["AES-CCM, slot 0x31 key"]
n --> ccm
ccm --> ct["Ciphertext, first 0x58 bytes"]
ccm --> tag["Tag, 16 bytes"]
n --> out["Wrapped: nonce, ciphertext, tag"]
ct --> out
tag --> out
When ctrpass makes a new Mii, it starts from a zero record, sets version 3 and byte 3 to 0x30, writes the Mii ID, creator MAC and name, and sets an ordinary face so the record renders. The face shape and gender come from the store's identity (see Store). The meaning of byte 3 is not known.
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