verity: output salt if we had one

BUG=chromium-os:12138
TEST=Adhoc
verity mode=create alg=sha256 payload=foo hashtree=bar [salt=0]
Check that with no salt, no salt is emitted, and with a salt, the right salt is
re-emitted (and the root hexdigest differs).

Change-Id: Ibb9de2956b937efed7aa98ee40342034458b1b38
Signed-off-by: Elly Jones <ellyjones@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/7100
Reviewed-by: Mandeep Singh Baines <msb@chromium.org>
diff --git a/file_hasher.cc b/file_hasher.cc
index d792917..e3b9edd 100644
--- a/file_hasher.cc
+++ b/file_hasher.cc
@@ -111,14 +111,21 @@
 void FileHasher::PrintTable(bool colocated) {
   // Grab the digest (up to 1kbit supported)
   uint8_t digest[128];
+  char hexsalt[DM_BHT_SALT_SIZE * 2 + 1];
+  bool have_salt;
+
   dm_bht_root_hexdigest(&tree_, digest, sizeof(digest));
+  have_salt = dm_bht_salt(&tree_, hexsalt) == 0;
 
   // TODO(wad) later support sizes that need 64-bit sectors.
   unsigned int hash_start = 0;
   unsigned int root_end = to_sector(block_limit_ << PAGE_SHIFT);
   if (colocated) hash_start = root_end;
   printf("0 %u verity payload=ROOT_DEV hashtree=HASH_DEV hashstart=%u alg=%s "
-         "root_hexdigest=%s\n", root_end, hash_start, alg_, digest);
+         "root_hexdigest=%s", root_end, hash_start, alg_, digest);
+  if (have_salt)
+    printf(" salt=%s", hexsalt);
+  printf("\n");
 }
 
 }  // namespace verity