Fix imprecise name of a fs-verity helper function

Root hash is only part of the fs-verity digest covers. Rename to avoid
confusion.

Bug: N/A
Test: m
Change-Id: I12c2a4ac57fb8772483473f951e97474ebd894c9
Merged-In: I12c2a4ac57fb8772483473f951e97474ebd894c9
This commit is contained in:
Victor Hsieh
2022-09-29 14:47:50 -07:00
parent 1861c325ae
commit c49d0bfa1a
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);
}