make sure we always save database as KDBX4 when using ChallengeXCKey (for compatibility with KeepassXC), closes #596
This commit is contained in:
@@ -42,5 +42,7 @@ namespace KeePassLib.Keys
|
||||
// /// Clear the key and securely erase all security-critical information.
|
||||
// /// </summary>
|
||||
// void Clear();
|
||||
|
||||
uint GetMinKdbxVersion();
|
||||
}
|
||||
}
|
||||
|
@@ -45,6 +45,11 @@ namespace KeePassLib.Keys
|
||||
get { return m_pbKey; }
|
||||
}
|
||||
|
||||
public uint GetMinKdbxVersion()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public KcpCustomKey(string strName, byte[] pbKeyData, bool bPerformHash)
|
||||
{
|
||||
Debug.Assert(strName != null); if(strName == null) throw new ArgumentNullException("strName");
|
||||
|
@@ -64,6 +64,11 @@ namespace KeePassLib.Keys
|
||||
get { return m_pbKeyData; }
|
||||
}
|
||||
|
||||
public uint GetMinKdbxVersion()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public IOConnectionInfo Ioc
|
||||
{
|
||||
get { return m_ioc; }
|
||||
|
@@ -53,6 +53,11 @@ namespace KeePassLib.Keys
|
||||
get { return m_pbKeyData; }
|
||||
}
|
||||
|
||||
public uint GetMinKdbxVersion()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public KcpPassword(byte[] pbPasswordUtf8)
|
||||
{
|
||||
SetKey(pbPasswordUtf8);
|
||||
|
@@ -60,6 +60,11 @@ namespace KeePassLib.Keys
|
||||
get { return m_pbKeyData; }
|
||||
}
|
||||
|
||||
public uint GetMinKdbxVersion()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Construct a user account key.
|
||||
/// </summary>
|
||||
|
@@ -23,6 +23,7 @@ using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
@@ -126,8 +127,8 @@ namespace KeePassLib.Serialization
|
||||
/// </summary>
|
||||
private const uint FileVersion32 = 0x00040000;
|
||||
|
||||
internal const uint FileVersion32_4 = 0x00040000; // First of 4.x series
|
||||
internal const uint FileVersion32_3 = 0x00030001; // Old format 3.1
|
||||
public const uint FileVersion32_4 = 0x00040000; // First of 4.x series
|
||||
public const uint FileVersion32_3 = 0x00030001; // Old format 3.1
|
||||
|
||||
private const uint FileVersionCriticalMask = 0xFFFF0000;
|
||||
|
||||
@@ -373,13 +374,16 @@ namespace KeePassLib.Serialization
|
||||
if(m_uForceVersion != 0) return m_uForceVersion;
|
||||
|
||||
// See also KeePassKdb2x3.Export (KDBX 3.1 export module)
|
||||
uint minVersionForKeys = m_pwDatabase.MasterKey.UserKeys.Select(key => key.GetMinKdbxVersion()).Max();
|
||||
|
||||
AesKdf kdfAes = new AesKdf();
|
||||
if(!kdfAes.Uuid.Equals(m_pwDatabase.KdfParameters.KdfUuid))
|
||||
return FileVersion32;
|
||||
return Math.Max(FileVersion32, minVersionForKeys);
|
||||
|
||||
if(m_pwDatabase.PublicCustomData.Count > 0)
|
||||
return FileVersion32;
|
||||
return Math.Max(FileVersion32, minVersionForKeys);
|
||||
|
||||
|
||||
|
||||
bool bCustomData = false;
|
||||
GroupHandler gh = delegate(PwGroup pg)
|
||||
@@ -396,9 +400,10 @@ namespace KeePassLib.Serialization
|
||||
};
|
||||
gh(m_pwDatabase.RootGroup);
|
||||
m_pwDatabase.RootGroup.TraverseTree(TraversalMethod.PreOrder, gh, eh);
|
||||
if(bCustomData) return FileVersion32;
|
||||
if(bCustomData)
|
||||
return Math.Max(FileVersion32, minVersionForKeys);
|
||||
|
||||
return FileVersion32_3; // KDBX 3.1 is sufficient
|
||||
return Math.Max(FileVersion32_3, minVersionForKeys); ; // KDBX 3.1 is sufficient
|
||||
}
|
||||
|
||||
private void ComputeKeys(out byte[] pbCipherKey, int cbCipherKey,
|
||||
|
@@ -2,6 +2,7 @@ using Java.Lang;
|
||||
using KeePassLib.Cryptography;
|
||||
using KeePassLib.Keys;
|
||||
using KeePassLib.Security;
|
||||
using KeePassLib.Serialization;
|
||||
using Exception = System.Exception;
|
||||
|
||||
namespace keepass2android
|
||||
@@ -62,6 +63,11 @@ namespace keepass2android
|
||||
}
|
||||
}
|
||||
|
||||
public uint GetMinKdbxVersion()
|
||||
{
|
||||
return KdbxFile.FileVersion32_4;
|
||||
}
|
||||
|
||||
private byte[] _kdfSeed;
|
||||
|
||||
public ChallengeXCKey(LockingActivity activity, int requestCode)
|
||||
|
Reference in New Issue
Block a user