Ok, so I have passed two stages now - generating the ephemeralPubKey and
parsing the Private key using your code.
Just in case someone would be interested it should be smth like this:
string ephemeralPubKey64 =
"BPhVspn70Zj2Kkgu9t8+ApEuUWsI/zos5whGCQBlgOkuYagOis7"
"qsrcbQrcprjvTZO3XOU+Qbcc28FSgsRtcgQE=";
StringSource ssECPoint(ephemeralPubKey64, true, new Base64Decoder);
DL_GroupParameters_EC<ECP> params(CryptoPP::ASN1::secp256r1());
ECP::Point point;
if (!params.GetCurve().DecodePoint(point, ssECPoint, (size_t)
ssECPoint.MaxRetrievable()))
std::cerr << "Invalid decoding" << endl;
ECIES<ECP>::PublicKey ephemeralPubKey;
ephemeralPubKey.Initialize(params, point);
ephemeralPubKey.ThrowIfInvalid(prng, 3);
cout << "Public key appears to be valid" << endl;
But still need to figure out how to pass it to Decryptor.
четверг, 3 марта 2016 г., 13:33:58 UTC+1 пользователь Vasily Demidenok
написал:
>
> Hello Jeffrey,
>
> Thank you for your quick answers, now it works fine, although I do not
> understand what I was doing wrong.
>
> So now I stuck on trying to load ephemeralPublicKey in the Decryptor.
> While it's mentioned in the Android docs, that they provide it, it's seems
> to me that it
> is not actually the key, because of the following code:
>
> ECParameterSpec aasymmetricKeyParams = generateECParameterSpec();
> KeyFactory asymmetricKeyFactory = KeyFactory.getInstance(ASYMMETRIC_KEY_TYPE,
> SECURITY_PROVIDER);
> PublicKey ephemeralPublicKey = asymmetricKeyFactory.generatePublic(
> new ECPublicKeySpec( ECPointUtil.decodePoint(asymmetricKeyParams.getCurve(),
> ephemeralPublicKeyBytes), asymmetricKeyParams));
>
>
>
> But even if I will succeed with generating it out of EC type (I should use
> CryptoPP::ASN1::secp256r1() I guess)
> and the provided ephemeralPublicKeyBytes, it's still not clear for me, how
> to provide this information to the Decryptor.
>
> It seems to me that we get ephemeralPublicKey here.
> https://github.com/weidai11/cryptopp/blob/master/pubkey.h#L1668
>
> But I have no idea how to store it there.. also rather confusing that we
> call params.DecodeElement(ciphertext, true).
>
> It would be great if you could point me to the right direction.
>
> четверг, 3 марта 2016 г., 4:48:06 UTC+1 пользователь Jeffrey Walton
> написал:
>>
>>
>> I'm trying to use cryptopp for implementing small lib which will allow me
>>> to integrate with Android Pay.
>>>
>>
>> As you work through issues, I'm going to be adding it to our ECIES page
>> at
>> http://cryptopp.com/wiki/Elliptic_Curve_Integrated_Encryption_Scheme#Android_Pay_Example
>>
>> This is the sort of thing I'd like to see well documented.
>>
>> I also reached out to the Bouncy Castle folks. We are on the same page
>> ECIES and interop, so they can ensure their library works with the Android
>> Pay example, too.
>>
>> Jeff
>>
>>
--
--
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.