Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int modifyFriendSeedAndSecInfo(int v1){
- DebugPrint("Setting");
- CFGI_Init();
- DebugPrint("SetLocalFriendCodeSeed\n");
- if (*(void*)0x1FF80014 & 1 ) goto LABEL_8; //If retail
- sub_124A6C(&psHandle, "ps:ps");
- v2 = nn::crypto::RsaKey::RsaKey(&keyHandle);
- if (R_SUCCEEDED(CFGI_VerifySigLocalFriendCodeSeed(v2))
- || R_SUCCEEDED(ret = CFGI_SetGetLocalFriendCodeSeedData(&FSeedData, 1))
- && (sub_12961C(&keyHandle, rsa_blob, 0x800u),
- sub_11E35C(&v52, &keyHandle, 0x208u, v4),
- psSignRsaSha256(&FSeedData, 0x10, &FSeedSigBuf, &v52),
- nn::crypto::RsaKey::Finalize(&keyHandle),
- R_SUCCEEDED(ret = CFGI_SetLocalFriendCodeSeedSignature(&FSeedSigBuf)))
- && R_SUCCEEDED(ret = CFGI_VerifySigLocalFriendCodeSeed(ret))
- && R_SUCCEEDED(ret = CFGI_DeleteCreateNANDLocalFriendCodeSeed())
- )
- {
- psHandleClose();
- LABEL_8:
- CFGI_Exit();
- DebugPrint("SetLocalFriendCodeSeed success.\n");
- ret = 0;
- }
- *(v1 + 28) = ret;
- if (R_FAILED(ret)
- {
- DebugPrint("Failed set local friend code seed. resulst = %08x\n", ret);
- return;
- }
- DebugPrint("SetSecureInfo\n", ret & 0x80000000);
- CFGI_Init();
- v5 = *(getRegionDataPtr() + 2);
- if (*(void*)0x1FF80014 & 1 ) goto LABEL_33;
- sub_124A6C(&psHandle, dword_140350);
- nn::crypto::RsaKey::RsaKey(&keyHandle2);
- if (R_FAILED(CFGI_VerifySigSecureInfo())
- {
- LOWORD(keyHandle) = v5;
- sub_11F2B0();
- }
- else
- {
- v6 = CFGI_SecureInfoGetData(&keyHandle);
- if (R_FAILED(v6)) goto LABEL_34;
- LOBYTE(keyHandle) = v5;
- }
- sub_12961C(&keyHandle2, dword_1488A8, 0x800u);
- sub_11E35C(&v57, &keyHandle2, 0x208u, v7);
- psSignRsaSha256(&keyHandle, 17, &v58, &v57);
- nn::crypto::RsaKey::Finalize(&keyHandle2);
- if (R_SUCCEEDED(v6 = CFGI_SetSecureInfo(&keyHandle, &v58)))
- {
- if (R_SUCCEEDED(v6 = CFGI_VerifySigSecureInfo()))
- {
- if (R_SUCCEEDED(v6 = CFGI_DeleteCreateNANDSecureInfo(v6)))
- {
- psHandleClose();
- v8 = getRegionDataPtr();
- v9 = *(v8 + 4);
- LOBYTE(v49) = *(v8 + 4);
- if (R_SUCCEEDED(v6 = CFGI_SetConfigInfoBlk4(655362, &v49, 1)))
- {
- if (R_SUCCEEDED(v6 = CFGI_UpdateConfigNANDSavegame(v6)))
- {
- sub_124E50(1);
- if (R_SUCCEEDED(nn::cfg::nor::CTR::SetLanguage(v9))
- || R_SUCCEEDED(v6 = sub_1250AC(v5))
- && R_SUCCEEDED(v6 = nn::cfg::nor::CTR::SetLanguage(v9))
- )
- {
- CFGNOR_Exit();
- if ( *(getRegionDataPtr() + 3) == v5
- || (v49 = -1,
- _aeabi_memclr4(&v51, 0x800u),
- _aeabi_memclr4(&v55, 0x800u),
- v6 = CFGI_GetConfigInfoBlk8(&v50, 1, 1048578),
- !(v6 >> 31))
- && R_SUCCEEDED(v6 = CFGI_GetConfigInfoBlk8(&v49, 4, 720896))
- && (v10 = sub_12B9D4(v5),
- v50 = v10,
- v49 = v49 & 0xFFFFFF | (v10 << 24),
- R_SUCCEEDED(v6 = CFGI_SetConfigInfoBlk4(1048578, &v50, 1))
- )
- && R_SUCCEEDED(v6 = CFGI_SetConfigInfoBlk4(0xB0000, &v49, 4))
- && R_SUCCEEDED(v6 = CFGI_SetConfigInfoBlk4(0xB0001, &v51, 2048))
- && R_SUCCEEDED(v6 = CFGI_SetConfigInfoBlk4(0xB0002, &v55, 2048))
- && R_SUCCEEDED(v6 = CFGI_UpdateConfigNANDSavegame(v6)) )
- {
- LABEL_33:
- CFGI_Exit();
- DebugPrint("SetSecureInfo success.\n");
- v6 = 0;
- goto LABEL_34;
- }
- }
- }
- }
- }
- }
- }
- //Ommitted some code here
- }
- int psSignRsaSha256(int seedData, int sigSize, int sigBuff, int key)
- {
- int v6, v8;
- char hash;
- nn::crypto::CalculateSha256(&hash, seedData, sigSize);
- sub_11E35C(&v8, key, 0x208u, v6);
- return PS_SignRsaSha256(&hash, sigBuf, *(key + 0x200) / 8, &v8);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement