From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@google.com>
Subject: [f2fs-dev] [PATCH] f2fscrypt: show more information of policy
Date: Mon, 30 Mar 2020 12:25:24 -0700 [thread overview]
Message-ID: <20200330192524.8931-1-jaegeuk@kernel.org> (raw)
From: Jaegeuk Kim <jaegeuk@google.com>
This patch gives more information of encryption policy.
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I04a6826aa4497554ce79d884d495b3dda1b64fac
---
tools/f2fscrypt.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/tools/f2fscrypt.c b/tools/f2fscrypt.c
index fe3e0ff..bb3e70f 100644
--- a/tools/f2fscrypt.c
+++ b/tools/f2fscrypt.c
@@ -63,6 +63,8 @@
#define F2FS_ENCRYPTION_MODE_AES_256_GCM 2
#define F2FS_ENCRYPTION_MODE_AES_256_CBC 3
#define F2FS_ENCRYPTION_MODE_AES_256_CTS 4
+#define F2FS_ENCRYPTION_MODE_ADIANTUM 9
+#define F2FS_ENCRYPTION_MODE_PRIVATE 127
#define F2FS_AES_256_XTS_KEY_SIZE 64
#define F2FS_AES_256_GCM_KEY_SIZE 32
@@ -531,6 +533,33 @@ static void get_passphrase(char *passphrase, int len)
*p = '\0';
}
+struct enc_mode_map {
+ int mode;
+ char name[255];
+};
+
+static const struct enc_mode_map enc_mode_str[] = {
+ {F2FS_ENCRYPTION_MODE_INVALID, "invalid"},
+ {F2FS_ENCRYPTION_MODE_AES_256_XTS, "aes_256_xts"},
+ {F2FS_ENCRYPTION_MODE_AES_256_GCM, "aes_256_gcm"},
+ {F2FS_ENCRYPTION_MODE_AES_256_CBC, "aes_256_cbc"},
+ {F2FS_ENCRYPTION_MODE_AES_256_CTS, "aes_256_cts"},
+ {F2FS_ENCRYPTION_MODE_ADIANTUM, "adiantum"},
+ {F2FS_ENCRYPTION_MODE_PRIVATE, "ice"},
+};
+
+static const char *get_crypt_mode(int mode)
+{
+ int i;
+
+ for (i = 0; i < (sizeof(enc_mode_str) / sizeof(enc_mode_str[0])); ++i) {
+ if (mode == enc_mode_str[i].mode) {
+ return enc_mode_str[i].name;
+ }
+ }
+ return "N/A";
+}
+
struct keyring_map {
char name[4];
size_t name_len;
@@ -827,6 +856,11 @@ static void do_get_policy(int argc, char **argv, const struct cmd_desc *cmd)
for (j = 0; j < F2FS_KEY_DESCRIPTOR_SIZE; j++) {
printf("%02x", (unsigned char) policy.master_key_descriptor[j]);
}
+ printf("\tversion: %u\n", policy.version);
+ printf("\tcontents_encryption_mode : %s\n",
+ get_crypt_mode(policy.contents_encryption_mode));
+ printf("\tfilenames_encryption_mode: %s\n",
+ get_crypt_mode(policy.filenames_encryption_mode));
fputc('\n', stdout);
}
exit(0);
--
2.26.0.rc2.310.g2932bb562d-goog
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next reply other threads:[~2020-03-30 19:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-30 19:25 Jaegeuk Kim [this message]
2020-03-30 19:51 ` [f2fs-dev] [PATCH] f2fscrypt: show more information of policy Eric Biggers
2020-03-30 20:18 ` Jaegeuk Kim
2020-03-30 20:37 ` Eric Biggers
2020-03-31 4:03 ` Jaegeuk Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200330192524.8931-1-jaegeuk@kernel.org \
--to=jaegeuk@kernel.org \
--cc=jaegeuk@google.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.