Hello third time.

Totally newbie in C++ and crypto-things.
General schema is here: 
https://developers.google.com/pay/api/payment-data-cryptography#encrypt-spec 


Am I right in understanding for what different cryptopp things to be used?

Short schema of my actions:

1)loading keys (PEM keys, I think) from string as here:

string base64_decode(string encoded) {
string decoded;

CryptoPP::Base64Decoder decoder;
decoder.Put((CryptoPP::byte*)encoded.data(), encoded.size());
decoder.MessageEnd();

CryptoPP::word64 size = decoder.MaxRetrievable();
if (size && size <= SIZE_MAX)
{
decoded.resize(size);
decoder.Get((CryptoPP::byte*)&decoded[0], decoded.size());
return decoded;
}
else {
return "";
}


}

string priv_key_encoded = "...";//big things in base64, like this:
//
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgWV4oK8c/MZkCLk4qSCNjW0Zm6H0CBCtSYxkXkC9FBHehRANCAAQPldOnhO2/oXjdJD1dwlFPiNs6fcdoRgFu3/Z0iKj24SjTGyLRGAtYWLGXBZcDdPj3T2bJRHRVhE8Bc2AjkT7n
string priv_key = base64_decode(priv_key_encoded);
const CryptoPP::byte *priv_key_ptr = (const CryptoPP::byte*) 
priv_key.data();
CryptoPP::SecByteBlock privKey(*priv_key_ptr);

//similar actions on other keys - our private, accepted ephemeral and 
accepted public

CryptoPP::OID curve = CryptoPP::ASN1::secp256r1();
CryptoPP::ECDH<CryptoPP::ECP>::Domain dh(curve);
CryptoPP::DH2 dh2(dh);

//and finally:
dh2.Agree(shared_secret, privKey, ephPrivKey, g_pubKey, g_ephKey, false)



When I use outer keys auto-generated with GenerateKeyPair, I get 
shared_secret, but with Google keys - not. What can it be? Incorrect key 
loading?
Google ephemeral is 65-byte length after base64 decoding, but google public 
(from here 
https://payments.developers.google.com/paymentmethodtoken/keys.json) is 
91-byte length. Tryed to use only last 65 - no effect.

Thank you very much!
I hope this post will help anyone wandering around googlePay api.

-- 
You received this message because you are subscribed to "Crypto++ Users". More 
information about Crypto++ and this group is available at 
http://www.cryptopp.com and 
http://groups.google.com/forum/#!forum/cryptopp-users.
--- 
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 cryptopp-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to