Skip to content

Commit

Permalink
Identify NpTicket platform based on signature identifier instead of i…
Browse files Browse the repository at this point in the history
…ssuer ID (#1062)

* Identify platform based on signature identifier instead of issuer id

* Use signature identifier to identify PS3

* Remove extra whitespace
  • Loading branch information
Slendy authored Sep 10, 2024
1 parent 917cccb commit 9030d64
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 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,13 +153,11 @@ private static bool ReadTicket(NPTicket npTicket, TicketReader reader)
return null;
}

// Production PSN Issuer ID: 0x100
// RPCN Issuer ID: 0x33333333
npTicket.Platform = npTicket.IssuerId switch
npTicket.Platform = npTicket.SignatureVerifier switch
{
0x100 => Platform.PS3,
0x33333333 => Platform.RPCS3,
0x74657374 => Platform.UnitTest,
PsnSignatureVerifier => Platform.PS3,
RpcnSignatureVerifier => Platform.RPCS3,
UnitTestSignatureVerifier => Platform.UnitTest,
_ => Platform.Unknown,
};

Expand Down

0 comments on commit 9030d64

Please sign in to comment.