I indent to verify 'google inapp billing signature' in server side implemented c or c++
I found the way through php(Android in-app billing signature verification in php server) and advice it could using EVP_Verify... functions in openssl..but to use :
int EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf, unsigned int siglen,EVP_PKEY *pkey);
It needs instance of 'EVP_PKEY* pkey' structure as a parameter...but I don't have it!
I beleive there is the way convert 'Google InApp Billing signature string(base64 encoded SHA1-with-RAS signature with PKCS#1 padding)' to EVP_PKEY..but I don't know how to it.
How CAN I PASS it as a parameter for EVP_VerifyFinal function??
int main()
{
OPENSSL_config(NULL);
OpenSSL_add_all_digests();
ERR_load_crypto_strings();
EVP_MD_CTX* ctx = EVP_MD_CTX_create();
const EVP_MD* md = EVP_get_digestbyname("SHA1");
if(0 == EVP_VerifyInit_ex(ctx, md, NULL))
{
std::cerr << "init error" << std::endl;
return 0;
}
const char* data = "{\"orderId\":\"12999763169054705758.1310724241212373\",\"packageName\":\"com.company.game.google\",\"productId\":\"game_product_001\",\"purchaseTime\":1358227642000,\"purchaseState\":0,\"developerPayload\":\"12322144\",\"purchaseToken\":\"}";
if(0 == EVP_VerifyUpdate(ctx, (void*)data, strlen(data)))
{
std::cerr << "update error" << std::endl;
return 0;
}
const char* key_context = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAh0UDlUA1aYPvfRFq6qUjDVG/fi5EetC6LsjdT/WNmHUAy0muvuOTFfQEzBoELciDfh23VXgwVnb/XsfuvQrCgtnQbuMKsj+sDhofLjeq8TznEMlQcJ//0LsGSM8rRVHw72BYA2mSVKi04k1GIicB9J25c2f+eIwF7lEWJlWqVDlNqOS7GIIjnq3HPhqki3ZRSA9c";
EVP_PKEY* pub_key = EVP_PKEY_new();
if(NULL == pub_key)
{
std::cerr << "evp_pkey new error" << std::endl;
return 0;
}
// I have to call 'EVP_VerifyFinish' here!! but I don't know how to!!
ERR_remove_state(0);
ERR_free_strings();
return 0;
}
please somebody help me!!