Browse Source

🐛 fix(encryption): InitVectorBytes Configuration values should be used

pull/1089/head
colin 1 year ago
parent
commit
92365bfa69
  1. 6
      aspnet-core/framework/security/LINGYUN.Abp.Encryption.SM4/LINGYUN/Abp/Encryption/SM4/SM4StringEncryptionService.cs

6
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);

Loading…
Cancel
Save