summaryrefslogtreecommitdiff
path: root/cmd_key.c
blob: 654ad774101972058542432d94929460cff4f37b (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
#include <errno.h>
#include <unistd.h>
#include <uuid/uuid.h>

#include "cmds.h"
#include "checksum.h"
#include "crypto.h"
#include "libbcache.h"

int cmd_unlock(int argc, char *argv[])
{
	struct bch_sb *sb;
	char *passphrase;

	if (argc != 2)
		die("please supply a single device");

	sb = bcache_super_read(argv[1]);

	passphrase = read_passphrase("Enter passphrase: ");

	add_bcache_key(sb, passphrase);

	memzero_explicit(passphrase, strlen(passphrase));
	free(passphrase);
	return 0;
}