Finish RpCrypt for PS5 Regist

This commit is contained in:
Florian Märkl 2020-12-11 18:35:49 +01:00
parent 21ef8fa018
commit 20a7e9d123
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
4 changed files with 246 additions and 71 deletions

View file

@ -23,11 +23,11 @@ typedef struct chiaki_rpcrypt_t
CHIAKI_EXPORT void chiaki_rpcrypt_bright_ambassador(ChiakiTarget target, uint8_t *bright, uint8_t *ambassador, const uint8_t *nonce, const uint8_t *morning);
CHIAKI_EXPORT void chiaki_rpcrypt_aeropause_ps4_pre10(uint8_t *aeropause, const uint8_t *ambassador);
CHIAKI_EXPORT void chiaki_rpcrypt_aeropause(size_t key_1_off, uint8_t *aeropause, const uint8_t *ambassador);
CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_aeropause(ChiakiTarget target, size_t key_1_off, uint8_t *aeropause, const uint8_t *ambassador);
CHIAKI_EXPORT void chiaki_rpcrypt_init_auth(ChiakiRPCrypt *rpcrypt, ChiakiTarget target, const uint8_t *nonce, const uint8_t *morning);
CHIAKI_EXPORT void chiaki_rpcrypt_init_regist_ps4_pre10(ChiakiRPCrypt *rpcrypt, const uint8_t *ambassador, uint32_t pin);
CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_init_regist(ChiakiRPCrypt *rpcrypt, const uint8_t *ambassador, size_t key_0_off, uint32_t pin);
CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_init_regist(ChiakiRPCrypt *rpcrypt, ChiakiTarget target, const uint8_t *ambassador, size_t key_0_off, uint32_t pin);
CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_generate_iv(ChiakiRPCrypt *rpcrypt, uint8_t *iv, uint64_t counter);
CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_encrypt(ChiakiRPCrypt *rpcrypt, uint64_t counter, const uint8_t *in, uint8_t *out, size_t sz);
CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_decrypt(ChiakiRPCrypt *rpcrypt, uint64_t counter, const uint8_t *in, uint8_t *out, size_t sz);

View file

@ -178,9 +178,13 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_regist_request_payload_format(ChiakiTarget
{
size_t key_0_off = buf[0x18D] & 0x1F;
size_t key_1_off = buf[0] >> 3;
chiaki_rpcrypt_init_regist(crypt, ambassador, key_0_off, pin);
ChiakiErrorCode err = chiaki_rpcrypt_init_regist(crypt, target, ambassador, key_0_off, pin);
if(err != CHIAKI_ERR_SUCCESS)
return err;
uint8_t aeropause[0x10];
chiaki_rpcrypt_aeropause(key_1_off, aeropause, crypt->ambassador);
err = chiaki_rpcrypt_aeropause(target, key_1_off, aeropause, crypt->ambassador);
if(err != CHIAKI_ERR_SUCCESS)
return err;
memcpy(buf + 0xc7, aeropause + 8, 8);
memcpy(buf + 0x191, aeropause, 8);
psn_online_id = NULL; // don't need this

View file

@ -813,9 +813,9 @@ CHIAKI_EXPORT void chiaki_rpcrypt_aeropause_ps4_pre10(uint8_t *aeropause, const
}
}
CHIAKI_EXPORT void chiaki_rpcrypt_aeropause(size_t key_1_off, uint8_t *aeropause, const uint8_t *ambassador)
CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_aeropause(ChiakiTarget target, size_t key_1_off, uint8_t *aeropause, const uint8_t *ambassador)
{
const uint8_t keys_1[] = {
static const uint8_t ps4_keys_1[] = {
0xc8, 0x48, 0xc2, 0xb4, 0x08, 0xeb, 0x88, 0xf7, 0x5f, 0x4a,
0x09, 0x2d, 0x59, 0x1f, 0x09, 0xcd, 0x1c, 0x18, 0xf4, 0x7a,
0x28, 0x4a, 0x96, 0x6d, 0xb3, 0x59, 0x71, 0x53, 0x75, 0x7e,
@ -870,11 +870,73 @@ CHIAKI_EXPORT void chiaki_rpcrypt_aeropause(size_t key_1_off, uint8_t *aeropause
0x63, 0x27
};
static const uint8_t ps5_keys_1[512] = {
0x79, 0x4d, 0x78, 0x30, 0xfe, 0x10, 0x52, 0x4c, 0xa8, 0x90,
0x5b, 0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0xa2, 0x4f, 0x13, 0x97, 0x78, 0x27, 0xf0, 0x48, 0xc0, 0xa5,
0xab, 0x83, 0x01, 0x05, 0xd0, 0x12, 0xd7, 0x1e, 0x12, 0x3a,
0x4e, 0x98, 0x77, 0xae, 0xba, 0xb1, 0x4e, 0xb5, 0x3b, 0x59,
0xca, 0x6d, 0xa5, 0x11, 0x80, 0x91, 0x9c, 0x07, 0x69, 0x59,
0x5a, 0x53, 0x70, 0x7c, 0x95, 0x97, 0x11, 0x6d, 0x66, 0x8d,
0xa3, 0xbd, 0xbb, 0x2d, 0xb0, 0xbf, 0x9b, 0x10, 0xcb, 0xc7,
0x0f, 0x5b, 0x7e, 0x67, 0xe2, 0xb0, 0x4b, 0xba, 0x10, 0x12,
0xb9, 0xbc, 0x97, 0xfd, 0x48, 0xe4, 0x8a, 0xc1, 0x0f, 0xa1,
0x30, 0x9d, 0x56, 0x20, 0x24, 0x1a, 0x7d, 0x5b, 0xa0, 0xb4,
0xbe, 0x9d, 0x38, 0x4f, 0xb4, 0x56, 0xa8, 0x4d, 0x13, 0x7c,
0x44, 0xe8, 0x84, 0x97, 0xeb, 0x78, 0x2c, 0x52, 0x85, 0xe4,
0xa2, 0xf6, 0xf3, 0xd9, 0x71, 0x9e, 0xee, 0xb8, 0x11, 0x47,
0xfb, 0xa9, 0x1b, 0xc7, 0x40, 0xc6, 0xe1, 0x19, 0x6d, 0x50,
0xa1, 0x2a
};
if(target < CHIAKI_TARGET_PS4_10)
return CHIAKI_ERR_INVALID_DATA;
const uint8_t *keys_1 = chiaki_target_is_ps5(target) ? ps5_keys_1 : ps4_keys_1;
uint8_t wurzelbert = chiaki_target_is_ps5(target) ? -0x2d : 0x29;
for(size_t i=0; i<CHIAKI_RPCRYPT_KEY_SIZE; i++)
{
uint8_t k = keys_1[i*0x20 + key_1_off];
aeropause[i] = (ambassador[i] ^ k) + 0x29 + (uint8_t)i;
aeropause[i] = (ambassador[i] ^ k) + wurzelbert + (uint8_t)i;
}
return CHIAKI_ERR_SUCCESS;
}
CHIAKI_EXPORT void chiaki_rpcrypt_init_auth(ChiakiRPCrypt *rpcrypt, ChiakiTarget target, const uint8_t *nonce, const uint8_t *morning)
@ -896,68 +958,126 @@ CHIAKI_EXPORT void chiaki_rpcrypt_init_regist_ps4_pre10(ChiakiRPCrypt *rpcrypt,
rpcrypt->bright[3] ^= (uint8_t)((pin >> 0x00) & 0xff);
}
CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_init_regist(ChiakiRPCrypt *rpcrypt, const uint8_t *ambassador, size_t key_0_off, uint32_t pin)
CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_init_regist(ChiakiRPCrypt *rpcrypt, ChiakiTarget target, const uint8_t *ambassador, size_t key_0_off, uint32_t pin)
{
static const uint8_t keys_0[] = {
0xbe, 0xce, 0x5d, 0xf0, 0xc1, 0x7d, 0xb5, 0xd0, 0xcb, 0x30,
0x13, 0x5d, 0xaa, 0x56, 0x23, 0xfb, 0xc4, 0xbc, 0xf1, 0x8f,
0x38, 0x57, 0xfb, 0xd4, 0xd4, 0x3f, 0x26, 0x38, 0xb5, 0xce,
0xed, 0x6a, 0x21, 0xbc, 0x38, 0xd0, 0x1e, 0x68, 0xcc, 0x7b,
0x45, 0xd1, 0xbe, 0x42, 0x1a, 0x08, 0xaa, 0x16, 0xfd, 0xb0,
0xc0, 0xf4, 0xda, 0x35, 0xe9, 0x12, 0xfd, 0x21, 0x07, 0x48,
0x34, 0xc1, 0xfc, 0x9f, 0x8c, 0xb6, 0xcb, 0x5d, 0xb2, 0x9c,
0x84, 0xe0, 0x1a, 0xfa, 0xa0, 0xc7, 0xeb, 0x3a, 0x93, 0xb3,
0xb3, 0xf1, 0x15, 0xaf, 0x13, 0xbd, 0x21, 0xab, 0xea, 0x5b,
0x80, 0x50, 0x6b, 0x31, 0x1d, 0x7c, 0x1d, 0x40, 0xba, 0x3c,
0x56, 0x0e, 0xe7, 0x94, 0x3a, 0x5b, 0xa1, 0x40, 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11, 0x57, 0x0c, 0x95, 0xf1, 0xaf, 0xd7, 0x34, 0x80,
0xf4, 0xeb, 0x9b, 0x50, 0xe6, 0x6a, 0x5d, 0xea, 0xce, 0x0c,
0x85, 0x4e, 0xc5, 0x5b, 0x93, 0x44, 0xc4, 0x24, 0x98, 0x80,
0xfc, 0xf7, 0x72, 0x9c, 0x31, 0x0b, 0xee, 0x89, 0x67, 0xb3,
0xa2, 0x69, 0x4f, 0xb3, 0x79, 0x5a, 0x14, 0x02, 0x70, 0xed,
0x50, 0x13, 0x75, 0x00, 0x6a, 0xf3, 0xc6, 0x05, 0x1a, 0x00,
0x33, 0x34, 0xf5, 0xac, 0x9e, 0x04, 0xdb, 0xc2, 0x00, 0xb0,
0x1b, 0xc4, 0xf3, 0x97, 0x9d, 0x7f, 0xbe, 0xb8, 0x23, 0x8d,
0x99, 0xe7, 0xcb, 0x74, 0x37, 0x4c, 0x57, 0xec, 0xd2, 0x69,
0x49, 0x46, 0x75, 0x74, 0xaf, 0x51, 0x40, 0xa4, 0x11, 0x7b,
0xb3, 0x2f, 0x51, 0xda, 0xe2, 0xef, 0x33, 0x73, 0x12, 0x18,
0x25, 0x39, 0x03, 0x09, 0xca, 0x49, 0xdc, 0x8e, 0xf1, 0x94,
0xd7, 0x80, 0x17, 0x9e, 0x87, 0x46, 0xc1, 0x04, 0x78, 0xd1,
0xe5, 0x3d, 0x25, 0x88, 0xec, 0x72, 0x3a, 0x28, 0x41, 0x68,
0x14, 0x6e, 0x10, 0xe4, 0xc9, 0x57, 0x75, 0x90, 0xfe, 0x22,
0x1a, 0x63, 0x8e, 0xf4, 0xb8, 0x8d, 0x1a, 0x36, 0xfd, 0xb6,
0xcb, 0x72, 0xc2, 0x97, 0x52, 0x9f, 0x91, 0x72, 0x1b, 0x75,
0x57, 0x90, 0x3b, 0xfd, 0x5a, 0x93, 0x8c, 0xdb, 0xfc, 0xa3,
0x03, 0xdf
};
static const uint8_t ps5_keys_0[512] = {
0x24, 0xd8, 0xc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x8d, 0x5b, 0x25, 0x54, 0xe0, 0xc4, 0x4f, 0xa0, 0xfa,
0x99, 0x8d, 0x6d, 0x7a, 0x64, 0xb1, 0xa9, 0x5d, 0xa4, 0xf9,
0xf5, 0x22, 0xeb, 0x9a, 0xf4, 0xa8, 0x7a, 0x78, 0x4b, 0x7f,
0xe2, 0x8b, 0x04, 0x50, 0x43, 0x7d, 0x26, 0x2d, 0x19, 0x98,
0x38, 0x6a, 0x4f, 0x2d, 0x30, 0x15, 0x2e, 0x4f, 0xcd, 0xb9,
0xce, 0x9e, 0x8d, 0x12, 0xc9, 0xfe, 0x33, 0x8b, 0x84, 0xce,
0x5b, 0x40, 0xe3, 0x7f, 0x72, 0x6d, 0x6c, 0x8a, 0x6a, 0x9e,
0x54, 0xf1, 0xe3, 0x64, 0x5d, 0x6e, 0x7f, 0xac, 0x1a, 0xe7,
0xf7, 0xfa, 0x00, 0x22, 0xed, 0x2b, 0x23, 0xfa, 0x58, 0xc5,
0xeb, 0x44, 0x92, 0x5d, 0xcc, 0xaa, 0x82, 0x9f, 0x23, 0xfb,
0xa6, 0xc9, 0x65, 0x2a, 0xe0, 0x79, 0x12, 0x65, 0x2c, 0x34,
0xc5, 0x23, 0x16, 0xc9, 0xcc, 0x05, 0x30, 0xf3, 0x96, 0x0b,
0x90, 0x67, 0x1a, 0xa7, 0x69, 0x4c, 0x3e, 0x43, 0x24, 0x9d,
0x4e, 0x68, 0xbd, 0x8b, 0x75, 0x6e, 0x9d, 0x07, 0x6f, 0x1a,
0x6a, 0xba
};
if(target < CHIAKI_TARGET_PS4_10)
return CHIAKI_ERR_INVALID_DATA;
const uint8_t *keys_0 = chiaki_target_is_ps5(target) ? ps5_keys_0 : ps4_keys_0;
if(key_0_off >= 0x20)
return CHIAKI_ERR_INVALID_DATA;
rpcrypt->target = CHIAKI_TARGET_PS4_10; // representative, might not be the actual version
rpcrypt->target = target;
memcpy(rpcrypt->ambassador, ambassador, sizeof(rpcrypt->ambassador));
for(size_t i=0; i<CHIAKI_RPCRYPT_KEY_SIZE; i++)

View file

@ -75,7 +75,7 @@ static MunitResult test_iv_ps4_pre10(const MunitParameter params[], void *user)
return MUNIT_OK;
}
static MunitResult test_iv_regist(const MunitParameter params[], void *user)
static MunitResult test_iv_regist_ps4(const MunitParameter params[], void *user)
{
static const uint8_t ambassador[] = { 0x3e, 0x7e, 0x7a, 0x82, 0x59, 0x73, 0xad, 0xab, 0x2f, 0x69, 0x43, 0x46, 0xbd, 0x44, 0xda, 0xb5 };
static const uint8_t iv_expected[] = { 0xac, 0x48, 0x99, 0x77, 0xf9, 0x2a, 0xc5, 0x5b, 0xb9, 0x09, 0x3c, 0x33, 0xb6, 0x11, 0x3c, 0x46 };
@ -83,7 +83,7 @@ static MunitResult test_iv_regist(const MunitParameter params[], void *user)
ChiakiRPCrypt rpcrypt;
ChiakiErrorCode err;
chiaki_rpcrypt_init_regist(&rpcrypt, ambassador, 0, 0);
chiaki_rpcrypt_init_regist(&rpcrypt, CHIAKI_TARGET_PS4_10, ambassador, 0, 0);
uint8_t iv[CHIAKI_RPCRYPT_KEY_SIZE];
@ -95,7 +95,27 @@ static MunitResult test_iv_regist(const MunitParameter params[], void *user)
return MUNIT_OK;
}
static MunitResult test_bright_regist(const MunitParameter params[], void *user)
static MunitResult test_iv_regist_ps5(const MunitParameter params[], void *user)
{
static const uint8_t ambassador[] = { 0x3e, 0x7e, 0x7a, 0x82, 0x59, 0x73, 0xad, 0xab, 0x2f, 0x69, 0x43, 0x46, 0xbd, 0x44, 0xda, 0xb5 };
static const uint8_t iv_expected[] = { 0x90, 0x44, 0x40, 0x82, 0x73, 0xf8, 0x04, 0x4d, 0xca, 0x76, 0x7b, 0x5a, 0x16, 0x39, 0x4d, 0x64 };
ChiakiRPCrypt rpcrypt;
ChiakiErrorCode err;
chiaki_rpcrypt_init_regist(&rpcrypt, CHIAKI_TARGET_PS5_1, ambassador, 0, 0);
uint8_t iv[CHIAKI_RPCRYPT_KEY_SIZE];
err = chiaki_rpcrypt_generate_iv(&rpcrypt, iv, 0);
if(err != CHIAKI_ERR_SUCCESS)
return MUNIT_ERROR;
munit_assert_memory_equal(CHIAKI_RPCRYPT_KEY_SIZE, iv, iv_expected);
return MUNIT_OK;
}
static MunitResult test_bright_regist_ps4(const MunitParameter params[], void *user)
{
static const uint8_t ambassador[] = { 0xdc, 0xa1, 0xc8, 0x4d, 0xfe, 0x50, 0xd6, 0x57, 0x22, 0xda, 0x09, 0x65, 0x42, 0x31, 0xe7, 0xc2 };
static const uint8_t bright_expected[] = { 0xed, 0xfc, 0x1d, 0xc5, 0xa2, 0xfe, 0x2d, 0x7f, 0x09, 0x19, 0x85, 0x75, 0x33, 0x6c, 0x13, 0x16 };
@ -104,7 +124,22 @@ static MunitResult test_bright_regist(const MunitParameter params[], void *user)
ChiakiRPCrypt rpcrypt;
ChiakiErrorCode err;
chiaki_rpcrypt_init_regist(&rpcrypt, ambassador, key_0_off, 78703893);
chiaki_rpcrypt_init_regist(&rpcrypt, CHIAKI_TARGET_PS4_10, ambassador, key_0_off, 78703893);
munit_assert_memory_equal(CHIAKI_RPCRYPT_KEY_SIZE, rpcrypt.bright, bright_expected);
return MUNIT_OK;
}
static MunitResult test_bright_regist_ps5(const MunitParameter params[], void *user)
{
static const uint8_t ambassador[] = { 0xdc, 0xa1, 0xc8, 0x4d, 0xfe, 0x50, 0xd6, 0x57, 0x22, 0xda, 0x09, 0x65, 0x42, 0x31, 0xe7, 0xc2 };
static const uint8_t bright_expected[] = { 0xe2, 0x9d, 0x64, 0x4c, 0x14, 0x1b, 0x9d, 0x61, 0x74, 0x31, 0xa5, 0x6d, 0x34, 0xcf, 0xc1, 0x7f };
size_t key_0_off = 0x1e;
ChiakiRPCrypt rpcrypt;
ChiakiErrorCode err;
chiaki_rpcrypt_init_regist(&rpcrypt, CHIAKI_TARGET_PS5_1, ambassador, key_0_off, 78703893);
munit_assert_memory_equal(CHIAKI_RPCRYPT_KEY_SIZE, rpcrypt.bright, bright_expected);
return MUNIT_OK;
@ -225,16 +260,32 @@ MunitTest tests_rpcrypt[] = {
NULL
},
{
"/iv_regist",
test_iv_regist,
"/iv_regist_ps4",
test_iv_regist_ps4,
NULL,
NULL,
MUNIT_TEST_OPTION_NONE,
NULL
},
{
"/bright_regist",
test_bright_regist,
"/iv_regist_ps5",
test_iv_regist_ps5,
NULL,
NULL,
MUNIT_TEST_OPTION_NONE,
NULL
},
{
"/bright_regist_ps4",
test_bright_regist_ps4,
NULL,
NULL,
MUNIT_TEST_OPTION_NONE,
NULL
},
{
"/bright_regist_ps5",
test_bright_regist_ps5,
NULL,
NULL,
MUNIT_TEST_OPTION_NONE,