Lines Matching full:hash
10 * Calculates md5/sha1 file hash, template hash, boot-aggreate hash
21 #include <crypto/hash.h>
86 pr_info("Allocated hash algorithm: %s\n", in ima_init_ima_crypto()
329 struct ima_digest_data *hash, in ima_calc_file_hash_atfm() argument
340 hash->length = crypto_ahash_digestsize(tfm); in ima_calc_file_hash_atfm()
431 ahash_request_set_crypt(req, NULL, hash->digest, 0); in ima_calc_file_hash_atfm()
439 static int ima_calc_file_ahash(struct file *file, struct ima_digest_data *hash) in ima_calc_file_ahash() argument
444 tfm = ima_alloc_atfm(hash->algo); in ima_calc_file_ahash()
448 rc = ima_calc_file_hash_atfm(file, hash, tfm); in ima_calc_file_ahash()
456 struct ima_digest_data *hash, in ima_calc_file_hash_tfm() argument
466 hash->length = crypto_shash_digestsize(tfm); in ima_calc_file_hash_tfm()
502 rc = crypto_shash_final(shash, hash->digest); in ima_calc_file_hash_tfm()
506 static int ima_calc_file_shash(struct file *file, struct ima_digest_data *hash) in ima_calc_file_shash() argument
511 tfm = ima_alloc_tfm(hash->algo); in ima_calc_file_shash()
515 rc = ima_calc_file_hash_tfm(file, hash, tfm); in ima_calc_file_shash()
523 * ima_calc_file_hash - calculate file hash
525 * Asynchronous hash (ahash) allows using HW acceleration for calculating
526 * a hash. ahash performance varies for different data sizes on different
532 * shash for the hash calculation. If ahash fails, it falls back to using
535 int ima_calc_file_hash(struct file *file, struct ima_digest_data *hash) in ima_calc_file_hash() argument
547 hash->length = hash_digest_size[ima_hash_algo]; in ima_calc_file_hash()
548 hash->algo = ima_hash_algo; in ima_calc_file_hash()
575 rc = ima_calc_file_ahash(f, hash); in ima_calc_file_hash()
580 rc = ima_calc_file_shash(f, hash); in ima_calc_file_hash()
590 * Calculate the hash of template data
673 struct ima_digest_data *hash, in calc_buffer_ahash_atfm() argument
681 hash->length = crypto_ahash_digestsize(tfm); in calc_buffer_ahash_atfm()
704 ahash_request_set_crypt(req, NULL, hash->digest, 0); in calc_buffer_ahash_atfm()
713 struct ima_digest_data *hash) in calc_buffer_ahash() argument
718 tfm = ima_alloc_atfm(hash->algo); in calc_buffer_ahash()
722 rc = calc_buffer_ahash_atfm(buf, len, hash, tfm); in calc_buffer_ahash()
730 struct ima_digest_data *hash, in calc_buffer_shash_tfm() argument
739 hash->length = crypto_shash_digestsize(tfm); in calc_buffer_shash_tfm()
755 rc = crypto_shash_final(shash, hash->digest); in calc_buffer_shash_tfm()
760 struct ima_digest_data *hash) in calc_buffer_shash() argument
765 tfm = ima_alloc_tfm(hash->algo); in calc_buffer_shash()
769 rc = calc_buffer_shash_tfm(buf, len, hash, tfm); in calc_buffer_shash()
776 struct ima_digest_data *hash) in ima_calc_buffer_hash() argument
781 rc = calc_buffer_ahash(buf, len, hash); in ima_calc_buffer_hash()
786 return calc_buffer_shash(buf, len, hash); in ima_calc_buffer_hash()
799 * The boot_aggregate is a cumulative hash over TPM registers 0 - 7. With
801 * TPM 2.0 hash agility, TPM chips could support multiple TPM PCR banks,
806 * hash algorithm for reading the TPM PCRs as for calculating the boot
853 int ima_calc_boot_aggregate(struct ima_digest_data *hash) in ima_calc_boot_aggregate() argument
861 if (crypto_id == hash->algo) { in ima_calc_boot_aggregate()
878 hash->algo = ima_tpm_chip->allocated_banks[bank_idx].crypto_id; in ima_calc_boot_aggregate()
880 tfm = ima_alloc_tfm(hash->algo); in ima_calc_boot_aggregate()
884 hash->length = crypto_shash_digestsize(tfm); in ima_calc_boot_aggregate()
886 rc = ima_calc_boot_aggregate_tfm(hash->digest, alg_id, tfm); in ima_calc_boot_aggregate()