!196 模拟器签名适配

Merge pull request !196 from 张欣宇/master
This commit is contained in:
openharmony_ci 2024-01-04 14:30:09 +00:00 committed by Gitee
commit 0abb3718c7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 9 additions and 2 deletions

View File

@ -84,6 +84,10 @@ if (os_level == "standard") {
subsystem_name = "security"
defines += [ "OPENSSL_SUPPRESS_DEPRECATED" ]
if (is_emulator) {
defines += [ "X86_EMULATOR_MODE" ]
}
}
} else {
group("libhapverify") {

View File

@ -80,7 +80,9 @@ const string VALUE_DEVELOPMENT_MODE = "1";
const int32_t MAXIMUM_NUM_DEVICES = 100;
const int32_t VERSION_CODE_TWO = 2;
#ifndef X86_EMULATOR_MODE
const int32_t DEVELOPMENT_MODE_LENGTH = 2;
#endif
inline void GetStringIfExist(const json& obj, const string& key, string& out)
{
@ -349,6 +351,7 @@ AppProvisionVerifyResult ParseAndVerify(const string& appProvision, ProvisionInf
if (ret != PROVISION_OK) {
return ret;
}
#ifndef X86_EMULATOR_MODE
const char *key = KEY_DEVELOPMENT_MODE.data();
char developmentMode[DEVELOPMENT_MODE_LENGTH] = {0};
GetParameter(key, nullptr, developmentMode, sizeof(developmentMode));
@ -362,6 +365,7 @@ AppProvisionVerifyResult ParseAndVerify(const string& appProvision, ProvisionInf
return ret;
}
}
#endif
HAPVERIFY_LOG_DEBUG(LABEL, "Leave HarmonyAppProvision Verify");
return PROVISION_OK;
}

View File

@ -174,8 +174,7 @@ bool HapCertVerifyOpensslUtils::GetPublickeyBase64(const X509* cert, std::string
*/
int32_t HapCertVerifyOpensslUtils::CalculateLenAfterBase64Encode(int32_t len)
{
return static_cast<int>(ceil(static_cast<long double>(len) / BASE64_ENCODE_PACKET_LEN) *
BASE64_ENCODE_LEN_OF_EACH_GROUP_DATA + 1);
return (len + BASE64_ENCODE_PACKET_LEN - 1) / BASE64_ENCODE_PACKET_LEN * BASE64_ENCODE_LEN_OF_EACH_GROUP_DATA + 1;
}
bool HapCertVerifyOpensslUtils::CompareX509Cert(const X509* certA, const std::string& base64Cert)