pkmn-classic-framework icon indicating copy to clipboard operation
pkmn-classic-framework copied to clipboard

Research/Implement Pokémon validation signatures (required for Random Matchup)

Open InternalLoss opened this issue 2 years ago • 12 comments

It seems Random Matchup fails currently after Wiimmfi fixed the matchmaking error, which @mm201 and I theorised is likely due to the signature not being valid (and confirmed the signature is shared to the other peer). As such, this is likely to be a blocking issue for Random Matchup Free mode (and presumably Rating Mode? @zurgeg may now be able to check since Wiimmfi's side of the communication works without issue).

Hopefully it's not an asymmetric key we don't have, or if it is we can make the DS accept our own signatures..

InternalLoss avatar Oct 04 '22 10:10 InternalLoss

For reference, shutter/Jon's Gen6 server can be found here: https://github.com/PretendoNetwork/PKHaX (they're also sending a zeroed out signature)

Apparently Gen6 is using an RSA-256 signature whose public key gets downloaded once from the server and saved. I don't think Gen5 downloads a key, or, at least, I've never seen any failed requests for it in my logs, but it's something we should test for. (test with a virgin savefile and see if it hits any unique endpoints)

mm201 avatar Oct 04 '22 14:10 mm201

I don't think Gen5 downloads a key,

I'd hope not, since there'd likely be no way to blank (and re-download) that key, but then that might mean its static..

InternalLoss avatar Oct 04 '22 17:10 InternalLoss

It seems Random Matchup fails currently after Wiimmfi fixed the matchmaking error, which @mm201 and I theorised is likely due to the signature not being valid (and confirmed the signature is shared to the other peer). As such, this is likely to be a blocking issue for Random Matchup Free mode (and presumably Rating Mode? @zurgeg may now be able to check since Wiimmfi's side of the communication works without issue).

Hopefully it's not an asymmetric key we don't have, or if it is we can make the DS accept our own signatures..

I'll try it in a minute.

zurgeg avatar Oct 04 '22 19:10 zurgeg

Just tried. Looks like A) NoSSL is banned on Wiimmfi or B) I was autobanned for some reason or C) I was banned by a mod or D) melonDS is banned. Whatever it is, I can't connect to NAS with 23917. Which is also what happens when you're banned so...

zurgeg avatar Oct 04 '22 19:10 zurgeg

melonDS is banned

you've not been banned, its probably just denied for some reason. Can you DM me your FC on Discord, and I'll ask someone?

InternalLoss avatar Oct 04 '22 20:10 InternalLoss

melonDS is banned

you've not been banned, its probably just denied for some reason. Can you DM me your FC on Discord, and I'll ask someone?

Turns out I was using the wrong melonDS install.

zurgeg avatar Oct 04 '22 20:10 zurgeg

Oops ;)

Let us know how it goes!

InternalLoss avatar Oct 05 '22 04:10 InternalLoss

@InternalLoss @mm201 Can confirm. PGL side is working. So yes, this does affect rating mode

zurgeg avatar Oct 05 '22 15:10 zurgeg

Can confirm. PGL side is working. So yes, this does affect rating mode So even rating mode is affected by this? Ok, time to really figure out if it is truly the signature that's the issue..

InternalLoss avatar Oct 05 '22 15:10 InternalLoss

Can confirm. PGL side is working. So yes, this does affect rating mode So even rating mode is affected by this? Ok, time to really figure out if it is truly the signature that's the issue..

@InternalLoss You could always try the "nop everything relating to whatever isn't working and hope it works" strategy

(Sadly melonDS has no support for debugging)

zurgeg avatar Oct 05 '22 15:10 zurgeg

What we know about this:

  • Signature algorithm used is SHA1withRSA with a key size of 1024 bits
  • Signature is over the entire encrypted party data sent to /pokemon/validate
  • RSA public key modulus is unfortunately hardcoded and is: D987D465E4EEAE582D017315F00EA3400C510B2E51E15D77D03ADCB25C830171F569FBD26A78DC69694DDD2CEFA4A9AAD1A0D9AA99705BF08038F57764EEA5AB7D6A3838678AEC262E952A1CDBB8E2FF68DC932E7F8E3AECD1FE5282EACA4161C2203FF098F79D6735E64414E185FBB3EC043D838D9B4B19072331C3F79857E5

kuroppoi avatar Jul 31 '23 14:07 kuroppoi

It's been a year since last comment. Any updates on this?

Priestyle avatar Jul 12 '24 11:07 Priestyle