mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-19 09:19:05 +02:00
Update the naming of functions called by SavedataParam::EncryptData. Thanks Linblow, and Nemo for the reminder
This commit is contained in:
1 parent
3f583ff5ab
commit
ecff4d03ee
3 files changed
+36
-36
No files matched your search
@@ -941,28 +941,28 @@ int SavedataParam::EncryptData(unsigned int mode,
|
||||
memset(data, 0, 0x10);
|
||||
|
||||
/* Build the 0x10-byte IV and setup encryption */
|
||||
if (sceSdCreateList_(ctx2, mode, 1, data, cryptkey) < 0)
|
||||
if (sceSdCipherInit(ctx2, mode, 1, data, cryptkey) < 0)
|
||||
return -1;
|
||||
if (sceSdSetIndex_(ctx1, mode) < 0)
|
||||
if (sceSdMacInit(ctx1, mode) < 0)
|
||||
return -2;
|
||||
if (sceSdRemoveValue_(ctx1, data, 0x10) < 0)
|
||||
if (sceSdMacUpdate(ctx1, data, 0x10) < 0)
|
||||
return -3;
|
||||
if (sceSdSetMember_(ctx2, data + 0x10, *alignedLen) < 0)
|
||||
if (sceSdCipherUpdate(ctx2, data + 0x10, *alignedLen) < 0)
|
||||
return -4;
|
||||
|
||||
/* Clear any extra bytes left from the previous steps */
|
||||
memset(data + 0x10 + *dataLen, 0, *alignedLen - *dataLen);
|
||||
|
||||
/* Encrypt the data */
|
||||
if (sceSdRemoveValue_(ctx1, data + 0x10, *alignedLen) < 0)
|
||||
if (sceSdMacUpdate(ctx1, data + 0x10, *alignedLen) < 0)
|
||||
return -5;
|
||||
|
||||
/* Verify encryption */
|
||||
if (sceSdCleanList_(ctx2) < 0)
|
||||
if (sceSdCipherFinal(ctx2) < 0)
|
||||
return -6;
|
||||
|
||||
/* Build the file hash from this PSP */
|
||||
if (sceSdGetLastIndex_(ctx1, hash, cryptkey) < 0)
|
||||
if (sceSdMacFinal(ctx1, hash, cryptkey) < 0)
|
||||
return -7;
|
||||
|
||||
/* Adjust sizes to account for IV */
|
||||
@@ -985,24 +985,24 @@ int SavedataParam::DecryptData(unsigned int mode, unsigned char *data, int *data
|
||||
*alignedLen -= 0x10;
|
||||
|
||||
/* Perform the magic */
|
||||
if (sceSdSetIndex_(ctx1, mode) < 0)
|
||||
if (sceSdMacInit(ctx1, mode) < 0)
|
||||
return -2;
|
||||
if (sceSdCreateList_(ctx2, mode, 2, data, cryptkey) < 0)
|
||||
if (sceSdCipherInit(ctx2, mode, 2, data, cryptkey) < 0)
|
||||
return -3;
|
||||
if (sceSdRemoveValue_(ctx1, data, 0x10) < 0)
|
||||
if (sceSdMacUpdate(ctx1, data, 0x10) < 0)
|
||||
return -4;
|
||||
if (sceSdRemoveValue_(ctx1, data + 0x10, *alignedLen) < 0)
|
||||
if (sceSdMacUpdate(ctx1, data + 0x10, *alignedLen) < 0)
|
||||
return -5;
|
||||
if (sceSdSetMember_(ctx2, data + 0x10, *alignedLen) < 0)
|
||||
if (sceSdCipherUpdate(ctx2, data + 0x10, *alignedLen) < 0)
|
||||
return -6;
|
||||
|
||||
/* Verify that it decrypted correctly */
|
||||
if (sceSdCleanList_(ctx2) < 0)
|
||||
if (sceSdCipherFinal(ctx2) < 0)
|
||||
return -7;
|
||||
|
||||
if (expectedHash) {
|
||||
u8 hash[16];
|
||||
if (sceSdGetLastIndex_(ctx1, hash, cryptkey) < 0)
|
||||
if (sceSdMacFinal(ctx1, hash, cryptkey) < 0)
|
||||
return -7;
|
||||
if (memcmp(hash, expectedHash, sizeof(hash)) != 0)
|
||||
return -8;
|
||||
@@ -1077,11 +1077,11 @@ int SavedataParam::BuildHash(uint8_t *output,
|
||||
memset(output, 0, 0x10);
|
||||
|
||||
/* Perform the magic */
|
||||
if (sceSdSetIndex_(ctx1, mode & 0xFF) < 0)
|
||||
if (sceSdMacInit(ctx1, mode & 0xFF) < 0)
|
||||
return -1;
|
||||
if (sceSdRemoveValue_(ctx1, data, alignedLen) < 0)
|
||||
if (sceSdMacUpdate(ctx1, data, alignedLen) < 0)
|
||||
return -2;
|
||||
if (sceSdGetLastIndex_(ctx1, output, cryptkey) < 0)
|
||||
if (sceSdMacFinal(ctx1, output, cryptkey) < 0)
|
||||
{
|
||||
// Got here since Kirk CMD5 missing, return random value;
|
||||
memset(output,0x1,0x10);
|
||||
|
||||
Reference in new issue
Block a user