Lines Matching refs:alg

45 	struct fsverity_hash_alg *alg;  in fsverity_get_hash_alg()  local
54 alg = &fsverity_hash_algs[num]; in fsverity_get_hash_alg()
57 if (likely(smp_load_acquire(&alg->tfm) != NULL)) in fsverity_get_hash_alg()
58 return alg; in fsverity_get_hash_alg()
62 if (alg->tfm != NULL) in fsverity_get_hash_alg()
65 tfm = crypto_alloc_shash(alg->name, 0, 0); in fsverity_get_hash_alg()
70 alg->name); in fsverity_get_hash_alg()
71 alg = ERR_PTR(-ENOPKG); in fsverity_get_hash_alg()
76 alg->name, PTR_ERR(tfm)); in fsverity_get_hash_alg()
77 alg = ERR_CAST(tfm); in fsverity_get_hash_alg()
82 if (WARN_ON_ONCE(alg->digest_size != crypto_shash_digestsize(tfm))) in fsverity_get_hash_alg()
84 if (WARN_ON_ONCE(alg->block_size != crypto_shash_blocksize(tfm))) in fsverity_get_hash_alg()
88 alg->name, crypto_shash_driver_name(tfm)); in fsverity_get_hash_alg()
91 smp_store_release(&alg->tfm, tfm); in fsverity_get_hash_alg()
96 alg = ERR_PTR(err); in fsverity_get_hash_alg()
99 return alg; in fsverity_get_hash_alg()
111 const u8 *fsverity_prepare_hash_state(const struct fsverity_hash_alg *alg, in fsverity_prepare_hash_state() argument
115 SHASH_DESC_ON_STACK(desc, alg->tfm); in fsverity_prepare_hash_state()
120 desc->tfm = alg->tfm; in fsverity_prepare_hash_state()
125 hashstate = kmalloc(crypto_shash_statesize(alg->tfm), GFP_KERNEL); in fsverity_prepare_hash_state()
136 padded_salt_size = round_up(salt_size, alg->block_size); in fsverity_prepare_hash_state()
209 int fsverity_hash_buffer(const struct fsverity_hash_alg *alg, in fsverity_hash_buffer() argument
212 return crypto_shash_tfm_digest(alg->tfm, data, size, out); in fsverity_hash_buffer()
224 const struct fsverity_hash_alg *alg = &fsverity_hash_algs[i]; in fsverity_check_hash_algs() local
226 if (!alg->name) in fsverity_check_hash_algs()
237 BUG_ON(alg->digest_size > FS_VERITY_MAX_DIGEST_SIZE); in fsverity_check_hash_algs()
244 BUG_ON(!is_power_of_2(alg->digest_size)); in fsverity_check_hash_algs()
245 BUG_ON(!is_power_of_2(alg->block_size)); in fsverity_check_hash_algs()
248 BUG_ON(alg->algo_id == 0); in fsverity_check_hash_algs()
249 BUG_ON(alg->digest_size != hash_digest_size[alg->algo_id]); in fsverity_check_hash_algs()