Skip to content

Commit

Permalink
Use signature identifier to identify PS3
Browse files Browse the repository at this point in the history
  • Loading branch information
Slendy committed Sep 10, 2024
1 parent 8787840 commit 4d879b1
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions ProjectLighthouse/Tickets/NPTicket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,13 @@ private static bool ReadTicket(NPTicket npTicket, TicketReader reader)

if (!ticketParser.ParseTicket()) return false;

// Create a uint in big endian
uint signatureIdentifier = (uint)(npTicket.TicketSignatureIdentifier[0] << 24 |
npTicket.TicketSignatureIdentifier[1] << 16 |
npTicket.TicketSignatureIdentifier[2] << 8 |
npTicket.TicketSignatureIdentifier[3]);

npTicket.SignatureVerifier = signatureIdentifier switch
npTicket.SignatureVerifier = npTicket.TicketSignatureIdentifier switch
{
0x5250434E => new RpcnSignatureVerifier(npTicket),
0x719F1D4A => new PsnSignatureVerifier(npTicket),
0x54455354 => new UnitTestSignatureVerifier(npTicket),
[0x71, 0x9F, 0x1D, 0x4A,] => new PsnSignatureVerifier(npTicket), // PSN LBP Signature Identifier
[0x52, 0x50, 0x43, 0x4E,] => new RpcnSignatureVerifier(npTicket), // 'RPCN' in ascii
[0x54, 0x45, 0x53, 0x54,] => new UnitTestSignatureVerifier(npTicket), // 'TEST' in ascii
_ => throw new ArgumentOutOfRangeException(nameof(npTicket),
signatureIdentifier,
npTicket.TicketSignatureIdentifier,
@"Invalid signature identifier"),
};

Expand Down Expand Up @@ -159,18 +153,12 @@ private static bool ReadTicket(NPTicket npTicket, TicketReader reader)
return null;
}

// Production PSN Issuer ID: 0x100
// The RPCN signature identifier is always 'RPCN' in ascii

npTicket.Platform = npTicket.TicketSignatureIdentifier switch
npTicket.Platform = npTicket.SignatureVerifier switch
{
[0x52, 0x50, 0x43, 0x4E,] => Platform.RPCS3, // 'RPCN' in ascii
[0x54, 0x45, 0x53, 0x54,] => Platform.UnitTest, // 'TEST' in ascii
_ => npTicket.IssuerId switch
{
0x100 => Platform.PS3,
_ => Platform.Unknown,
}
PsnSignatureVerifier => Platform.PS3,
RpcnSignatureVerifier => Platform.RPCS3,
UnitTestSignatureVerifier => Platform.UnitTest,
_ => Platform.Unknown,
};

if (npTicket.GameVersion == GameVersion.LittleBigPlanetVita) npTicket.Platform = Platform.Vita;
Expand Down

0 comments on commit 4d879b1

Please sign in to comment.