Lines Matching refs:params
113 static int build_merkle_tree(const struct fsveritysetup_params *params, in build_merkle_tree() argument
129 compute_tree_layout(data_size, tree_offset, params->blockbits, in build_merkle_tree()
130 params->hashes_per_block, hash_lvl_region_idx, in build_merkle_tree()
134 data_to_hash = xmalloc(params->blocksize); in build_merkle_tree()
135 pending_hashes = xmalloc(params->blocksize); in build_merkle_tree()
137 nr_hashes_at_this_lvl = data_size >> params->blockbits; in build_merkle_tree()
152 hash_update(hash, params->salt, params->saltlen); in build_merkle_tree()
163 if (!full_pread(file, data_to_hash, params->blocksize, in build_merkle_tree()
164 blk_idx << params->blockbits)) in build_merkle_tree()
166 hash_update(hash, data_to_hash, params->blocksize); in build_merkle_tree()
181 if (pending_hash_bytes + digest_size > params->blocksize in build_merkle_tree()
185 params->blocksize - pending_hash_bytes); in build_merkle_tree()
187 (i / params->hashes_per_block); in build_merkle_tree()
190 params->blocksize, in build_merkle_tree()
191 blk_idx << params->blockbits)) in build_merkle_tree()
198 params->hashes_per_block); in build_merkle_tree()
235 static int append_fsverity_descriptor(const struct fsveritysetup_params *params, in append_fsverity_descriptor() argument
247 desc_auth_len += FSVERITY_EXTLEN(params->hash_alg->digest_size); in append_fsverity_descriptor()
248 if (params->saltlen) in append_fsverity_descriptor()
249 desc_auth_len += FSVERITY_EXTLEN(params->saltlen); in append_fsverity_descriptor()
250 desc_auth_len += total_elide_patch_ext_length(params); in append_fsverity_descriptor()
256 desc->log_data_blocksize = params->blockbits; in append_fsverity_descriptor()
257 desc->log_tree_blocksize = params->blockbits; in append_fsverity_descriptor()
258 desc->data_algorithm = cpu_to_le16(params->hash_alg - in append_fsverity_descriptor()
264 if (params->saltlen) in append_fsverity_descriptor()
266 auth_ext_count += params->num_elisions_and_patches; in append_fsverity_descriptor()
271 root_hash, params->hash_alg->digest_size); in append_fsverity_descriptor()
272 if (params->saltlen) in append_fsverity_descriptor()
274 params->salt, params->saltlen); in append_fsverity_descriptor()
275 append_elide_patch_exts(&buf, params); in append_fsverity_descriptor()
297 const struct fsveritysetup_params *params, in append_unauthenticated_extensions() argument
305 bool have_sig = params->signing_key_file || params->signature_file; in append_unauthenticated_extensions()
318 return append_signed_measurement(out, params, measurement); in append_unauthenticated_extensions()
337 const struct fsveritysetup_params *params) in fsveritysetup() argument
384 aligned_filesize = ALIGN(filesize, params->blocksize); in fsveritysetup()
388 if (params->num_elisions_and_patches) { in fsveritysetup()
391 if (!apply_elisions_and_patches(params, in, filesize, in fsveritysetup()
400 hash = hash_create(params->hash_alg); in fsveritysetup()
403 status = build_merkle_tree(params, hash, src, src_filesize, in fsveritysetup()
414 status = append_fsverity_descriptor(params, filesize, root_hash, in fsveritysetup()
420 status = append_unauthenticated_extensions(out, params, measurement); in fsveritysetup()
428 bin2hex(measurement, params->hash_alg->digest_size, hash_hex); in fsveritysetup()
429 printf("File measurement: %s:%s\n", params->hash_alg->name, hash_hex); in fsveritysetup()
454 struct fsveritysetup_params params = { in fsverity_cmd_setup() local
465 params.hash_alg = find_hash_alg_by_name(optarg); in fsverity_cmd_setup()
466 if (!params.hash_alg) in fsverity_cmd_setup()
470 if (params.salt) { in fsverity_cmd_setup()
474 params.saltlen = strlen(optarg) / 2; in fsverity_cmd_setup()
475 params.salt = xmalloc(params.saltlen); in fsverity_cmd_setup()
476 if (!hex2bin(optarg, params.salt, params.saltlen)) { in fsverity_cmd_setup()
482 if (!parse_blocksize_option(optarg, ¶ms.blocksize)) in fsverity_cmd_setup()
486 params.signing_key_file = optarg; in fsverity_cmd_setup()
489 params.signing_cert_file = optarg; in fsverity_cmd_setup()
492 params.signature_file = optarg; in fsverity_cmd_setup()
511 ASSERT(params.hash_alg->digest_size <= FS_VERITY_MAX_DIGEST_SIZE); in fsverity_cmd_setup()
513 if (params.blocksize == 0) { in fsverity_cmd_setup()
514 params.blocksize = sysconf(_SC_PAGESIZE); in fsverity_cmd_setup()
515 if (params.blocksize <= 0 || !is_power_of_2(params.blocksize)) { in fsverity_cmd_setup()
518 params.blocksize); in fsverity_cmd_setup()
519 params.blocksize = 4096; in fsverity_cmd_setup()
522 params.blockbits = ilog2(params.blocksize); in fsverity_cmd_setup()
524 params.hashes_per_block = params.blocksize / in fsverity_cmd_setup()
525 params.hash_alg->digest_size; in fsverity_cmd_setup()
526 if (params.hashes_per_block < 2) { in fsverity_cmd_setup()
528 params.blocksize, params.hash_alg->name); in fsverity_cmd_setup()
532 if (params.signing_cert_file && !params.signing_key_file) { in fsverity_cmd_setup()
538 if ((params.signing_key_file || params.signature_file) && in fsverity_cmd_setup()
539 !params.hash_alg->cryptographic) { in fsverity_cmd_setup()
542 params.hash_alg->name, params.hash_alg->name); in fsverity_cmd_setup()
546 if (!load_elisions_and_patches(&elide_opts, &patch_opts, ¶ms)) in fsverity_cmd_setup()
549 status = fsveritysetup(argv[0], argv[argc - 1], ¶ms); in fsverity_cmd_setup()
551 free(params.salt); in fsverity_cmd_setup()
552 free_elisions_and_patches(¶ms); in fsverity_cmd_setup()