Lines Matching refs:hash

28 static void hash_one_block(struct hash_ctx *hash, struct block_buffer *cur,
36 libfsverity_hash_init(hash);
37 libfsverity_hash_update(hash, salt, salt_size);
38 libfsverity_hash_update(hash, cur->data, block_size);
39 libfsverity_hash_final(hash, &next->data[next->filled]);
41 next->filled += hash->alg->digest_size;
46 struct hash_ctx *hash)
48 /* Would the next hash put us over the limit? */
49 return block->filled + hash->alg->digest_size > block_size;
100 * Compute the file's Merkle tree root hash using the given hash algorithm,
104 u64 file_size, struct hash_ctx *hash,
109 const u32 hashes_per_block = block_size / hash->alg->digest_size;
110 const u32 padded_salt_size = roundup(salt_size, hash->alg->block_size);
121 /* Root hash of empty file is all 0's */
123 memset(root_hash, 0, hash->alg->digest_size);
154 * metadata callbacks (if they were given), as the hash computation
171 * Buffer 'num_levels' is for the root hash.
192 hash_one_block(hash, &buffers[-1], block_size,
195 if (!block_is_full(&buffers[level], block_size, hash))
197 hash_one_block(hash, &buffers[level], block_size,
210 hash_one_block(hash, &buffers[level], block_size,
221 /* Root hash was filled by the last call to hash_one_block() */
222 if (WARN_ON(buffers[num_levels].filled != hash->alg->digest_size)) {
242 struct hash_ctx *hash = NULL;
284 libfsverity_error_msg("unknown hash algorithm: %u", alg_num);
289 libfsverity_error_msg("block size (%u) too small for hash algorithm %s",
294 hash = hash_alg->create_ctx(hash_alg);
295 if (!hash)
308 err = compute_root_hash(fd, read_fn, params->file_size, hash,
326 libfsverity_hash_full(hash, &desc, sizeof(desc), digest->digest);
330 libfsverity_free_hash_ctx(hash);