crypto/block-luks.c | 2 +- crypto/cipher-gcrypt.c.inc | 4 ++-- crypto/cipher-nettle.c.inc | 4 ++-- crypto/cipher.c | 4 ++-- qapi/crypto.json | 4 ++-- tests/unit/test-crypto-cipher.c | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-)
With reference to the naming conventions of other encryption algorithms,
the name of SM4 is modified.So libvirt and qemu are compatible.
Signed-off-by: luzhipeng <luzhipeng@cestc.cn>
---
crypto/block-luks.c | 2 +-
crypto/cipher-gcrypt.c.inc | 4 ++--
crypto/cipher-nettle.c.inc | 4 ++--
crypto/cipher.c | 4 ++--
qapi/crypto.json | 4 ++--
tests/unit/test-crypto-cipher.c | 4 ++--
6 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/crypto/block-luks.c b/crypto/block-luks.c
index 5b777c15d3..c156c6f1ff 100644
--- a/crypto/block-luks.c
+++ b/crypto/block-luks.c
@@ -98,7 +98,7 @@ qcrypto_block_luks_cipher_size_map_twofish[] = {
#ifdef CONFIG_CRYPTO_SM4
static const QCryptoBlockLUKSCipherSizeMap
qcrypto_block_luks_cipher_size_map_sm4[] = {
- { 16, QCRYPTO_CIPHER_ALG_SM4},
+ { 16, QCRYPTO_CIPHER_ALG_SM4_128},
{ 0, 0 },
};
#endif
diff --git a/crypto/cipher-gcrypt.c.inc b/crypto/cipher-gcrypt.c.inc
index 4a8314746d..e9a555bff5 100644
--- a/crypto/cipher-gcrypt.c.inc
+++ b/crypto/cipher-gcrypt.c.inc
@@ -46,7 +46,7 @@ static int qcrypto_cipher_alg_to_gcry_alg(QCryptoCipherAlgorithm alg)
case QCRYPTO_CIPHER_ALG_TWOFISH_256:
return GCRY_CIPHER_TWOFISH;
#ifdef CONFIG_CRYPTO_SM4
- case QCRYPTO_CIPHER_ALG_SM4:
+ case QCRYPTO_CIPHER_ALG_SM4_128:
return GCRY_CIPHER_SM4;
#endif
default:
@@ -86,7 +86,7 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg,
case QCRYPTO_CIPHER_ALG_TWOFISH_128:
case QCRYPTO_CIPHER_ALG_TWOFISH_256:
#ifdef CONFIG_CRYPTO_SM4
- case QCRYPTO_CIPHER_ALG_SM4:
+ case QCRYPTO_CIPHER_ALG_SM4_128:
#endif
break;
default:
diff --git a/crypto/cipher-nettle.c.inc b/crypto/cipher-nettle.c.inc
index 42b39e18a2..a62a5e8178 100644
--- a/crypto/cipher-nettle.c.inc
+++ b/crypto/cipher-nettle.c.inc
@@ -471,7 +471,7 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg,
case QCRYPTO_CIPHER_ALG_TWOFISH_192:
case QCRYPTO_CIPHER_ALG_TWOFISH_256:
#ifdef CONFIG_CRYPTO_SM4
- case QCRYPTO_CIPHER_ALG_SM4:
+ case QCRYPTO_CIPHER_ALG_SM4_128:
#endif
break;
default:
@@ -732,7 +732,7 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
return &ctx->base;
}
#ifdef CONFIG_CRYPTO_SM4
- case QCRYPTO_CIPHER_ALG_SM4:
+ case QCRYPTO_CIPHER_ALG_SM4_128:
{
QCryptoNettleSm4 *ctx = g_new0(QCryptoNettleSm4, 1);
diff --git a/crypto/cipher.c b/crypto/cipher.c
index 5f512768ea..dc4b39d480 100644
--- a/crypto/cipher.c
+++ b/crypto/cipher.c
@@ -39,7 +39,7 @@ static const size_t alg_key_len[QCRYPTO_CIPHER_ALG__MAX] = {
[QCRYPTO_CIPHER_ALG_TWOFISH_192] = 24,
[QCRYPTO_CIPHER_ALG_TWOFISH_256] = 32,
#ifdef CONFIG_CRYPTO_SM4
- [QCRYPTO_CIPHER_ALG_SM4] = 16,
+ [QCRYPTO_CIPHER_ALG_SM4_128] = 16,
#endif
};
@@ -57,7 +57,7 @@ static const size_t alg_block_len[QCRYPTO_CIPHER_ALG__MAX] = {
[QCRYPTO_CIPHER_ALG_TWOFISH_192] = 16,
[QCRYPTO_CIPHER_ALG_TWOFISH_256] = 16,
#ifdef CONFIG_CRYPTO_SM4
- [QCRYPTO_CIPHER_ALG_SM4] = 16,
+ [QCRYPTO_CIPHER_ALG_SM4_128] = 16,
#endif
};
diff --git a/qapi/crypto.json b/qapi/crypto.json
index e102be337b..1a28e312d8 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -94,7 +94,7 @@
#
# @twofish-256: Twofish with 256 bit / 32 byte keys
#
-# @sm4: SM4 with 128 bit / 16 byte keys (since 9.0)
+# @sm4-128: SM4 with 128 bit / 16 byte keys (since 9.0)
#
# Since: 2.6
##
@@ -105,7 +105,7 @@
'cast5-128',
'serpent-128', 'serpent-192', 'serpent-256',
'twofish-128', 'twofish-192', 'twofish-256',
- 'sm4']}
+ 'sm4-128']}
##
# @QCryptoCipherMode:
diff --git a/tests/unit/test-crypto-cipher.c b/tests/unit/test-crypto-cipher.c
index f5152e569d..c60d48cb13 100644
--- a/tests/unit/test-crypto-cipher.c
+++ b/tests/unit/test-crypto-cipher.c
@@ -385,8 +385,8 @@ static QCryptoCipherTestData test_data[] = {
#ifdef CONFIG_CRYPTO_SM4
{
/* SM4, GB/T 32907-2016, Appendix A.1 */
- .path = "/crypto/cipher/sm4",
- .alg = QCRYPTO_CIPHER_ALG_SM4,
+ .path = "/crypto/cipher/sm4-128",
+ .alg = QCRYPTO_CIPHER_ALG_SM4_128,
.mode = QCRYPTO_CIPHER_MODE_ECB,
.key = "0123456789abcdeffedcba9876543210",
.plaintext =
--
2.34.0.windows.1
On Tue, Jul 30, 2024 at 07:38:50PM +0800, luzhipeng wrote: > With reference to the naming conventions of other encryption algorithms, > the name of SM4 is modified.So libvirt and qemu are compatible. > > Signed-off-by: luzhipeng <luzhipeng@cestc.cn> > --- > crypto/block-luks.c | 2 +- > crypto/cipher-gcrypt.c.inc | 4 ++-- > crypto/cipher-nettle.c.inc | 4 ++-- > crypto/cipher.c | 4 ++-- > qapi/crypto.json | 4 ++-- > tests/unit/test-crypto-cipher.c | 4 ++-- > 6 files changed, 11 insertions(+), 11 deletions(-) > > diff --git a/qapi/crypto.json b/qapi/crypto.json > index e102be337b..1a28e312d8 100644 > --- a/qapi/crypto.json > +++ b/qapi/crypto.json > @@ -94,7 +94,7 @@ > # > # @twofish-256: Twofish with 256 bit / 32 byte keys > # > -# @sm4: SM4 with 128 bit / 16 byte keys (since 9.0) > +# @sm4-128: SM4 with 128 bit / 16 byte keys (since 9.0) > # > # Since: 2.6 > ## > @@ -105,7 +105,7 @@ > 'cast5-128', > 'serpent-128', 'serpent-192', 'serpent-256', > 'twofish-128', 'twofish-192', 'twofish-256', > - 'sm4']} > + 'sm4-128']} This rename isn't permitted, as 'sm4' was already exposed as public API in the 9.0 release and thus this would break backwards compatibility. I agree it would have been nice to call it 'sm4-128' and I dropped the ball by not suggesting a rename when this was first proposed. At this point though, I don't think we need to go through the many release dance of deprecating the old name & introducing a new name & finally removing the old name, since IIUC, SM4 is always 128 bits in size. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
© 2016 - 2024 Red Hat, Inc.