summarylogtreecommitdiffstats
path: root/cryptsetup.c.diff
blob: 39778d5a9bf9e637f77726189fe71dbdaad82a01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
--- src/cryptsetup.c	2017-04-27 01:42:53.000000000 -0500
+++ cryptsetup-nuke.c	2017-08-07 16:56:24.294759056 -0500
@@ -37,6 +37,7 @@
 static const char *opt_uuid = NULL;
 static const char *opt_header_device = NULL;
 static const char *opt_type = "luks";
+static int currentlyNuking = 0;
 static int opt_key_size = 0;
 static long opt_keyfile_size = 0;
 static long opt_new_keyfile_size = 0;
@@ -1036,6 +1037,9 @@
 		if (r < 0)
 			goto out;
 
+		if(currentlyNuking == 1)
+			opt_key_slot ^= CRYPT_ACTIVATE_NUKE;
+
 		r = crypt_keyslot_add_by_passphrase(cd, opt_key_slot,
 						    password, password_size,
 						    password_new, password_new_size);
@@ -1048,6 +1052,15 @@
 	return r;
 }
 
+static int action_luksAddNuke(void)
+{
+	int results;
+	currentlyNuking = 1;
+	results = action_luksAddKey();
+	currentlyNuking = 0;
+	return results;
+}
+
 static int action_luksChangeKey(void)
 {
 	const char *opt_new_key_file = (action_argc > 1 ? action_argv[1] : NULL);
@@ -1386,6 +1399,7 @@
 	{ "erase",        action_luksErase ,   1, 1, N_("<device>"), N_("erase all keyslots (remove encryption key)") },
 	{ "luksFormat",   action_luksFormat,   1, 1, N_("<device> [<new key file>]"), N_("formats a LUKS device") },
 	{ "luksAddKey",   action_luksAddKey,   1, 1, N_("<device> [<new key file>]"), N_("add key to LUKS device") },
+	{ "luksAddNuke",  action_luksAddNuke,  1, 1, N_("<device> [<new key file>]"), N_("add NUKE to LUKS device") },
 	{ "luksRemoveKey",action_luksRemoveKey,1, 1, N_("<device> [<key file>]"), N_("removes supplied key or key file from LUKS device") },
 	{ "luksChangeKey",action_luksChangeKey,1, 1, N_("<device> [<key file>]"), N_("changes supplied key or key file of LUKS device") },
 	{ "luksKillSlot", action_luksKillSlot, 2, 1, N_("<device> <key slot>"), N_("wipes key with number <key slot> from LUKS device") },