Lines Matching refs:alg
44 struct fsverity_hash_alg *alg; in fsverity_get_hash_alg() local
53 alg = &fsverity_hash_algs[num]; in fsverity_get_hash_alg()
56 if (likely(smp_load_acquire(&alg->tfm) != NULL)) in fsverity_get_hash_alg()
57 return alg; in fsverity_get_hash_alg()
61 if (alg->tfm != NULL) in fsverity_get_hash_alg()
68 tfm = crypto_alloc_ahash(alg->name, 0, 0); in fsverity_get_hash_alg()
73 alg->name); in fsverity_get_hash_alg()
74 alg = ERR_PTR(-ENOPKG); in fsverity_get_hash_alg()
79 alg->name, PTR_ERR(tfm)); in fsverity_get_hash_alg()
80 alg = ERR_CAST(tfm); in fsverity_get_hash_alg()
85 if (WARN_ON(alg->digest_size != crypto_ahash_digestsize(tfm))) in fsverity_get_hash_alg()
87 if (WARN_ON(alg->block_size != crypto_ahash_blocksize(tfm))) in fsverity_get_hash_alg()
90 err = mempool_init_kmalloc_pool(&alg->req_pool, 1, in fsverity_get_hash_alg()
97 alg->name, crypto_ahash_driver_name(tfm)); in fsverity_get_hash_alg()
100 smp_store_release(&alg->tfm, tfm); in fsverity_get_hash_alg()
105 alg = ERR_PTR(err); in fsverity_get_hash_alg()
108 return alg; in fsverity_get_hash_alg()
123 struct ahash_request *fsverity_alloc_hash_request(struct fsverity_hash_alg *alg, in fsverity_alloc_hash_request() argument
126 struct ahash_request *req = mempool_alloc(&alg->req_pool, gfp_flags); in fsverity_alloc_hash_request()
129 ahash_request_set_tfm(req, alg->tfm); in fsverity_alloc_hash_request()
138 void fsverity_free_hash_request(struct fsverity_hash_alg *alg, in fsverity_free_hash_request() argument
143 mempool_free(req, &alg->req_pool); in fsverity_free_hash_request()
156 const u8 *fsverity_prepare_hash_state(struct fsverity_hash_alg *alg, in fsverity_prepare_hash_state() argument
170 hashstate = kmalloc(crypto_ahash_statesize(alg->tfm), GFP_KERNEL); in fsverity_prepare_hash_state()
175 req = fsverity_alloc_hash_request(alg, GFP_KERNEL); in fsverity_prepare_hash_state()
184 padded_salt_size = round_up(salt_size, alg->block_size); in fsverity_prepare_hash_state()
210 fsverity_free_hash_request(alg, req); in fsverity_prepare_hash_state()
281 int fsverity_hash_buffer(struct fsverity_hash_alg *alg, in fsverity_hash_buffer() argument
290 req = fsverity_alloc_hash_request(alg, GFP_KERNEL); in fsverity_hash_buffer()
300 fsverity_free_hash_request(alg, req); in fsverity_hash_buffer()
313 const struct fsverity_hash_alg *alg = &fsverity_hash_algs[i]; in fsverity_check_hash_algs() local
315 if (!alg->name) in fsverity_check_hash_algs()
318 BUG_ON(alg->digest_size > FS_VERITY_MAX_DIGEST_SIZE); in fsverity_check_hash_algs()
325 BUG_ON(!is_power_of_2(alg->digest_size)); in fsverity_check_hash_algs()
326 BUG_ON(!is_power_of_2(alg->block_size)); in fsverity_check_hash_algs()