From: Ildar Muslukhov Date: Mon, 2 Mar 2015 16:54:19 +0000 (-0500) Subject: misc: teach mke2fs to create encrypted file systems X-Git-Tag: v1.43-WIP-2015-05-18~60 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbb859496ac0509e586b7c364927bc2110d76179;p=thirdparty%2Fe2fsprogs.git misc: teach mke2fs to create encrypted file systems Also enable support for encryption in e2fsprogs. Signed-off-by: Ildar Muslukhov Signed-off-by: Theodore Ts'o --- diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 0f83efc52..d75dd7654 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -598,7 +598,8 @@ typedef struct ext2_icount *ext2_icount_t; EXT4_FEATURE_INCOMPAT_FLEX_BG|\ EXT4_LIB_INCOMPAT_MMP|\ EXT4_FEATURE_INCOMPAT_64BIT|\ - EXT4_FEATURE_INCOMPAT_INLINE_DATA) + EXT4_FEATURE_INCOMPAT_INLINE_DATA|\ + EXT4_FEATURE_INCOMPAT_ENCRYPT) #define EXT2_LIB_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\ EXT4_FEATURE_RO_COMPAT_HUGE_FILE|\ @@ -615,7 +616,7 @@ typedef struct ext2_icount *ext2_icount_t; * These features are only allowed if EXT2_FLAG_SOFTSUPP_FEATURES is passed * to ext2fs_openfs() */ -#define EXT2_LIB_SOFTSUPP_INCOMPAT (EXT4_FEATURE_INCOMPAT_ENCRYPT) +#define EXT2_LIB_SOFTSUPP_INCOMPAT (0) #define EXT2_LIB_SOFTSUPP_RO_COMPAT (EXT4_FEATURE_RO_COMPAT_REPLICA) diff --git a/misc/mke2fs.c b/misc/mke2fs.c index aeb852f04..ec450adf9 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1076,7 +1076,8 @@ static __u32 ok_features[3] = { EXT4_FEATURE_INCOMPAT_FLEX_BG| EXT4_FEATURE_INCOMPAT_MMP | EXT4_FEATURE_INCOMPAT_64BIT| - EXT4_FEATURE_INCOMPAT_INLINE_DATA, + EXT4_FEATURE_INCOMPAT_INLINE_DATA| + EXT4_FEATURE_INCOMPAT_ENCRYPT, /* R/O compat */ EXT2_FEATURE_RO_COMPAT_LARGE_FILE| EXT4_FEATURE_RO_COMPAT_HUGE_FILE| @@ -2910,6 +2911,15 @@ int main (int argc, char *argv[]) sizeof(fs->super->s_last_mounted)); } + /* Set current default encryption algorithms for data and + * filename encryption */ + if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_ENCRYPT) { + fs->super->s_encrypt_algos[0] = + EXT4_ENCRYPTION_MODE_AES_256_XTS; + fs->super->s_encrypt_algos[1] = + EXT4_ENCRYPTION_MODE_AES_256_CBC; + } + if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super, EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) fs->super->s_checksum_type = EXT2_CRC32C_CHKSUM;