linux/include/uapi/linux/fscrypt.h

/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
 * fscrypt user API
 *
 * These ioctls can be used on filesystems that support fscrypt.  See the
 * "User API" section of Documentation/filesystems/fscrypt.rst.
 */
#ifndef _UAPI_LINUX_FSCRYPT_H
#define _UAPI_LINUX_FSCRYPT_H

#include <linux/ioctl.h>
#include <linux/types.h>

/* Encryption policy flags */
#define FSCRYPT_POLICY_FLAGS_PAD_4
#define FSCRYPT_POLICY_FLAGS_PAD_8
#define FSCRYPT_POLICY_FLAGS_PAD_16
#define FSCRYPT_POLICY_FLAGS_PAD_32
#define FSCRYPT_POLICY_FLAGS_PAD_MASK
#define FSCRYPT_POLICY_FLAG_DIRECT_KEY
#define FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64
#define FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32

/* Encryption algorithms */
#define FSCRYPT_MODE_AES_256_XTS
#define FSCRYPT_MODE_AES_256_CTS
#define FSCRYPT_MODE_AES_128_CBC
#define FSCRYPT_MODE_AES_128_CTS
#define FSCRYPT_MODE_SM4_XTS
#define FSCRYPT_MODE_SM4_CTS
#define FSCRYPT_MODE_ADIANTUM
#define FSCRYPT_MODE_AES_256_HCTR2
/* If adding a mode number > 10, update FSCRYPT_MODE_MAX in fscrypt_private.h */

/*
 * Legacy policy version; ad-hoc KDF and no key verification.
 * For new encrypted directories, use fscrypt_policy_v2 instead.
 *
 * Careful: the .version field for this is actually 0, not 1.
 */
#define FSCRYPT_POLICY_V1
#define FSCRYPT_KEY_DESCRIPTOR_SIZE
struct fscrypt_policy_v1 {};

/*
 * Process-subscribed "logon" key description prefix and payload format.
 * Deprecated; prefer FS_IOC_ADD_ENCRYPTION_KEY instead.
 */
#define FSCRYPT_KEY_DESC_PREFIX
#define FSCRYPT_KEY_DESC_PREFIX_SIZE
#define FSCRYPT_MAX_KEY_SIZE
struct fscrypt_key {};

/*
 * New policy version with HKDF and key verification (recommended).
 */
#define FSCRYPT_POLICY_V2
#define FSCRYPT_KEY_IDENTIFIER_SIZE
struct fscrypt_policy_v2 {};

/* Struct passed to FS_IOC_GET_ENCRYPTION_POLICY_EX */
struct fscrypt_get_policy_ex_arg {};

/*
 * v1 policy keys are specified by an arbitrary 8-byte key "descriptor",
 * matching fscrypt_policy_v1::master_key_descriptor.
 */
#define FSCRYPT_KEY_SPEC_TYPE_DESCRIPTOR

/*
 * v2 policy keys are specified by a 16-byte key "identifier" which the kernel
 * calculates as a cryptographic hash of the key itself,
 * matching fscrypt_policy_v2::master_key_identifier.
 */
#define FSCRYPT_KEY_SPEC_TYPE_IDENTIFIER

/*
 * Specifies a key, either for v1 or v2 policies.  This doesn't contain the
 * actual key itself; this is just the "name" of the key.
 */
struct fscrypt_key_specifier {};

/*
 * Payload of Linux keyring key of type "fscrypt-provisioning", referenced by
 * fscrypt_add_key_arg::key_id as an alternative to fscrypt_add_key_arg::raw.
 */
struct fscrypt_provisioning_key_payload {};

/* Struct passed to FS_IOC_ADD_ENCRYPTION_KEY */
struct fscrypt_add_key_arg {};

/* Struct passed to FS_IOC_REMOVE_ENCRYPTION_KEY */
struct fscrypt_remove_key_arg {};

/* Struct passed to FS_IOC_GET_ENCRYPTION_KEY_STATUS */
struct fscrypt_get_key_status_arg {};

#define FS_IOC_SET_ENCRYPTION_POLICY
#define FS_IOC_GET_ENCRYPTION_PWSALT
#define FS_IOC_GET_ENCRYPTION_POLICY
#define FS_IOC_GET_ENCRYPTION_POLICY_EX
#define FS_IOC_ADD_ENCRYPTION_KEY
#define FS_IOC_REMOVE_ENCRYPTION_KEY
#define FS_IOC_REMOVE_ENCRYPTION_KEY_ALL_USERS
#define FS_IOC_GET_ENCRYPTION_KEY_STATUS
#define FS_IOC_GET_ENCRYPTION_NONCE

/**********************************************************************/

/* old names; don't add anything new here! */
#ifndef __KERNEL__
#define fscrypt_policy
#define FS_KEY_DESCRIPTOR_SIZE
#define FS_POLICY_FLAGS_PAD_4
#define FS_POLICY_FLAGS_PAD_8
#define FS_POLICY_FLAGS_PAD_16
#define FS_POLICY_FLAGS_PAD_32
#define FS_POLICY_FLAGS_PAD_MASK
#define FS_POLICY_FLAG_DIRECT_KEY
#define FS_POLICY_FLAGS_VALID
#define FS_ENCRYPTION_MODE_INVALID
#define FS_ENCRYPTION_MODE_AES_256_XTS
#define FS_ENCRYPTION_MODE_AES_256_GCM
#define FS_ENCRYPTION_MODE_AES_256_CBC
#define FS_ENCRYPTION_MODE_AES_256_CTS
#define FS_ENCRYPTION_MODE_AES_128_CBC
#define FS_ENCRYPTION_MODE_AES_128_CTS
#define FS_ENCRYPTION_MODE_ADIANTUM
#define FS_KEY_DESC_PREFIX
#define FS_KEY_DESC_PREFIX_SIZE
#define FS_MAX_KEY_SIZE
#endif /* !__KERNEL__ */

#endif /* _UAPI_LINUX_FSCRYPT_H */