Skip to content

Protocol CEC Messages

finthetechguy edited this page Nov 24, 2026 · 2 revisions

CEC Messages

A StreetPass message is a CEC container: a fixed header, optional extension headers, a game-defined body and an HMAC trailer. Containers travel over the link inside envelopes, one envelope per title. The same container bytes are what a console stores in its message box (see CEC Message Boxes).

All integers are little-endian.

Implemented in: cec::container, cec::envelope, cec::icon.

Container layout

flowchart LR
    h["Header, 0x70 bytes"] --> e["Extension headers"]
    e --> b["Body, game-defined"]
    b --> t["Trailer, 0x20 bytes: HMAC-SHA256 of the body"]
Loading

Header

Offset Size Field
0x00 2 Magic 60 60
0x04 4 Total size: header size + body size + 0x20
0x08 4 Header size: 0x70 + extension headers
0x0c 4 Body size
0x10 4 Title ID
0x20 8 Message ID
0x34 1 Flags
0x35 1 Send mode, 0 to 3
0x36 1 Unopened, set to 1 by a receiving console
0x37 1 New, set to 1 by a receiving console
0x48 12 Received time, CEC timestamp
0x54 12 Opened time, CEC timestamp
0x60 12 Created time, CEC timestamp
0x6c 1 Send count
0x6d 1 Forward count

Other bytes in the header are not interpreted by ctrpass and are kept as they are. The CEC timestamp format is given on Exchange Objects.

ctrpass treats a container as well formed when:

Check Rule
Total size Between 0x70 + 4 + 0x20 and 0x19000
Body size Nonzero, a multiple of 4, at most 0x18000
Header size At least 0x70, a multiple of 4
Sizes Header + body + trailer equals the total
Title ID Nonzero
Send mode Below 4
Counts Send count and forward count are not both above 1
Extension headers Fit inside the header size, at most 16, none of type 0

A new container built by ctrpass has send count 0xff and forward count 1.

Extension headers

Extension headers fill the space between offset 0x70 and the header size. Each one is:

Offset Size Field
0 4 Type, nonzero
4 4 Data size
8 n Data, padded with zeros to a multiple of 4

Known types:

Type Contents
1 Service record the title is offered with (format on Discovery)
2 Icon, 40 × 40 RGB565, 0xc80 bytes
4 Info text: UTF-16LE, ending in a zero unit, shown with the message

The service record in type 1 is what a console advertises for that title while it has this message to send.

Body

The body format belongs to the game. ctrpass reads and builds the bodies of games it has a plugin for, such as Mii Plaza (see Mii Plaza Messages). Other titles' bodies are carried unchanged.

Trailer and signature

The trailer is HMAC-SHA256(key = the title's 32-byte signing key, data = body). Only the body is signed. The header, including the message ID, is not covered, so a sender may change the message ID without signing again. ctrpass gives each message a fresh random message ID every time it offers it.

The signing key for each title is kept in that title's MBoxInfo____ file (see CEC Message Boxes and Keys). A receiver with the key can check the trailer. ctrpass refuses to store a received message whose trailer does not match the key it holds for the title. Without a key it stores the message unchecked.

Icons

Icons are square RGB565 images stored as 8 × 8 tiles. Tiles are in row-major order. Inside a tile, pixel i (0-63) sits at:

x = bit0(i) | bit2(i) << 1 | bit4(i) << 2
y = bit1(i) | bit3(i) << 1 | bit5(i) << 2

Each pixel is a little-endian u16: red in bits 11-15, green in bits 5-10, blue in bits 0-4. A size × size icon is size × size × 2 bytes.

Where Size
Container extension header 2 40 × 40
Mii Plaza featured software, small 24 × 24
Mii Plaza featured software, large 48 × 48

Envelopes

An envelope holds one or more containers of a single title. It is what travels over the link after the message list.

Offset Size Field
0x00 2 Magic 61 61 (aa)
0x02 2 Zero
0x04 4 Total envelope length, including this header
0x08 4 Title ID
0x0c 4 Zero
0x10 4 Number of containers
0x14 ... Containers, back to back
flowchart LR
    eh["Envelope header, 0x14"] --> c1["Container 1"]
    c1 --> c2["Container 2"]
    c2 --> cn["..."]
Loading

Rules ctrpass applies when splitting an envelope:

  • The total length matches the bytes present and is at most 1 MiB.
  • The container count is between 1 and 64.
  • Each container's total size is read from its header and must fit in what is left.
  • Every container has the envelope's title.
  • No bytes are left after the last container.

Message identity

Field Use
Title ID Which game's box the message belongs to
Message ID Names the message. Consoles and ctrpass derive the file name from it.
Send mode Decides how the title pairs (see Discovery) and, for mode 0, whether a received message is kept
Created time ctrpass sends a title's outbox messages in order of creation time, then message ID

Clone this wiki locally