Skip to content

Commit d209ce3

Browse files
uudiinebiggers
authored andcommitted
blk-crypto: Add support for SM4-XTS blk crypto mode
SM4 is a symmetric cipher algorithm widely used in China. The SM4-XTS variant is used to encrypt length-preserving data. This is the mandatory algorithm in some special scenarios. Add support for the algorithm to block inline encryption. This is needed for the inlinecrypt mount option to be supported via blk-crypto-fallback, as it is for the other fscrypt modes. Signed-off-by: Tianjia Zhang <[email protected]> Signed-off-by: Eric Biggers <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent aa99799 commit d209ce3

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

block/blk-crypto.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ const struct blk_crypto_mode blk_crypto_modes[] = {
3636
.keysize = 32,
3737
.ivsize = 32,
3838
},
39+
[BLK_ENCRYPTION_MODE_SM4_XTS] = {
40+
.name = "SM4-XTS",
41+
.cipher_str = "xts(sm4)",
42+
.keysize = 32,
43+
.ivsize = 16,
44+
},
3945
};
4046

4147
/*

include/linux/blk-crypto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ enum blk_crypto_mode_num {
1313
BLK_ENCRYPTION_MODE_AES_256_XTS,
1414
BLK_ENCRYPTION_MODE_AES_128_CBC_ESSIV,
1515
BLK_ENCRYPTION_MODE_ADIANTUM,
16+
BLK_ENCRYPTION_MODE_SM4_XTS,
1617
BLK_ENCRYPTION_MODE_MAX,
1718
};
1819

0 commit comments

Comments
 (0)