static int ValidateSignature(CFDataRef signature, CFDataRef data) { int result = -1; CCRSACryptorRef key_ref = NULL; CCCryptorStatus ccStatus = kCCSuccess; if (NULL == signature || NULL == data) { return result; } // Get the key if (GetPublicManifestKey(&key_ref)) { return result; } const void *hash_data_ptr = CFDataGetBytePtr(data); size_t hash_data_len = CFDataGetLength(data); const void* sig_data_pre = CFDataGetBytePtr(signature); size_t sig_dat_len = CFDataGetLength(signature); ccStatus = CCRSACryptorVerify( key_ref, ccPKCS1Padding, hash_data_ptr, hash_data_len, kCCDigestSHA1, 0, sig_data_pre, sig_dat_len); CCRSACryptorRelease(key_ref); result = (kCCSuccess == ccStatus) ? 0 : -1; return result; }
CryptoKeyRSA::~CryptoKeyRSA() { CCRSACryptorRelease(m_platformKey); }