int dm_tree_node_add_striped_target(struct dm_tree_node *node,
uint64_t size,
uint32_t stripe_size);
+
+#define DM_CRYPT_IV_DEFAULT UINT64_C(-1) /* iv_offset == seg offset */
+/*
+ * Function accepts one string in cipher specification
+ * (chainmode and iv should be NULL because included in cipher string)
+ * or
+ * separate arguments which will be joined to "cipher-chainmode-iv"
+ */
+int dm_tree_node_add_crypt_target(struct dm_tree_node *node,
+ uint64_t size,
+ const char *cipher,
+ const char *chainmode,
+ const char *iv,
+ uint64_t iv_offset,
+ const char *key);
int dm_tree_node_add_mirror_target(struct dm_tree_node *node,
uint64_t size);
/* Supported segment types */
enum {
- SEG_ERROR,
+ SEG_CRYPT,
+ SEG_ERROR,
SEG_LINEAR,
SEG_MIRRORED,
SEG_SNAPSHOT,
unsigned type;
const char *target;
} dm_segtypes[] = {
+ { SEG_CRYPT, "crypt" },
{ SEG_ERROR, "error" },
{ SEG_LINEAR, "linear" },
{ SEG_MIRRORED, "mirror" },
uint64_t size;
- unsigned area_count; /* Linear + Striped + Mirrored */
- struct dm_list areas; /* Linear + Striped + Mirrored */
+ unsigned area_count; /* Linear + Striped + Mirrored + Crypt */
+ struct dm_list areas; /* Linear + Striped + Mirrored + Crypt */
uint32_t stripe_size; /* Striped */
unsigned mirror_area_count; /* Mirror */
uint32_t flags; /* Mirror log */
char *uuid; /* Clustered mirror log */
+
+ const char *cipher; /* Crypt */
+ const char *chainmode; /* Crypt */
+ const char *iv; /* Crypt */
+ uint64_t iv_offset; /* Crypt */
+ const char *key; /* Crypt */
};
/* Per-device properties */
case SEG_STRIPED:
EMIT_PARAMS(pos, "%u %u", seg->area_count, seg->stripe_size);
break;
+ case SEG_CRYPT:
+ EMIT_PARAMS(pos, "%s%s%s%s%s %s %" PRIu64, seg->cipher,
+ seg->chainmode ? "-" : "", seg->chainmode ?: "",
+ seg->iv ? "-" : "", seg->iv ?: "", seg->key,
+ seg->iv_offset != DM_CRYPT_IV_DEFAULT ?
+ seg->iv_offset : *seg_start);
+ break;
}
switch(seg->type) {
case SEG_SNAPSHOT_ORIGIN:
case SEG_ZERO:
break;
+ case SEG_CRYPT:
case SEG_LINEAR:
case SEG_MIRRORED:
case SEG_STRIPED:
return 1;
}
+int dm_tree_node_add_crypt_target(struct dm_tree_node *node,
+ uint64_t size,
+ const char *cipher,
+ const char *chainmode,
+ const char *iv,
+ uint64_t iv_offset,
+ const char *key)
+{
+ struct load_segment *seg;
+
+ if (!(seg = _add_segment(node, SEG_CRYPT, size)))
+ return_0;
+
+ seg->cipher = cipher;
+ seg->chainmode = chainmode;
+ seg->iv = iv;
+ seg->iv_offset = iv_offset;
+ seg->key = key;
+
+ return 1;
+}
+
int dm_tree_node_add_mirror_target_log(struct dm_tree_node *node,
uint32_t region_size,
unsigned clustered,