Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\verity\hash_algs.c Create Date:2022-07-28 20:24:38
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name: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

Proto:const struct fsverity_hash_alg *fsverity_get_hash_alg(const struct inode *inode, unsigned int num)

Type:struct fsverity_hash_alg

Parameter:

TypeParameterName
const struct inode *inode
unsigned intnum
46  If num >= ARRAY_SIZE - get the number of elements in array @arr*@arr: array to be sized(The hash algorithms supported by fs-verity ) || Not crypto API name, e.g. sha256 Then
48  fsverity_warn(inode, "Unknown hash algorithm number: %u", num)
49  Return ERR_PTR( - EINVAL)
51  alg = The hash algorithms supported by fs-verity [num]
54  tfm = READ_ONCE(hash tfm, allocated on demand )
55  If Value is more likely to compile time(tfm != NULL) Then Return alg
61  tfm = crypto_alloc_ahash(crypto API name, e.g. sha256 , 0, 0)
62  If IS_ERR(tfm) Then
63  If PTR_ERR(tfm) == -ENOENT Then
64  fsverity_warn(inode, "Missing crypto API support for hash algorithm \"%s\"", crypto API name, e.g. sha256 )
67  Return ERR_PTR( - ENOPKG)
69  fsverity_err(inode, "Error allocating hash algorithm \"%s\": %ld", crypto API name, e.g. sha256 , PTR_ERR(tfm))
72  Return ERR_CAST - Explicitly cast an error-valued pointer to another pointer type*@ptr: The pointer to cast.* Explicitly cast an error-valued pointer to another pointer type in such a* way as to make it clear that's what's going on.
75  err = -EINVAL
76  If WARN_ON(digest size in bytes, e.g. 32 for SHA-256 != rypto_ahash_digestsize() - obtain message digest size*@tfm: cipher handle* The size for the message digest created by the message digest cipher* referenced with the cipher handle is returned.* Return: message digest size of cipher) Then Go to err_free_tfm
78  If WARN_ON(lock size in bytes, e.g. 64 for SHA-256 != rypto_ahash_blocksize() - obtain block size for cipher*@tfm: cipher handle* The block size for the message digest cipher referenced with the cipher* handle is returned.* Return: block size of cipher) Then Go to err_free_tfm
81  pr_info("%s using implementation \"%s\"\n", crypto API name, e.g. sha256 , crypto_ahash_driver_name(tfm))
85  If (cmpxchg( & hash tfm, allocated on demand , NULL, tfm) != NULL) Then rypto_free_ahash() - zeroize and free the ahash handle*@tfm: cipher handle to be freed
88  Return alg
90  err_free_tfm :
91  rypto_free_ahash() - zeroize and free the ahash handle*@tfm: cipher handle to be freed
92  Return ERR_PTR(err)
Caller
NameDescribe
fsverity_init_merkle_tree_paramssverity_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