evm: add evm_inode_init_security to initialize new files

Initialize 'security.evm' for new files.

Changelog v7:
- renamed evm_inode_post_init_security to evm_inode_init_security
- moved struct xattr definition to earlier patch
- allocate xattr name
Changelog v6:
- Use 'struct evm_ima_xattr_data'

Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
This commit is contained in:
Mimi Zohar
2011-03-09 14:40:44 -05:00
parent 975d294373
commit cb72318069
4 changed files with 72 additions and 0 deletions

View File

@@ -157,6 +157,26 @@ int evm_update_evmxattr(struct dentry *dentry, const char *xattr_name,
return rc;
}
int evm_init_hmac(struct inode *inode, const struct xattr *lsm_xattr,
char *hmac_val)
{
struct hash_desc desc;
struct scatterlist sg[1];
int error;
error = init_desc(&desc);
if (error != 0) {
printk(KERN_INFO "init_desc failed\n");
return error;
}
sg_init_one(sg, lsm_xattr->value, lsm_xattr->value_len);
crypto_hash_update(&desc, sg, lsm_xattr->value_len);
hmac_add_misc(&desc, inode, hmac_val);
crypto_free_hash(desc.tfm);
return 0;
}
/*
* Get the key from the TPM for the SHA1-HMAC
*/