Merge "Change source stamp verifier outcome" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e6bae5dc05
@@ -82,25 +82,34 @@ public abstract class SourceStampVerifier {
|
|||||||
public static SourceStampVerificationResult verify(String apkFile) {
|
public static SourceStampVerificationResult verify(String apkFile) {
|
||||||
try (RandomAccessFile apk = new RandomAccessFile(apkFile, "r")) {
|
try (RandomAccessFile apk = new RandomAccessFile(apkFile, "r")) {
|
||||||
return verify(apk);
|
return verify(apk);
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
// Any exception in the SourceStamp verification returns a non-verified SourceStamp
|
// Any exception in reading the APK returns a non-present SourceStamp outcome
|
||||||
// outcome without affecting the outcome of any of the other signature schemes.
|
// without affecting the outcome of any of the other signature schemes.
|
||||||
return SourceStampVerificationResult.notVerified();
|
return SourceStampVerificationResult.notPresent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SourceStampVerificationResult verify(RandomAccessFile apk)
|
private static SourceStampVerificationResult verify(RandomAccessFile apk) {
|
||||||
throws IOException, SignatureNotFoundException {
|
byte[] sourceStampCertificateDigest;
|
||||||
byte[] sourceStampCertificateDigest = getSourceStampCertificateDigest(apk);
|
try {
|
||||||
|
sourceStampCertificateDigest = getSourceStampCertificateDigest(apk);
|
||||||
if (sourceStampCertificateDigest == null) {
|
if (sourceStampCertificateDigest == null) {
|
||||||
// SourceStamp certificate hash file not found, which means that there is not
|
// SourceStamp certificate hash file not found, which means that there is not
|
||||||
// SourceStamp present.
|
// SourceStamp present.
|
||||||
return SourceStampVerificationResult.notPresent();
|
return SourceStampVerificationResult.notPresent();
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
return SourceStampVerificationResult.notPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
SignatureInfo signatureInfo =
|
SignatureInfo signatureInfo =
|
||||||
ApkSigningBlockUtils.findSignature(apk, SOURCE_STAMP_BLOCK_ID);
|
ApkSigningBlockUtils.findSignature(apk, SOURCE_STAMP_BLOCK_ID);
|
||||||
Map<Integer, byte[]> apkContentDigests = getApkContentDigests(apk);
|
Map<Integer, byte[]> apkContentDigests = getApkContentDigests(apk);
|
||||||
return verify(signatureInfo, apkContentDigests, sourceStampCertificateDigest);
|
return verify(signatureInfo, apkContentDigests, sourceStampCertificateDigest);
|
||||||
|
} catch (IOException | SignatureNotFoundException e) {
|
||||||
|
return SourceStampVerificationResult.notVerified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SourceStampVerificationResult verify(
|
private static SourceStampVerificationResult verify(
|
||||||
|
|||||||
Reference in New Issue
Block a user