[PATCH 4/6] md: dm-crypt: Add additional algo modes for inline encryption

From: Md Sadre Alam
Date: Tue Jul 30 2024 - 07:59:12 EST


Add support for AES-XTS-128, AES-CBC-128 and AES-CBC-256 algo
modes for inline encryption.

Signed-off-by: Md Sadre Alam <quic_mdalam@xxxxxxxxxxx>
---
drivers/md/dm-crypt.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index c0257d961968..884cf76fc4c6 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -2482,8 +2482,14 @@ static int crypt_select_inline_crypt_mode(struct dm_target *ti, char *cipher,
{
struct crypt_config *cc = ti->private;

- if (strcmp(cipher, "xts(aes)") == 0) {
+ if (strcmp(cipher, "xts(aes128)") == 0) {
+ cc->crypto_mode = BLK_ENCRYPTION_MODE_AES_128_XTS;
+ } else if (strcmp(cipher, "xts(aes256)") == 0) {
cc->crypto_mode = BLK_ENCRYPTION_MODE_AES_256_XTS;
+ } else if (strcmp(cipher, "cbc(aes128)") == 0) {
+ cc->crypto_mode = BLK_ENCRYPTION_MODE_AES_128_CBC;
+ } else if (strcmp(cipher, "cbc(aes256)") == 0) {
+ cc->crypto_mode = BLK_ENCRYPTION_MODE_AES_256_CBC;
} else {
ti->error = "Invalid cipher for inline_crypt";
return -EINVAL;
--
2.34.1