FRDU:GetMyApproachContext

From 3dbrew
Jump to navigation Jump to search

Request[edit]

Index Word Description
0
Header 0x00330000 Cmd 0x0033 Param 0 Xlat 0

Request Static Buffers[edit]

The handler for this IPC command expects the following 0x100-bytes after the beginning of the above command buffer:

Index Word Description


0 Descriptor for static buffer (id 0)
1 Output encrypted ApproachContext payload buffer

Response[edit]

Index Word Description
0
Header 0x00330042 Cmd 0x0033 Param 1 Xlat 2
1 Result code
2 Descriptor for static buffer (id 0)
3 Output encrypted ApproachContext payload buffer

Description[edit]

Creates an encrypted payload containing information that can be used to add this console as a friend locally. (See Approach Contexts for details)

First, the 0x1E0-sized ApproachContext structure is created and user's personal Mii is encrypted using APT:Wrap. If the user doesn't have a personal Mii yet, the 0x70-sized field in the approach context is set to all zeros.

The populated structure is then encrypted with AES-CCM using PS:EncryptSignDecryptVerifyAesCcm and keytype 8 (Keyslot 0x36), the nonce being the concatenated little-endian Principal ID and Friend Code of the console (total nonce size 12). The nonce is returned in plaintext at offset 0x4-0x10. Note that the ApproachContext is located at 0x10 and that is where the actually encrypted section begins. In other words, the AES-CCM encrypted section is located at offset 0x10 thru 0x1F0.