Why is 65537 not base64URL encoded in "AQAB" using CryptoPP?

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? !

+4
1

CryptoPP, -, ASN.1 DER. AgMBAAE 0203010001.

ASN.1/DER :

    02 a signed INTEGER
    03 the length of the value
010001 the value, a big endian signed integer (i.e. 65537)

base64encode.org, , 64- ASCII "65537": 3635353337 .


17, , .

  • EQ==
  • ASN.1/DER AgER
  • MTc=

, , = ( base64url 64).

+5

All Articles