sm4:Adjust the naming of SM4 encryption method
PATCH 1/1 sm4:Adjust the naming of SM4 encryption method
With reference to the naming conventions of other encryption algorithms, the name of SM4 is modified.So libvirt and qemu are compatible.
--- 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(-)
crypto/block-luks.c +1 -1
@@ -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
crypto/cipher-gcrypt.c.inc +2 -2
@@ -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:
crypto/cipher-nettle.c.inc +2 -2
@@ -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);
crypto/cipher.c +2 -2
@@ -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 };
qapi/crypto.json +2 -2
@@ -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:
tests/unit/test-crypto-cipher.c +2 -2
@@ -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 =
Signature · 1 line
2.34.0.windows.1
Quoted 27 lines · luzhipeng
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 <[email protected]>--- 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(-)qapi/crypto.json +1
-1@@ -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 ##
qapi/crypto.json line 108
Quoted 5 lines
qapi/crypto.json +1
-1@@ -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
Signature · 3 lines
|: 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 :|