16 #include <linux/module.h>
18 #include <linux/xattr.h>
23 #define EVMKEY "evm-key"
24 #define MAX_KEY_SIZE 128
55 pr_err(
"Can not allocate %s (reason: %ld)\n", algo, rc);
63 crypto_free_shash(*tfm);
73 desc =
kmalloc(
sizeof(*desc) + crypto_shash_descsize(*tfm),
81 rc = crypto_shash_init(desc);
106 memset(&hmac_misc, 0,
sizeof hmac_misc);
107 hmac_misc.ino = inode->
i_ino;
111 hmac_misc.mode = inode->
i_mode;
124 const char *req_xattr_name,
125 const char *req_xattr_value,
126 size_t req_xattr_value_len,
127 char type,
char *digest)
129 struct inode *inode = dentry->
d_inode;
132 size_t xattr_size = 0;
133 char *xattr_value =
NULL;
137 if (!inode->
i_op || !inode->
i_op->getxattr)
139 desc = init_desc(type);
141 return PTR_ERR(desc);
145 if ((req_xattr_name && req_xattr_value)
146 && !
strcmp(*xattrname, req_xattr_name)) {
149 req_xattr_value_len);
153 &xattr_value, xattr_size,
GFP_NOFS);
165 hmac_add_misc(desc, inode, digest);
174 const char *req_xattr_value,
size_t req_xattr_value_len,
177 return evm_calc_hmac_or_hash(dentry, req_xattr_name, req_xattr_value,
182 const char *req_xattr_value,
size_t req_xattr_value_len,
185 return evm_calc_hmac_or_hash(dentry, req_xattr_name, req_xattr_value,
195 const char *xattr_value,
size_t xattr_value_len)
197 struct inode *inode = dentry->
d_inode;
202 xattr_value_len, xattr_data.
digest);
207 sizeof(xattr_data), 0);
222 return PTR_ERR(desc);
226 hmac_add_misc(desc, inode, hmac_val);
245 ekp = evm_key->payload.data;