PSVIMG: Difference between revisions
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
# If making a PSVMD file, use the deflate algorithm to compress. | # If making a PSVMD file, use the deflate algorithm to compress. | ||
# Generate a random nonce for the first 0x10 bytes using the RndNumber syscall. | # Generate a random nonce for the first 0x10 bytes using the RndNumber syscall. | ||
# Generate a unique session AES256 key using a secret phrase and the | # Generate a unique session AES256 key using a secret phrase and the PSN account id of the PSVita. | ||
# generate a SHA256 hash of the plaintext every 0x8000 bytes and insert the hash into the filestream. | # generate a SHA256 hash of the plaintext every 0x8000 bytes and insert the hash into the filestream. | ||
# Encrypt the stream data using EncDecKeygen syscall from [[SceSblDmac5Mgr]] with the nonce as the header and the AES256 session key. | # Encrypt the stream data using EncDecKeygen syscall from [[SceSblDmac5Mgr]] with the nonce as the header and the AES256 session key. | ||
Line 13: | Line 13: | ||
=== Secrets === | === Secrets === | ||
If you look at the 16 character hex directory name included in part of the backup path, that is your | If you look at the 16 character hex directory name included in part of the backup path, that is your PSN account id. | ||
The AES256 session key is calculated by doing a SHA256 hash of the 8 byte hex binary representation of the | The AES256 session key is calculated by doing a SHA256 hash of the 8 byte hex binary representation of the PSN account id followed by the secret phrase: | ||
<code> | <code> | ||
Sri Jayewardenepura Kotte | Sri Jayewardenepura Kotte |
Revision as of 20:53, 10 February 2017
PSVIMG files are encrypted files generated by CMA in backing up and restoring data from the Vita.
Generating PSVIMG
When CMA is used to backup system, game, or savedata from the Vita to a PC or PS3, the following algorithm is used:
- Using a tar-like structure, stream all of the file data into a file.
- If making a PSVMD file, use the deflate algorithm to compress.
- Generate a random nonce for the first 0x10 bytes using the RndNumber syscall.
- Generate a unique session AES256 key using a secret phrase and the PSN account id of the PSVita.
- generate a SHA256 hash of the plaintext every 0x8000 bytes and insert the hash into the filestream.
- Encrypt the stream data using EncDecKeygen syscall from SceSblDmac5Mgr with the nonce as the header and the AES256 session key.
- Transmit to PC or PS3.
Secrets
If you look at the 16 character hex directory name included in part of the backup path, that is your PSN account id.
The AES256 session key is calculated by doing a SHA256 hash of the 8 byte hex binary representation of the PSN account id followed by the secret phrase:
Sri Jayewardenepura Kotte
Example
Buffer:
01 23 45 67 89 AB CD EF 53 72 69 20 4A 61 79 65 77 61 72 64 65 6E 65 70 75 72 61 20 4B 6F 74 74 65
SHA256 of this buffer generates the AES256 session key of:
02EAAB5A00EC9D4207E8B1F53F8A2F3F91F1A73AAFDD2A81CCFEE3E83E5B101A
Unfortunately, this is dependent on the PSVita for executing using the EncDecKeygen function. The AES256 key is altered inside the F00D Processor in some way currently unknown. Upon decryption, the session key is sent to F00D and an assigned slot. When the HW crypto engine is invoked to perform the decryption, it is given the slot number. Presumably, the crypto engine talks directly with F00D to use the derived key.