I use CryptoPP to create an RSA key pair to allow authentication for the game server. I need base64URL to encode my common metric and module for inclusion in the JWK, but I have some problems. The code shows how I generate RSA keys, extract the exponent and encode it:
typedef InvertibleRSAFunction RSAPrivateKey;
typedef RSAFunction RSAPublicKey;
RSAPrivateKey privateKey;
privateKey.Initialize( rng, 1024);
RSAPublicKey publicKey( privateKey );
const Integer& e = privateKey.GetPublicExponent();
Base64Encoder exponentSink(new StringSink(exponentString));
e.DEREncode(exponentSink);
exponentSink.MessageEnd();
base64URL(exponentString);
cout << "exponentString: " << exponentString << endl;
The base64URL function simply filters the string for the characters =, +, \ n and / to make it base64URL.
I know that CryptoPP uses a metric of 17, and the code above encodes this as "Ager". I read from numerous sources that 65537 encodes as "AQAB", and I tried this as a test, manually setting e for this. When I do this, the output is "AgMBAAE", not "AQAB".
-, https://www.base64encode.org/, "NjU1Mzc".
- , , 17? !