summaryrefslogtreecommitdiff
path: root/ubifs-utils/mkfs.ubifs/fscrypt.c
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2018-10-18 16:37:12 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2018-11-01 12:42:01 +0100
commit9c8caf5aca7527235afcbbb813e9bf490a239dee (patch)
treec5dbafb842920201295ae9572084f66467799d33 /ubifs-utils/mkfs.ubifs/fscrypt.c
parent922a6e998538a1ea57682d0d3373cb4d19e9dc02 (diff)
mkfs.ubifs: Compute encryption key descriptor automatically
...if none is given. To be compatible with fscryptctl. Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'ubifs-utils/mkfs.ubifs/fscrypt.c')
-rw-r--r--ubifs-utils/mkfs.ubifs/fscrypt.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/ubifs-utils/mkfs.ubifs/fscrypt.c b/ubifs-utils/mkfs.ubifs/fscrypt.c
index b9f9acc..ce6e2fc 100644
--- a/ubifs-utils/mkfs.ubifs/fscrypt.c
+++ b/ubifs-utils/mkfs.ubifs/fscrypt.c
@@ -242,12 +242,17 @@ struct fscrypt_context *init_fscrypt_context(const char *cipher_name,
return NULL;
}
- if (parse_key_descriptor(key_descriptor, master_key_descriptor))
- return NULL;
-
if (load_master_key(key_file, fscrypt_cipher))
return NULL;
+ if (!key_descriptor) {
+ if (derive_key_descriptor(fscrypt_masterkey, master_key_descriptor))
+ return NULL;
+ } else {
+ if (parse_key_descriptor(key_descriptor, master_key_descriptor))
+ return NULL;
+ }
+
RAND_bytes((void *)nonce, FS_KEY_DERIVATION_NONCE_SIZE);
new_fctx = xmalloc(sizeof(*new_fctx));