From 92365bfa69680913d37b2c240328c5e39b78f758 Mon Sep 17 00:00:00 2001 From: colin Date: Thu, 6 Feb 2025 15:31:15 +0800 Subject: [PATCH] :bug: fix(encryption): InitVectorBytes Configuration values should be used --- .../Abp/Encryption/SM4/SM4StringEncryptionService.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/aspnet-core/framework/security/LINGYUN.Abp.Encryption.SM4/LINGYUN/Abp/Encryption/SM4/SM4StringEncryptionService.cs b/aspnet-core/framework/security/LINGYUN.Abp.Encryption.SM4/LINGYUN/Abp/Encryption/SM4/SM4StringEncryptionService.cs index 00ed14e2f..a3d37ea52 100644 --- a/aspnet-core/framework/security/LINGYUN.Abp.Encryption.SM4/LINGYUN/Abp/Encryption/SM4/SM4StringEncryptionService.cs +++ b/aspnet-core/framework/security/LINGYUN.Abp.Encryption.SM4/LINGYUN/Abp/Encryption/SM4/SM4StringEncryptionService.cs @@ -37,10 +37,9 @@ public class SM4StringEncryptionService : StringEncryptionService using var password = new Rfc2898DeriveBytes(passPhrase, salt); // 128-bit key var keyBytes = password.GetBytes(16); - var ivBytes = password.GetBytes(16); var cipher = new PaddedBufferedBlockCipher(new CbcBlockCipher(new SM4Engine()), new Pkcs7Padding()); - cipher.Init(false, new ParametersWithIV(new KeyParameter(keyBytes), ivBytes)); + cipher.Init(false, new ParametersWithIV(new KeyParameter(keyBytes), Options.InitVectorBytes)); var decryptTextBytes = cipher.DoFinal(cipherTextBytes); @@ -61,10 +60,9 @@ public class SM4StringEncryptionService : StringEncryptionService using var password = new Rfc2898DeriveBytes(passPhrase, salt); // 128-bit key var keyBytes = password.GetBytes(16); - var ivBytes = password.GetBytes(16); var cipher = new PaddedBufferedBlockCipher(new CbcBlockCipher(new SM4Engine()), new Pkcs7Padding()); - cipher.Init(true, new ParametersWithIV(new KeyParameter(keyBytes), ivBytes)); + cipher.Init(true, new ParametersWithIV(new KeyParameter(keyBytes), Options.InitVectorBytes)); var decryptTextBytes = cipher.DoFinal(plainTextBytes);