]> www.infradead.org Git - mtd-utils.git/commitdiff
mkfs.ubifs: Make encryption dependend on (not-yet-existant) command line options
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Thu, 18 Oct 2018 14:36:59 +0000 (16:36 +0200)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Thu, 1 Nov 2018 11:40:14 +0000 (12:40 +0100)
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
ubifs-utils/mkfs.ubifs/mkfs.ubifs.c

index 8be84ca1e99cce38784bc89eea401c9ff726af71..5be390e93da9c56d488fd6986af3ea843eac8367 100644 (file)
@@ -217,6 +217,7 @@ static struct inum_mapping **hash_table;
 /* Inode creation sequence number */
 static unsigned long long creat_sqnum;
 
+//TODO: add options for double hash and encryption
 static const char *optstring = "d:r:m:o:D:yh?vVe:c:g:f:Fp:k:x:X:j:R:l:j:UQqa";
 
 static const struct option longopts[] = {
@@ -654,6 +655,8 @@ static int get_options(int argc, char**argv)
        c->max_leb_cnt = -1;
        c->max_bud_bytes = -1;
        c->log_lebs = -1;
+       c->double_hash = 0;
+       c->encrypted = 0;
 
        while (1) {
                opt = getopt_long(argc, argv, optstring, longopts, &i);
@@ -2826,15 +2829,16 @@ static int init(void)
        sz = sizeof(struct inum_mapping *) * HASH_TABLE_SIZE;
        hash_table = xzalloc(sz);
 
-       //TODO make this a parameter
-       RAND_bytes((void *)master_key_descriptor, FS_KEY_DESCRIPTOR_SIZE);
-       RAND_bytes((void *)nonce, FS_KEY_DERIVATION_NONCE_SIZE);
+       if (c->encrypted) {
+               RAND_bytes((void *)master_key_descriptor,
+                               FS_KEY_DESCRIPTOR_SIZE);
+               RAND_bytes((void *)nonce, FS_KEY_DERIVATION_NONCE_SIZE);
 
-       root_fctx = init_fscrypt_context(FS_POLICY_FLAGS_PAD_4,
-                                       master_key_descriptor, nonce);
-       print_fscrypt_master_key_descriptor(root_fctx);
-       c->double_hash = 1;
-       c->encrypted = 1;
+               root_fctx = init_fscrypt_context(FS_POLICY_FLAGS_PAD_4,
+                                               master_key_descriptor, nonce);
+               print_fscrypt_master_key_descriptor(root_fctx);
+               c->double_hash = 1;
+       }
 
        err = init_compression();
        if (err)