On Friday, March 23, 2018 at 9:11:00 AM UTC-4, Миша Винник wrote:
>
> 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.
>

Man, Google search is getting bad. I could not find the wiki page of 
interest...

Part of the Google Pay problem has been solved at 
https://www.cryptopp.com/wiki/Elliptic_Curve_Integrated_Encryption_Scheme#Android_Pay_Example
 
. I'm not sure how complete the example is, but I seem to recall it is not 
complete.

Jeff

 

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