New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix verifying wii dev signatures #10984
Conversation
allows verifying dev-signed discs and wads
|
Update on this: the non-verifying signatures I've encountered actually do have correct PKCS#1 v1.5 padding, but they're of block type Either way, I've implemented the type 2 padding checks in my own tooling and all the signatures seem to verify correctly. |
|
Good point! I should have looked into it a bit more :) I've seen this elsewhere as well - dev sigs encrypt the hash using d=0x10001, e={big num}. i.e. it is technically encrypted and not signed. afaict mbedtls makes this quite annoying since it requires "private" rsa operations to have both d and e set in the context. So just setting d=e then retrying with fwiw in python you should just be able to use this https://www.pycryptodome.org/src/cipher/pkcs1_v1_5 |
|
Yeah, it's a bit of a mess! I opted to not use the PyCrypto PKCS#1 primitives because they have (correct, mind you) opinions about when you should use RSA encrypt versus decrypt operations, and about unpadding stuff properly (both of which the Wii at various points of course, can violate :>). It seems mbedtls sadly doesn't cater out-of-the-box to non-standard use-cases like this either nor is its padding API usable by itself, which is a bummer... |
allows verifying dev-signed discs and wads
also fixes a memleak because
mbedtls_rsa_freewasn't called before.