Lines Matching refs:alg

41  * Return: pointer to the hash alg on success, else an ERR_PTR()
46 struct fsverity_hash_alg *alg;
55 alg = &fsverity_hash_algs[num];
58 if (likely(smp_load_acquire(&alg->tfm) != NULL))
59 return alg;
63 if (alg->tfm != NULL)
70 tfm = crypto_alloc_ahash(alg->name, 0, 0);
75 alg->name);
76 alg = ERR_PTR(-ENOPKG);
81 alg->name, PTR_ERR(tfm));
82 alg = ERR_CAST(tfm);
87 if (WARN_ON(alg->digest_size != crypto_ahash_digestsize(tfm)))
89 if (WARN_ON(alg->block_size != crypto_ahash_blocksize(tfm)))
92 err = mempool_init_kmalloc_pool(&alg->req_pool, 1,
99 alg->name, crypto_ahash_driver_name(tfm));
102 smp_store_release(&alg->tfm, tfm);
107 alg = ERR_PTR(err);
110 return alg;
115 * @alg: the hash algorithm for which to allocate the request
125 struct ahash_request *fsverity_alloc_hash_request(struct fsverity_hash_alg *alg,
128 struct ahash_request *req = mempool_alloc(&alg->req_pool, gfp_flags);
131 ahash_request_set_tfm(req, alg->tfm);
137 * @alg: the hash algorithm
140 void fsverity_free_hash_request(struct fsverity_hash_alg *alg,
145 mempool_free(req, &alg->req_pool);
151 * @alg: hash algorithm
158 const u8 *fsverity_prepare_hash_state(struct fsverity_hash_alg *alg,
172 hashstate = kmalloc(crypto_ahash_statesize(alg->tfm), GFP_KERNEL);
177 req = fsverity_alloc_hash_request(alg, GFP_KERNEL);
186 padded_salt_size = round_up(salt_size, alg->block_size);
212 fsverity_free_hash_request(alg, req);
273 * @alg: the hash algorithm to use
276 * @out: output digest, size 'alg->digest_size' bytes
283 int fsverity_hash_buffer(struct fsverity_hash_alg *alg,
292 req = fsverity_alloc_hash_request(alg, GFP_KERNEL);
302 fsverity_free_hash_request(alg, req);
315 const struct fsverity_hash_alg *alg = &fsverity_hash_algs[i];
317 if (!alg->name)
320 BUG_ON(alg->digest_size > FS_VERITY_MAX_DIGEST_SIZE);
327 BUG_ON(!is_power_of_2(alg->digest_size));
328 BUG_ON(!is_power_of_2(alg->block_size));