函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\verity\open.c Create Date:2022-07-29 10:58:34
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:sverity_init_merkle_tree_params() - initialize Merkle tree parameters*@params: the parameters struct to initialize*@inode: the inode for which the Merkle tree is being built*@hash_algorithm: number of hash algorithm to use*@log_blocksize: log base 2 of

函数原型:int fsverity_init_merkle_tree_params(struct merkle_tree_params *params, const struct inode *inode, unsigned int hash_algorithm, unsigned int log_blocksize, const u8 *salt, size_t salt_size)

返回类型:int

参数:

类型参数名称
struct merkle_tree_params *params
const struct inode *inode
unsigned inthash_algorithm
unsigned intlog_blocksize
const u8 *salt
size_tsalt_size
40  memset(params, 0, params的长度)
42  hash_alg等于sverity_get_hash_alg() - validate and prepare a hash algorithm*@inode: optional inode for logging purposes*@num: the hash algorithm number* Get the struct fsverity_hash_alg for the given hash algorithm number, and
43  如果是错误则返回:错误
45  he hash algorithm 等于hash_alg
46  same as hash_alg->digest_size 等于digest size in bytes, e.g. 32 for SHA-256
48  itial hash state or NULL 等于sverity_prepare_hash_state() - precompute the initial hash state*@alg: hash algorithm*@salt: a salt which is to be prepended to all data to be hashed*@salt_size: salt size in bytes, possibly 0* Return: NULL if the salt is empty, otherwise the kmalloc()'ed
50  如果是错误
51  err等于错误
52  itial hash state or NULL = NULL
53  fsverity_err(inode, "Error %d preparing hash state", err)
54  转到:out_err
57  如果log_blocksize不等于PAGE_SHIFT determines the page size
58  fsverity_warn(inode, "Unsupported log_blocksize: %u", log_blocksize)
60  err等于负EINVAL
61  转到:out_err
63  log2(block_size) 等于log_blocksize
64  size of data and tree blocks 等于1左移log_blocksize
66  如果WARN_ON(!s_power_of_2() - check if a value is a power of two*@n: the value to check* Determine whether some value is a power of two, where zero is* *not* considered a power of two.* Return: true if @n is a power of 2, otherwise false.)则
67  err等于负EINVAL
68  转到:out_err
70  如果size of data and tree blocks 小于2乘same as hash_alg->digest_size
71  fsverity_warn(inode, "Merkle tree block size (%u) too small for hash algorithm \"%s\"", size of data and tree blocks , crypto API name, e.g. sha256 )
74  err等于负EINVAL
75  转到:out_err
77  log2(hashes_per_block) 等于log2(block_size) log2 - log base 2 of 32-bit or a 64-bit unsigned value*@n: parameter* constant-capable log of base 2 calculation* - this can be used to initialise global variables from constant data, hence* the massive ternary operator construction* selects the (same as hash_alg->digest_size )
78  umber of hashes per tree block 等于1左移log2(hashes_per_block)
80  pr_debug("Merkle tree uses %s with %u-byte blocks (%u hashes/block), salt=%*phN\n", crypto API name, e.g. sha256 , size of data and tree blocks , umber of hashes per tree block , (int)salt_size, salt)
92  blocks等于i_sizesize of data and tree blocks 减1右移log_blocksize
93  pr_debug("Data is %lld bytes (%llu blocks)\n", i_size, blocks)
94 blocks大于1循环
96  fsverity_err(inode, "Too many levels in Merkle tree")
97  err等于负EINVAL
98  转到:out_err
100  blocks等于blocksumber of hashes per tree block 减1右移log2(hashes_per_block)
103  Starting block index for each tree level, ordered from leaf level (0)* to root level ('num_levels - 1')[umber of levels in Merkle tree ++]等于blocks
107  offset等于0
108 level大于等于0循环
109  blocks等于Starting block index for each tree level, ordered from leaf level (0)* to root level ('num_levels - 1')[level]
110  Starting block index for each tree level, ordered from leaf level (0)* to root level ('num_levels - 1')[level]等于offset
111  pr_debug("Level %d is %llu blocks starting at index %llu\n", level, blocks, offset)
113  offset加等于blocks
116  Merkle tree size in bytes 等于offset左移log_blocksize
117  返回:0
119  out_err :
120  释放内存
121  memset(params, 0, params的长度)
122  返回:err
调用者
名称描述
fsverity_create_infoValidate the given fsverity_descriptor and create a new fsverity_info from* it. The signature (if present) is also checked.