refactor: improve APK signature block parsing

This commit is contained in:
NkBe 2025-11-19 18:27:26 +08:00
parent 5642d2e62f
commit 9588a87814
No known key found for this signature in database
GPG Key ID: 525137026FF031DF
1 changed files with 9 additions and 7 deletions

View File

@ -131,14 +131,16 @@ public class ApkSignatureHelper {
while (block.remaining() > 24) {
size = (int) block.getLong();
if (block.getInt() == 0x7109871a) {
// signer-sequence length, signer length, signed data length
// SignerSequence length(4) + Signer length(4) + SignedData length(4)
block.position(block.position() + 12);
size = block.getInt(); // digests-sequence length
// digests, certificates length
block.position(block.position() + size + 0x4);
size = block.getInt(); // certificate length
// 读取 DigestsSequence
int digestsLen = block.getInt();
block.position(block.position() + digestsLen);
// 不使用仅为了移动指针
block.getInt();
// 这里赋值给 size供循环外读取数据使用
size = block.getInt();
// 此时 block 指针正好位于第一个证书数据的开头
break;
} else {
block.position(block.position() + size - 0x4);