Difference between revisions of "APT:Unwrap"

From 3dbrew
Jump to navigation Jump to search
m
Line 9: Line 9:
 
|-
 
|-
 
| 1
 
| 1
| Output buffer size
+
| Output Size
 
|-
 
|-
 
| 2
 
| 2
| Input buffer size
+
| Input Size
 
|-
 
|-
 
| 3
 
| 3
| Block size
+
| Block Size
 
|-
 
|-
 
| 4
 
| 4
| Nonce size, size 12 is used if this is >12.
+
| Nonce Size (capped to 12)
 
|-
 
|-
 
| 5
 
| 5
| (inputbufsize<<4) <nowiki>|</nowiki> 10
+
| (Input Size << 4) <nowiki>|</nowiki> 0xA
 
|-
 
|-
 
| 6
 
| 6
| Input encrypted data buffer ptr
+
| void*, Input
 
|-
 
|-
 
| 7
 
| 7
| (outputbufsize<<4) <nowiki>|</nowiki> 12
+
| (Output Size << 4) <nowiki>|</nowiki> 0xC
 
|-
 
|-
 
| 8
 
| 8
| Output cleartext data buffer ptr
+
| void*, Output
 
|}
 
|}
  

Revision as of 04:28, 22 November 2015

Request

Index Word Description
0 Header code [0x00470104]
1 Output Size
2 Input Size
3 Block Size
4 Nonce Size (capped to 12)
5 (Input Size << 4) | 0xA
6 void*, Input
7 (Output Size << 4) | 0xC
8 void*, Output

Response

Index Word Description
0 Header code
1 Result code

Description

This decrypts 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+0 with the noncesize is copied to this nonce buffer. NS then uses PS:EncryptSignDecryptVerifyAesCcm with keytype2 and with the above nonce buffer, where the inputptr is inputbuf+noncesize, outputptr is outputbuf+0, and size is inputbuffersize - noncesize - 16.

After decryption, NS copies the data at outbuf+blocksize to outbuf+blocksize+noncesize, with size inputbuffersize-blocksize-16. NS then copies the nonce from inputbuf+0 with the noncesize, to outbuf+blocksize.