mirror of
https://github.com/wismna/ModernKeePassLib.git
synced 2025-10-03 15:40:20 -04:00
Downgrade to net standard 1.2
This commit is contained in:
8
ModernKeePassLib/Cryptography/Cipher/CryptoStreamMode.cs
Normal file
8
ModernKeePassLib/Cryptography/Cipher/CryptoStreamMode.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace ModernKeePassLib.Cryptography.Cipher
|
||||
{
|
||||
public enum CryptoStreamMode
|
||||
{
|
||||
Write,
|
||||
Read
|
||||
}
|
||||
}
|
@@ -24,17 +24,17 @@ using System.IO;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
|
||||
#if !KeePassUAP
|
||||
#if ModernKeePassLib
|
||||
using ModernKeePassLib.Resources;
|
||||
#else
|
||||
using System.Security.Cryptography;
|
||||
#endif
|
||||
|
||||
using ModernKeePassLib.Resources;
|
||||
|
||||
namespace ModernKeePassLib.Cryptography.Cipher
|
||||
{
|
||||
public sealed class StandardAesEngine : ICipherEngine
|
||||
{
|
||||
#if !KeePassUAP
|
||||
#if !ModernKeePassLib && !KeePassUAP
|
||||
private const CipherMode SaeCipherMode = CipherMode.CBC;
|
||||
private const PaddingMode SaePaddingMode = PaddingMode.PKCS7;
|
||||
#endif
|
||||
@@ -97,7 +97,7 @@ namespace ModernKeePassLib.Cryptography.Cipher
|
||||
{
|
||||
StandardAesEngine.ValidateArguments(s, bEncrypt, pbKey, pbIV);
|
||||
|
||||
#if KeePassUAP
|
||||
#if ModernKeePassLib || KeePassUAP
|
||||
return StandardAesEngineExt.CreateStream(s, bEncrypt, pbKey, pbIV);
|
||||
#else
|
||||
SymmetricAlgorithm a = CryptoUtil.CreateAes();
|
||||
|
26
ModernKeePassLib/Cryptography/Cipher/StandardAesEngineExt.cs
Normal file
26
ModernKeePassLib/Cryptography/Cipher/StandardAesEngineExt.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.IO;
|
||||
using Org.BouncyCastle.Crypto.Engines;
|
||||
using Org.BouncyCastle.Crypto.IO;
|
||||
using Org.BouncyCastle.Crypto.Modes;
|
||||
using Org.BouncyCastle.Crypto.Paddings;
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
|
||||
namespace ModernKeePassLib.Cryptography.Cipher
|
||||
{
|
||||
public class StandardAesEngineExt
|
||||
{
|
||||
internal static Stream CreateStream(Stream s, bool bEncrypt, byte[] pbKey, byte[] pbIV)
|
||||
{
|
||||
var cbc = new CbcBlockCipher(new AesEngine());
|
||||
//var cbc = new CbcBlockCipher(new RijndaelEngine());
|
||||
var bc = new PaddedBufferedBlockCipher(cbc, new Pkcs7Padding());
|
||||
var kp = new KeyParameter(pbKey);
|
||||
var prmIV = new ParametersWithIV(kp, pbIV);
|
||||
bc.Init(bEncrypt, prmIV);
|
||||
|
||||
var cpRead = bEncrypt ? null : bc;
|
||||
var cpWrite = bEncrypt ? bc : null;
|
||||
return new CipherStream(s, cpRead, cpWrite);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user