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:
@@ -23,7 +23,8 @@ using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
#if (!ModernKeePassLib && !KeePassUAP)
|
||||
|
||||
#if !ModernKeePassLib && !KeePassLibSD
|
||||
using System.Security.AccessControl;
|
||||
#endif
|
||||
|
||||
@@ -220,15 +221,15 @@ namespace ModernKeePassLib.Serialization
|
||||
// FileAttributes faBase = FileAttributes.Normal;
|
||||
try
|
||||
{
|
||||
#if !ModernKeePassLib
|
||||
#if !(ModernKeePassLib || KeePassUAP)
|
||||
FileAttributes faBase = File.GetAttributes(m_iocBase.Path);
|
||||
bEfsEncrypted = ((long)(faBase & FileAttributes.Encrypted) != 0);
|
||||
try { if(bEfsEncrypted) File.Decrypt(m_iocBase.Path); } // For TxF
|
||||
catch(Exception) { Debug.Assert(false); }
|
||||
#endif
|
||||
|
||||
otCreation = File.GetCreationTimeUtc(m_iocBase.Path);
|
||||
sStat = SimpleStat.Get(m_iocBase.Path);
|
||||
#if !ModernKeePassLib
|
||||
|
||||
// May throw with Mono
|
||||
FileSecurity sec = File.GetAccessControl(m_iocBase.Path, acs);
|
||||
if(sec != null) pbSec = sec.GetSecurityDescriptorBinaryForm();
|
||||
@@ -522,8 +523,8 @@ namespace ModernKeePassLib.Serialization
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
internal static void ClearOld()
|
||||
#if !ModernKeePassLib
|
||||
internal static void ClearOld()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -545,5 +546,6 @@ namespace ModernKeePassLib.Serialization
|
||||
}
|
||||
catch(Exception) { Debug.Assert(false); }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,9 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
#if !KeePassUAP
|
||||
#if ModernKeePassLib
|
||||
using ModernKeePassLib.Cryptography.Hash;
|
||||
#elif !KeePassUAP
|
||||
using System.Security.Cryptography;
|
||||
#endif
|
||||
|
||||
@@ -39,7 +41,7 @@ namespace ModernKeePassLib.Serialization
|
||||
private Stream m_sBase;
|
||||
private readonly bool m_bWriting;
|
||||
private readonly bool m_bVerify;
|
||||
private byte[] m_pbKey;
|
||||
private readonly byte[] m_pbKey;
|
||||
|
||||
private bool m_bEos = false;
|
||||
private byte[] m_pbBuffer;
|
||||
|
@@ -24,6 +24,7 @@ using System.IO;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassUAP)
|
||||
using System.Net.Cache;
|
||||
using System.Net.Security;
|
||||
@@ -33,12 +34,16 @@ using System.Net.Security;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
#endif
|
||||
|
||||
#if ModernKeePassLib
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.Streams;
|
||||
#endif
|
||||
using ModernKeePassLib.Native;
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
namespace ModernKeePassLib.Serialization
|
||||
{
|
||||
#if (!ModernKeePassLib && !KeePassLibSD)
|
||||
#if !ModernKeePassLib && !KeePassLibSD
|
||||
internal sealed class IOWebClient : WebClient
|
||||
{
|
||||
private IOConnectionInfo m_ioc;
|
||||
@@ -240,7 +245,7 @@ namespace ModernKeePassLib.Serialization
|
||||
|
||||
public static class IOConnection
|
||||
{
|
||||
#if (!ModernKeePassLib && !KeePassLibSD)
|
||||
#if !ModernKeePassLib && !KeePassLibSD
|
||||
private static ProxyServerType m_pstProxyType = ProxyServerType.System;
|
||||
private static string m_strProxyAddr = string.Empty;
|
||||
private static string m_strProxyPort = string.Empty;
|
||||
@@ -269,7 +274,7 @@ namespace ModernKeePassLib.Serialization
|
||||
|
||||
public static event EventHandler<IOAccessEventArgs> IOAccessPre;
|
||||
|
||||
#if (!ModernKeePassLib && !KeePassLibSD)
|
||||
#if !ModernKeePassLib && !KeePassLibSD
|
||||
// Allow self-signed certificates, expired certificates, etc.
|
||||
private static bool AcceptCertificate(object sender,
|
||||
X509Certificate certificate, X509Chain chain,
|
||||
@@ -603,7 +608,7 @@ namespace ModernKeePassLib.Serialization
|
||||
#endif
|
||||
}
|
||||
|
||||
#if (!ModernKeePassLib && !KeePassLibSD)
|
||||
#if !ModernKeePassLib && !KeePassLibSD
|
||||
public static Stream OpenWrite(IOConnectionInfo ioc)
|
||||
{
|
||||
if(ioc == null) { Debug.Assert(false); return null; }
|
||||
@@ -802,7 +807,7 @@ namespace ModernKeePassLib.Serialization
|
||||
#endif
|
||||
}
|
||||
|
||||
#if (!ModernKeePassLib && !KeePassLibSD)
|
||||
#if !ModernKeePassLib && !KeePassLibSD
|
||||
private static bool SendCommand(IOConnectionInfo ioc, string strMethod)
|
||||
{
|
||||
try
|
||||
@@ -910,6 +915,6 @@ namespace ModernKeePassLib.Serialization
|
||||
return (wr is FileWebRequest);
|
||||
#endif
|
||||
}
|
||||
#endif // ModernKeePass
|
||||
#endif // ModernKeePassLib
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
KeePass Password Safe - The Open-Source Password Manager
|
||||
Copyright (C) 2003-2020 Dominik Reichl <dominik.reichl@t-online.de>
|
||||
Copyright (C) 2003-2018 Dominik Reichl <dominik.reichl@t-online.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@@ -30,14 +30,13 @@ using System.Drawing;
|
||||
|
||||
using ModernKeePassLib;
|
||||
using ModernKeePassLib.Collections;
|
||||
using ModernKeePassLib.Cryptography;
|
||||
using ModernKeePassLib.Cryptography.Cipher;
|
||||
using ModernKeePassLib.Interfaces;
|
||||
using ModernKeePassLib.Resources;
|
||||
using ModernKeePassLib.Security;
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
using ModernKeePassLib.Cryptography;
|
||||
using ModernKeePassLib.Cryptography.Cipher;
|
||||
|
||||
namespace ModernKeePassLib.Serialization
|
||||
{
|
||||
/// <summary>
|
||||
@@ -758,13 +757,21 @@ namespace ModernKeePassLib.Serialization
|
||||
}
|
||||
|
||||
m_bReadNextNode = false; // ReadElementString skips end tag
|
||||
#if ModernKeePassLib
|
||||
return xr.ReadElementContentAsString();
|
||||
#else
|
||||
return xr.ReadElementString();
|
||||
#endif
|
||||
}
|
||||
|
||||
private string ReadStringRaw(XmlReader xr)
|
||||
{
|
||||
m_bReadNextNode = false; // ReadElementString skips end tag
|
||||
#if ModernKeePassLib
|
||||
return xr.ReadElementContentAsString();
|
||||
#else
|
||||
return xr.ReadElementString();
|
||||
#endif
|
||||
}
|
||||
|
||||
private byte[] ReadBase64(XmlReader xr, bool bRaw)
|
||||
|
@@ -26,7 +26,7 @@ using System.Security;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
#if !KeePassUAP
|
||||
#if !ModernKeePassLib && !KeePassUAP
|
||||
using System.Drawing;
|
||||
using System.Security.Cryptography;
|
||||
#endif
|
||||
@@ -204,7 +204,7 @@ namespace ModernKeePassLib.Serialization
|
||||
throw new ArgumentOutOfRangeException("fmt");
|
||||
}
|
||||
|
||||
m_xmlWriter = XmlUtilEx.CreateXmlWriter(sXml);
|
||||
m_xmlWriter = XmlUtilEx.CreateXmlWriter(sXml, m_uFileVersion >= FileVersion32_4);
|
||||
|
||||
WriteDocument(pgRoot);
|
||||
|
||||
|
@@ -26,8 +26,9 @@ using System.Security;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
#if !KeePassUAP
|
||||
using System.Security.Cryptography;
|
||||
#if ModernKeePassLib
|
||||
using Windows.Storage;
|
||||
using ModernKeePassLib.Cryptography.Hash;
|
||||
#endif
|
||||
|
||||
using ModernKeePassLib.Collections;
|
||||
@@ -511,11 +512,33 @@ namespace ModernKeePassLib.Serialization
|
||||
|
||||
++iTry;
|
||||
}
|
||||
#if ModernKeePassLib
|
||||
while (StorageFile.GetFileFromPathAsync(strPath).GetResults() != null);
|
||||
#else
|
||||
while(File.Exists(strPath));
|
||||
#endif
|
||||
|
||||
#if ModernKeePassLib
|
||||
byte[] pbData = pb.ReadData();
|
||||
/*var file = FileSystem.Current.GetFileFromPathAsync(strPath).Result;
|
||||
using (var stream = file.OpenAsync(FileAccess.ReadAndWrite).Result) {*/
|
||||
var file = StorageFile.GetFileFromPathAsync(strPath).GetAwaiter().GetResult();
|
||||
using (var stream = file.OpenAsync(FileAccessMode.ReadWrite).GetAwaiter().GetResult().AsStream())
|
||||
{
|
||||
stream.Write (pbData, 0, pbData.Length);
|
||||
}
|
||||
MemUtil.ZeroByteArray(pbData);
|
||||
#elif !KeePassLibSD
|
||||
byte[] pbData = pb.ReadData();
|
||||
File.WriteAllBytes(strPath, pbData);
|
||||
MemUtil.ZeroByteArray(pbData);
|
||||
#else
|
||||
FileStream fs = new FileStream(strPath, FileMode.Create,
|
||||
FileAccess.Write, FileShare.None);
|
||||
byte[] pbData = pb.ReadData();
|
||||
try { File.WriteAllBytes(strPath, pbData); }
|
||||
finally { if(pb.IsProtected) MemUtil.ZeroByteArray(pbData); }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user