On Wednesday, March 2, 2016 at 10:12:01 PM UTC-5, Jeffrey Walton wrote:
>
>
> I have difficulties with loading private key into Crypto++ wich is
>> mentioned in
>> https://developers.google.com/android-pay/integration/gateway-processor-integration#using-openssl-to-generate-and-format-a-key
>>
>> private static final String MERCHANT_PRIVATE_KEY_PKCS8_BASE64 =
>> "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgCPSuFr4iSIaQprjj" +
>> "chHPyDu2NXFe0vDBoTpPkYaK9dehRANCAATnaFz/vQKuO90pxsINyVNWojabHfbx" +
>> "9qIJ6uD7Q7ZSxmtyo/Ez3/o2kDT8g0pIdyVIYktCsq65VoQIDWSh2Bdm";
>>
>> My bad... I missed that you were already using the PEM Pack.
>
> Try this, it works for me...
>
I probably should have given you this, too. It uses ECIES<ECP> rather than
the private key.
string encoded =
"MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgCPSuFr4iSIaQprjj"
"chHPyDu2NXFe0vDBoTpPkYaK9dehRANCAATnaFz/vQKuO90pxsINyVNWojabHfbx"
"9qIJ6uD7Q7ZSxmtyo/Ez3/o2kDT8g0pIdyVIYktCsq65VoQIDWSh2Bdm";
int main(int argc, char* argv[])
{
try
{
string decoded;
StringSource ss1(encoded.c_str(), true, new Base64Decoder(new
StringSink(decoded)));
ECIES<ECP>::Decryptor decryptor;
decryptor.AccessKey().Load(StringStore((const byte*)decoded.data(),
decoded.size()).Ref());
// AccessKey() provides a non-const reference
AutoSeededRandomPool prng;
decryptor.GetKey().ThrowIfInvalid(prng, 3);
// GetKey() provides a const reference
cout << "Private key appears to be valid" << endl;
}
catch(Exception& ex)
{
cerr << ex.what() << endl;
return 1;
}
return 0;
}
It produces the same result:
$ ./test.exe
Private key appears to be valid
--
--
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.