Merge "Fix imprecise name of a fs-verity helper function" am: 2af62aa321

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2274628

Change-Id: Ia9ba79c5d6bc8f9e65780166b5456afaf01f3c88
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2022-10-27 21:33:48 +00:00
committed by Automerger Merge Worker
2 changed files with 10 additions and 3 deletions

View File

@@ -90,8 +90,15 @@ public abstract class VerityUtils {
return (retval == 1);
}
/** Returns hash of a root node for the fs-verity enabled file. */
public static byte[] getFsverityRootHash(@NonNull String filePath) {
/**
* Returns fs-verity digest for the file if enabled, otherwise returns null. The digest is a
* hash of root hash of fs-verity's Merkle tree with extra metadata.
*
* @see <a href="https://www.kernel.org/doc/html/latest/filesystems/fsverity.html#file-digest-computation">
* File digest computation in Linux kernel documentation</a>
* @return Bytes of fs-verity digest
*/
public static byte[] getFsverityDigest(@NonNull String filePath) {
byte[] result = new byte[HASH_SIZE_BYTES];
int retval = measureFsverityNative(filePath, result);
if (retval < 0) {

View File

@@ -650,7 +650,7 @@ public class ApkChecksums {
// Skip /product folder.
// TODO(b/231354111): remove this hack once we are allowed to change SELinux rules.
if (!containsFile(Environment.getProductDirectory(), filePath)) {
byte[] verityHash = VerityUtils.getFsverityRootHash(filePath);
byte[] verityHash = VerityUtils.getFsverityDigest(filePath);
if (verityHash != null) {
return new ApkChecksum(split, TYPE_WHOLE_MERKLE_ROOT_4K_SHA256, verityHash);
}