Commit 50af5544 authored by Dmitry Kasatkin's avatar Dmitry Kasatkin Committed by Mimi Zohar

ima: rename hash calculation functions

Rename hash calculation functions to reflect meaning
and change argument order in conventional way.
Signed-off-by: default avatarDmitry Kasatkin <dmitry.kasatkin@intel.com>
Signed-off-by: default avatarMimi Zohar <zohar@linux.vnet.ibm.com>
parent 76bb28f6
...@@ -84,8 +84,8 @@ void ima_fs_cleanup(void); ...@@ -84,8 +84,8 @@ void ima_fs_cleanup(void);
int ima_inode_alloc(struct inode *inode); int ima_inode_alloc(struct inode *inode);
int ima_add_template_entry(struct ima_template_entry *entry, int violation, int ima_add_template_entry(struct ima_template_entry *entry, int violation,
const char *op, struct inode *inode); const char *op, struct inode *inode);
int ima_calc_hash(struct file *file, char *digest); int ima_calc_file_hash(struct file *file, char *digest);
int ima_calc_template_hash(int template_len, void *template, char *digest); int ima_calc_buffer_hash(const void *data, int len, char *digest);
int ima_calc_boot_aggregate(char *digest); int ima_calc_boot_aggregate(char *digest);
void ima_add_violation(struct inode *inode, const unsigned char *filename, void ima_add_violation(struct inode *inode, const unsigned char *filename,
const char *op, const char *cause); const char *op, const char *cause);
......
...@@ -50,8 +50,8 @@ int ima_store_template(struct ima_template_entry *entry, ...@@ -50,8 +50,8 @@ int ima_store_template(struct ima_template_entry *entry,
entry->template_len = sizeof(entry->template); entry->template_len = sizeof(entry->template);
if (!violation) { if (!violation) {
result = ima_calc_template_hash(entry->template_len, result = ima_calc_buffer_hash(&entry->template,
&entry->template, entry->template_len,
entry->digest); entry->digest);
if (result < 0) { if (result < 0) {
integrity_audit_msg(AUDIT_INTEGRITY_PCR, inode, integrity_audit_msg(AUDIT_INTEGRITY_PCR, inode,
...@@ -148,7 +148,7 @@ int ima_collect_measurement(struct integrity_iint_cache *iint, ...@@ -148,7 +148,7 @@ int ima_collect_measurement(struct integrity_iint_cache *iint,
u64 i_version = file->f_dentry->d_inode->i_version; u64 i_version = file->f_dentry->d_inode->i_version;
iint->ima_xattr.type = IMA_XATTR_DIGEST; iint->ima_xattr.type = IMA_XATTR_DIGEST;
result = ima_calc_hash(file, iint->ima_xattr.digest); result = ima_calc_file_hash(file, iint->ima_xattr.digest);
if (!result) { if (!result) {
iint->version = i_version; iint->version = i_version;
iint->flags |= IMA_COLLECTED; iint->flags |= IMA_COLLECTED;
......
...@@ -40,7 +40,7 @@ int ima_init_crypto(void) ...@@ -40,7 +40,7 @@ int ima_init_crypto(void)
/* /*
* Calculate the MD5/SHA1 file digest * Calculate the MD5/SHA1 file digest
*/ */
int ima_calc_hash(struct file *file, char *digest) int ima_calc_file_hash(struct file *file, char *digest)
{ {
loff_t i_size, offset = 0; loff_t i_size, offset = 0;
char *rbuf; char *rbuf;
...@@ -93,9 +93,9 @@ int ima_calc_hash(struct file *file, char *digest) ...@@ -93,9 +93,9 @@ int ima_calc_hash(struct file *file, char *digest)
} }
/* /*
* Calculate the hash of a given template * Calculate the hash of a given buffer
*/ */
int ima_calc_template_hash(int template_len, void *template, char *digest) int ima_calc_buffer_hash(const void *data, int len, char *digest)
{ {
struct { struct {
struct shash_desc shash; struct shash_desc shash;
...@@ -105,7 +105,7 @@ int ima_calc_template_hash(int template_len, void *template, char *digest) ...@@ -105,7 +105,7 @@ int ima_calc_template_hash(int template_len, void *template, char *digest)
desc.shash.tfm = ima_shash_tfm; desc.shash.tfm = ima_shash_tfm;
desc.shash.flags = 0; desc.shash.flags = 0;
return crypto_shash_digest(&desc.shash, template, template_len, digest); return crypto_shash_digest(&desc.shash, data, len, digest);
} }
static void __init ima_pcrread(int idx, u8 *pcr) static void __init ima_pcrread(int idx, u8 *pcr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment