Lines Matching +full:unlock +full:- +full:keys

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2005-2010 IBM Corporation
19 #include <keys/encrypted-type.h>
24 #define EVMKEY "evm-key"
41 * evm_set_key() - set EVM HMAC key from the kernel
46 * without using the "encrypted" key subsystem keys. It can be used
48 * keys.
56 rc = -EBUSY; in evm_set_key()
59 rc = -EINVAL; in evm_set_key()
84 return ERR_PTR(-ENOKEY); in init_desc()
90 return ERR_PTR(-EINVAL); in init_desc()
100 goto unlock; in init_desc()
118 unlock: in init_desc()
124 return ERR_PTR(-ENOMEM); in init_desc()
126 desc->tfm = *tfm; in init_desc()
158 hmac_misc.ino = inode->i_ino; in hmac_add_misc()
159 hmac_misc.generation = inode->i_generation; in hmac_add_misc()
169 hmac_misc.uid = from_kuid(&init_user_ns, inode->i_uid); in hmac_add_misc()
170 hmac_misc.gid = from_kgid(&init_user_ns, inode->i_gid); in hmac_add_misc()
171 hmac_misc.mode = inode->i_mode; in hmac_add_misc()
175 crypto_shash_update(desc, (u8 *)&inode->i_sb->s_uuid, UUID_SIZE); in hmac_add_misc()
208 * each xattr, but attempt to re-use the previously allocated memory.
225 if (!(inode->i_opflags & IOP_XATTR) || in evm_calc_hmac_or_hash()
226 inode->i_sb->s_user_ns != &init_user_ns) in evm_calc_hmac_or_hash()
227 return -EOPNOTSUPP; in evm_calc_hmac_or_hash()
229 desc = init_desc(type, data->hdr.algo); in evm_calc_hmac_or_hash()
233 data->hdr.length = crypto_shash_digestsize(desc->tfm); in evm_calc_hmac_or_hash()
235 error = -ENODATA; in evm_calc_hmac_or_hash()
239 if (strcmp(xattr->name, XATTR_NAME_IMA) == 0) in evm_calc_hmac_or_hash()
243 * Skip non-enabled xattrs for locally calculated in evm_calc_hmac_or_hash()
246 if (type != EVM_XATTR_PORTABLE_DIGSIG && !xattr->enabled) in evm_calc_hmac_or_hash()
250 && !strcmp(xattr->name, req_xattr_name)) { in evm_calc_hmac_or_hash()
268 size = vfs_getxattr_alloc(&init_user_ns, dentry, xattr->name, in evm_calc_hmac_or_hash()
270 if (size == -ENOMEM) { in evm_calc_hmac_or_hash()
271 error = -ENOMEM; in evm_calc_hmac_or_hash()
278 xattr->name, NULL, 0); in evm_calc_hmac_or_hash()
281 dentry->d_name.name, xattr->name, size, in evm_calc_hmac_or_hash()
290 pr_debug("%s: (%zu) [%*phN]", xattr->name, xattr_size, in evm_calc_hmac_or_hash()
293 dump_security_xattr(xattr->name, xattr_value, in evm_calc_hmac_or_hash()
296 hmac_add_misc(desc, inode, type, data->digest); in evm_calc_hmac_or_hash()
300 error = -EPERM; in evm_calc_hmac_or_hash()
330 if (iint && (iint->flags & EVM_IMMUTABLE_DIGSIG)) in evm_is_immutable()
337 if (rc == -ENODATA) in evm_is_immutable()
341 if (xattr_data->type == EVM_XATTR_PORTABLE_DIGSIG) in evm_is_immutable()
371 return -EPERM; in evm_update_evmxattr()
382 } else if (rc == -ENODATA && (inode->i_opflags & IOP_XATTR)) { in evm_update_evmxattr()
399 crypto_shash_update(desc, lsm_xattr->value, lsm_xattr->value_len); in evm_init_hmac()
406 * Get the key from the TPM for the SHA1-HMAC
416 return -ENOENT; in evm_init_key()
418 down_read(&evm_key->sem); in evm_init_key()
419 ekp = evm_key->payload.data[0]; in evm_init_key()
421 rc = evm_set_key(ekp->decrypted_data, ekp->decrypted_datalen); in evm_init_key()
424 memset(ekp->decrypted_data, 0, ekp->decrypted_datalen); in evm_init_key()
425 up_read(&evm_key->sem); in evm_init_key()