Skip to content

Commit

Permalink
更新 integrity.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
ioit2024 authored Jan 2, 2025
1 parent 7ab859d commit d10cb73
Showing 1 changed file with 2 additions and 34 deletions.
36 changes: 2 additions & 34 deletions TMessagesProj/jni/integrity/integrity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,6 @@ static const char *SIGN = "3A0F57FE06485D0B90D0ACD990E3A30328E3988D";

extern "C" {
int verifySign(JNIEnv *env) {
jobject application = getApplication(env);
if (application == nullptr) {
return JNI_ERR;
}
const char *resourcePath = getApkPath(env, application);
env->DeleteLocalRef(application);
intptr_t fd = openAt(AT_FDCWD, resourcePath, O_RDONLY);
if (fd < 0) {
return JNI_ERR;
}
std::string sign = read_certificate(fd);
if (!more_check(fd, resourcePath)) {
return JNI_ERR;
}
close(fd);
std::string s = toolkit::SHA1::encode(sign);
// 使用标准库算法将小写字母转换为大写字母
for (char &c : s) {
if (c >= 'a' && c <= 'z') {
c = c - 'a' + 'A'; // 转换成大写
}
}
const char* hex_sha = s.c_str();

LOGI("应用读取的签名为:%s", hex_sha);
LOGI("应用预置的签名为:%s", SIGN);
int result = strcmp(hex_sha, SIGN);
if (result == 0) { // 签名一致
LOGI("签名一致");
return JNI_OK;
}
LOGE("签名校验失败");
return JNI_ERR;
}
return JNI_OK;
}
}

0 comments on commit d10cb73

Please sign in to comment.