Commit | Line | Data |
---|---|---|
cd2ce8ab GLV |
1 | From d4434c05e7c0cf05d87089404cfa2deedc60811a Mon Sep 17 00:00:00 2001 |
2 | From: Ingo Franzki <ifranzki@linux.ibm.com> | |
3 | Date: Mon, 29 Oct 2018 16:47:40 +0100 | |
4 | Subject: [PATCH] crypto: Add support for LUKS2 | |
5 | ||
6 | Cryptsetup version 2.0 added support for LUKS2. | |
7 | This patch adds support for mounting LUKS2 volumes with | |
8 | pam_mount. | |
9 | ||
10 | Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com> | |
11 | --- | |
12 | src/crypto-dmc.c | 10 ++++++++-- | |
13 | 1 file changed, 8 insertions(+), 2 deletions(-) | |
14 | ||
15 | diff --git a/src/crypto-dmc.c b/src/crypto-dmc.c | |
16 | index d0ab6ca..abd0358 100644 | |
17 | --- a/src/crypto-dmc.c | |
18 | +++ b/src/crypto-dmc.c | |
19 | @@ -21,6 +21,12 @@ | |
20 | #include "libcryptmount.h" | |
21 | #include "pam_mount.h" | |
22 | ||
23 | +#ifndef CRYPT_LUKS | |
24 | + #define CRYPT_LUKS NULL /* Passing NULL to crypt_load will | |
25 | + default to LUKS(1) on older | |
26 | + libcryptsetup versions. */ | |
27 | +#endif | |
28 | + | |
29 | /** | |
30 | * dmc_is_luks - check if @path points to a LUKS volume (cf. normal dm-crypt) | |
31 | * @path: path to the crypto container | |
32 | @@ -48,7 +54,7 @@ EXPORT_SYMBOL int ehd_is_luks(const char *path, bool blkdev) | |
33 | ||
34 | ret = crypt_init(&cd, device); | |
35 | if (ret == 0) { | |
36 | - ret = crypt_load(cd, CRYPT_LUKS1, NULL); | |
37 | + ret = crypt_load(cd, CRYPT_LUKS, NULL); | |
38 | if (ret == -EINVAL) | |
39 | ret = false; | |
40 | else if (ret == 0) | |
41 | @@ -106,7 +112,7 @@ static bool dmc_run(const struct ehd_mount_request *req, | |
42 | #endif | |
43 | } | |
44 | ||
45 | - ret = crypt_load(cd, CRYPT_LUKS1, NULL); | |
46 | + ret = crypt_load(cd, CRYPT_LUKS, NULL); | |
47 | if (ret == 0) { | |
48 | ret = crypt_activate_by_passphrase(cd, mt->crypto_name, | |
49 | CRYPT_ANY_SLOT, req->key_data, req->key_size, flags); | |
50 | -- | |
51 | 2.21.0 |