[Enhancement]: Make (some) tokens use asymmetric cryptography rather than symmetric cryptography #108
Labels
awaiting-approval
Topic has not been approved or denied
enhancement
An update to an existing part of the codebase
Checked Existing
What enhancement would you like to see?
Migrate (some) tokens to using asymmetric cryptography (public/private keys). Years ago we used RSA encryption for tokens, but moved away from it to AES for simplicity and to make the tokens smaller. This is not super great however, since it prevents us from securely allowing 3rd party servers and if the AES keys ever leaked anyone could generate their own.
By using asymmetric cryptography again we can properly issue tokens to individual services, including 3rd parties, with the ability to decrypt the token data without being able to generate any themselves.
Any other details to share? (OPTIONAL)
Not all tokens need to be handled this way. Some tokens, which are always handled internally on the account server, can simply have no meaning whatsoever. Tokens such as access and refresh tokens for example, can likely just be totally random bytes which we lookup the details for (relies on #107)
Nintendo seems to have likely used RSA-1024 for several tokens based on the size of the Wii U NEX token. However a few things should be considered:
3DS tokens from NASC might not be entirely RSA either. They always seem to be 105 bytes long, which could mean they are AES still? The guys from Colors! 3D made mention that they're able to decrypt the tokens to get basic data but then they ask a Nintendo server to verify a token signature, so maybe these use a combination of RSA+AES? Unsure, did not ask and I likely won'tNot sure where this info for the key size came from, it's wrong. See the edit belowEDIT:
Here are the details of all tokens officially used by Nintendo on the account server:
LOGIN
tokens from NASC are always 152 base64 characters (112 bytes) using a custom base64 alphabet (+
->.
,/
->-
,=
->*
)SVCLOC
tokens from NASC are always 88 base64 characters (64 bytes) using a custom base64 alphabet (+
->.
,/
->-
,=
->*
)This means that, assuming we keep with these same lengths as well, these are our options for keys:
The text was updated successfully, but these errors were encountered: