Merge branch 'upstream' into tizen
[platform/upstream/cryptsetup.git] / lib / utils_dm.h
index 1501eb5..79212a2 100644 (file)
@@ -3,8 +3,8 @@
  *
  * Copyright (C) 2004 Jana Saout <jana@saout.de>
  * Copyright (C) 2004-2007 Clemens Fruhwirth <clemens@endorphin.org>
- * Copyright (C) 2009-2020 Red Hat, Inc. All rights reserved.
- * Copyright (C) 2009-2020 Milan Broz
+ * Copyright (C) 2009-2023 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2009-2023 Milan Broz
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -25,7 +25,8 @@
 #define _UTILS_DM_H
 
 /* device-mapper library helpers */
-#include <inttypes.h>
+#include <stddef.h>
+#include <stdint.h>
 
 struct crypt_device;
 struct volume_key;
@@ -69,9 +70,15 @@ static inline uint32_t act2dmflags(uint32_t act_flags)
 #define DM_BITLK_ELEPHANT_SUPPORTED (1 << 21) /* Elephant diffuser for BITLK supported */
 #define DM_VERITY_SIGNATURE_SUPPORTED (1 << 22) /* Verity option root_hash_sig_key_desc supported */
 #define DM_INTEGRITY_DISCARDS_SUPPORTED (1 << 23) /* dm-integrity discards/TRIM option is supported */
+#define DM_INTEGRITY_RESIZE_SUPPORTED (1 << 23) /* dm-integrity resize of the integrity device supported (introduced in the same version as discards)*/
+#define DM_VERITY_PANIC_CORRUPTION_SUPPORTED (1 << 24) /* dm-verity panic on corruption  */
+#define DM_CRYPT_NO_WORKQUEUE_SUPPORTED (1 << 25) /* dm-crypt suppot for bypassing workqueues  */
+#define DM_INTEGRITY_FIX_HMAC_SUPPORTED (1 << 26) /* hmac covers also superblock */
+#define DM_INTEGRITY_RESET_RECALC_SUPPORTED (1 << 27) /* dm-integrity automatic recalculation supported */
+#define DM_VERITY_TASKLETS_SUPPORTED (1 << 28) /* dm-verity tasklets supported */
 
 typedef enum { DM_CRYPT = 0, DM_VERITY, DM_INTEGRITY, DM_LINEAR, DM_ERROR, DM_ZERO, DM_UNKNOWN } dm_target_type;
-enum tdirection { TARGET_SET = 1, TARGET_QUERY };
+enum tdirection { TARGET_EMPTY = 0, TARGET_SET, TARGET_QUERY };
 
 int dm_flags(struct crypt_device *cd, dm_target_type target, uint32_t *flags);
 
@@ -89,6 +96,12 @@ int dm_flags(struct crypt_device *cd, dm_target_type target, uint32_t *flags);
 
 #define DM_ACTIVE_INTEGRITY_PARAMS     (1 << 9)
 
+#define DM_ACTIVE_JOURNAL_CRYPT_KEY    (1 << 10)
+#define DM_ACTIVE_JOURNAL_CRYPT_KEYSIZE        (1 << 11)
+
+#define DM_ACTIVE_JOURNAL_MAC_KEY      (1 << 12)
+#define DM_ACTIVE_JOURNAL_MAC_KEYSIZE  (1 << 13)
+
 struct dm_target {
        dm_target_type type;
        enum tdirection direction;
@@ -118,9 +131,8 @@ struct dm_target {
                const char *root_hash_sig_key_desc;
 
                uint64_t hash_offset;   /* hash offset in blocks (not header) */
-               uint64_t hash_blocks;   /* size of hash device (in hash blocks) */
                uint64_t fec_offset;    /* FEC offset in blocks (not header) */
-               uint64_t fec_blocks;    /* size of FEC device (in hash blocks) */
+               uint64_t fec_blocks;    /* FEC blocks covering data + hash + padding (foreign metadata)*/
                struct crypt_params_verity *vp;
        } verity;
        struct {
@@ -146,6 +158,8 @@ struct dm_target {
                struct device *meta_device;
 
                bool fix_padding;
+               bool fix_hmac;
+               bool legacy_recalc;
        } integrity;
        struct {
                uint64_t offset;
@@ -185,8 +199,8 @@ int dm_crypt_target_set(struct dm_target *tgt, uint64_t seg_offset, uint64_t seg
        uint32_t tag_size, uint32_t sector_size);
 int dm_verity_target_set(struct dm_target *tgt, uint64_t seg_offset, uint64_t seg_size,
        struct device *data_device, struct device *hash_device, struct device *fec_device,
-       const char *root_hash, uint32_t root_hash_size, const char *root_hash_sig_key_desc,
-       uint64_t hash_offset_block, uint64_t hash_blocks, struct crypt_params_verity *vp);
+       const char *root_hash, uint32_t root_hash_size, const charroot_hash_sig_key_desc,
+       uint64_t hash_offset_block, uint64_t fec_blocks, struct crypt_params_verity *vp);
 int dm_integrity_target_set(struct crypt_device *cd,
        struct dm_target *tgt, uint64_t seg_offset, uint64_t seg_size,
        struct device *meta_device,
@@ -217,6 +231,7 @@ int dm_resume_and_reinstate_key(struct crypt_device *cd, const char *name,
                                const struct volume_key *vk);
 int dm_error_device(struct crypt_device *cd, const char *name);
 int dm_clear_device(struct crypt_device *cd, const char *name);
+int dm_cancel_deferred_removal(const char *name);
 
 const char *dm_get_dir(void);