Difference between revisions of "APT:Wrap"
(Created page with "=Request= {| class="wikitable" border="1" |- ! Index Word ! Description |- | 0 | Header code [0x00460104] |- | 1 | Output buffer size |- | 2 | Input buffer size |- | 3 | Block ...") |
(rename a param and make a more intuitive description) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 9: | Line 9: | ||
|- | |- | ||
| 1 | | 1 | ||
− | | Output | + | | Output Size |
|- | |- | ||
| 2 | | 2 | ||
− | | Input | + | | Input Size |
|- | |- | ||
| 3 | | 3 | ||
− | | | + | | Nonce Offset |
|- | |- | ||
| 4 | | 4 | ||
− | | Nonce | + | | Nonce Size (capped to 12) |
|- | |- | ||
| 5 | | 5 | ||
− | | ( | + | | (Input Size << 4) <nowiki>|</nowiki> 0xA |
|- | |- | ||
| 6 | | 6 | ||
− | | Input | + | | void*, Input |
|- | |- | ||
| 7 | | 7 | ||
− | | ( | + | | (Output Size << 4) <nowiki>|</nowiki> 0xC |
|- | |- | ||
| 8 | | 8 | ||
− | | Output | + | | void*, Output |
|} | |} | ||
Line 47: | Line 47: | ||
=Description= | =Description= | ||
− | This encrypts the input data with [[PS:EncryptSignDecryptVerifyAesCcm|AES-CCM]] using keytype2. The 12-byte nonce buffer used by NS is cleared to all-zero, then the nonce from inputbuf+ | + | This encrypts the input data with [[PS:EncryptSignDecryptVerifyAesCcm|AES-CCM]] using keytype2, when the input noncesize is <12 the low 2-bits are cleared in the noncesize. The 12-byte nonce buffer used by NS is cleared to all-zero, then the nonce from inputbuf+nonceoffset with the noncesize is copied to this nonce buffer. NS then copies the data at inputbuf+0 to outbuf+noncesize, with the nonceoffset. |
− | NS then copies the data at inbuf+ | + | NS then copies the data at inbuf+nonceoffset+noncesize to outbuf+nonceoffset+noncesize, with size inputbuffersize-nonceoffset-noncesize. NS then uses [[PS:EncryptSignDecryptVerifyAesCcm]] with keytype2 and with the above nonce buffer, where the input/output buffer ptrs are outbuf+noncesize, with size nonceoffset+(inputbuffersize-nonceoffset-noncesize). NS then copies the the nonce from the nonce-buffer with the noncesize, to outbuf+0. |
+ | |||
+ | In other words, the nonce with noncesize located at nonceoffset in the input buffer is copied to the beginning of the output buffer. The rest of the input data are concatenated, encrypted via [[PS:EncryptSignDecryptVerifyAesCcm]] using the said nonce (padded or capped to 12 bytes), and then written to outbuf+noncesize. |
Latest revision as of 11:04, 30 December 2016
Request[edit]
Index Word | Description |
---|---|
0 | Header code [0x00460104] |
1 | Output Size |
2 | Input Size |
3 | Nonce Offset |
4 | Nonce Size (capped to 12) |
5 | (Input Size << 4) | 0xA |
6 | void*, Input |
7 | (Output Size << 4) | 0xC |
8 | void*, Output |
Response[edit]
Index Word | Description |
---|---|
0 | Header code |
1 | Result code |
Description[edit]
This encrypts the input data with AES-CCM using keytype2, when the input noncesize is <12 the low 2-bits are cleared in the noncesize. The 12-byte nonce buffer used by NS is cleared to all-zero, then the nonce from inputbuf+nonceoffset with the noncesize is copied to this nonce buffer. NS then copies the data at inputbuf+0 to outbuf+noncesize, with the nonceoffset.
NS then copies the data at inbuf+nonceoffset+noncesize to outbuf+nonceoffset+noncesize, with size inputbuffersize-nonceoffset-noncesize. NS then uses PS:EncryptSignDecryptVerifyAesCcm with keytype2 and with the above nonce buffer, where the input/output buffer ptrs are outbuf+noncesize, with size nonceoffset+(inputbuffersize-nonceoffset-noncesize). NS then copies the the nonce from the nonce-buffer with the noncesize, to outbuf+0.
In other words, the nonce with noncesize located at nonceoffset in the input buffer is copied to the beginning of the output buffer. The rest of the input data are concatenated, encrypted via PS:EncryptSignDecryptVerifyAesCcm using the said nonce (padded or capped to 12 bytes), and then written to outbuf+noncesize.