mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
KeepassLib version update to 2.38
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -69,7 +69,7 @@ namespace ModernKeePassLib.Cryptography.Cipher
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class ChaCha20Stream : Stream
|
internal sealed class ChaCha20Stream : Stream
|
||||||
{
|
{
|
||||||
private Stream m_sBase;
|
private Stream m_sBase;
|
||||||
private readonly bool m_bWriting;
|
private readonly bool m_bWriting;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -22,9 +22,13 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
#if ModernKeePassLib || KeePassUAP
|
||||||
using Org.BouncyCastle.Crypto;
|
using Org.BouncyCastle.Crypto;
|
||||||
using Org.BouncyCastle.Crypto.Engines;
|
using Org.BouncyCastle.Crypto.Engines;
|
||||||
using Org.BouncyCastle.Crypto.Parameters;
|
using Org.BouncyCastle.Crypto.Parameters;
|
||||||
|
#else
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
#endif
|
||||||
|
|
||||||
using ModernKeePassLib.Cryptography;
|
using ModernKeePassLib.Cryptography;
|
||||||
using ModernKeePassLib.Native;
|
using ModernKeePassLib.Native;
|
||||||
@@ -134,7 +138,7 @@ namespace ModernKeePassLib.Cryptography.KeyDerivation
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool TransformKeyManaged(byte[] pbNewKey32, byte[] pbKeySeed32,
|
internal static bool TransformKeyManaged(byte[] pbNewKey32, byte[] pbKeySeed32,
|
||||||
ulong uNumRounds)
|
ulong uNumRounds)
|
||||||
{
|
{
|
||||||
#if ModernKeePassLib || KeePassUAP
|
#if ModernKeePassLib || KeePassUAP
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -35,7 +35,6 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using ModernKeePassLib.Cryptography.Hash;
|
using ModernKeePassLib.Cryptography.Hash;
|
||||||
using ModernKeePassLib.Utility;
|
using ModernKeePassLib.Utility;
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
using ModernKeePassLib.Utility;
|
using ModernKeePassLib.Utility;
|
||||||
|
|
||||||
@@ -28,8 +28,8 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
{
|
{
|
||||||
public static class PopularPasswords
|
public static class PopularPasswords
|
||||||
{
|
{
|
||||||
private static Dictionary<int, Dictionary<string, bool>> m_dicts =
|
private static Dictionary<int, Dictionary<char[], bool>> m_dicts =
|
||||||
new Dictionary<int, Dictionary<string, bool>>();
|
new Dictionary<int, Dictionary<char[], bool>>();
|
||||||
|
|
||||||
internal static int MaxLength
|
internal static int MaxLength
|
||||||
{
|
{
|
||||||
@@ -49,7 +49,7 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
|
|
||||||
internal static bool ContainsLength(int nLength)
|
internal static bool ContainsLength(int nLength)
|
||||||
{
|
{
|
||||||
Dictionary<string, bool> dDummy;
|
Dictionary<char[], bool> dDummy;
|
||||||
return m_dicts.TryGetValue(nLength, out dDummy);
|
return m_dicts.TryGetValue(nLength, out dDummy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,28 +64,37 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
if(vPassword == null) throw new ArgumentNullException("vPassword");
|
if(vPassword == null) throw new ArgumentNullException("vPassword");
|
||||||
if(vPassword.Length == 0) { uDictSize = 0; return false; }
|
if(vPassword.Length == 0) { uDictSize = 0; return false; }
|
||||||
|
|
||||||
string str = new string(vPassword);
|
#if DEBUG
|
||||||
|
#if ModernKeePassLib
|
||||||
|
foreach (var ch in vPassword)
|
||||||
|
{
|
||||||
|
Debug.Assert(ch == char.ToLower(ch));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
Array.ForEach(vPassword, ch => Debug.Assert(ch == char.ToLower(ch)));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
try { return IsPopularPasswordPriv(str, out uDictSize); }
|
try { return IsPopularPasswordPriv(vPassword, out uDictSize); }
|
||||||
catch(Exception) { Debug.Assert(false); }
|
catch(Exception) { Debug.Assert(false); }
|
||||||
|
|
||||||
uDictSize = 0;
|
uDictSize = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsPopularPasswordPriv(string str, out ulong uDictSize)
|
private static bool IsPopularPasswordPriv(char[] vPassword, out ulong uDictSize)
|
||||||
{
|
{
|
||||||
Debug.Assert(m_dicts.Count > 0); // Should be initialized with data
|
Debug.Assert(m_dicts.Count > 0); // Should be initialized with data
|
||||||
|
|
||||||
Dictionary<string, bool> d;
|
Dictionary<char[], bool> d;
|
||||||
if(!m_dicts.TryGetValue(str.Length, out d))
|
if(!m_dicts.TryGetValue(vPassword.Length, out d))
|
||||||
{
|
{
|
||||||
uDictSize = 0;
|
uDictSize = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uDictSize = (ulong)d.Count;
|
uDictSize = (ulong)d.Count;
|
||||||
return d.ContainsKey(str);
|
return d.ContainsKey(vPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Add(byte[] pbData, bool bGZipped)
|
public static void Add(byte[] pbData, bool bGZipped)
|
||||||
@@ -98,30 +107,27 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
string strData = StrUtil.Utf8.GetString(pbData, 0, pbData.Length);
|
string strData = StrUtil.Utf8.GetString(pbData, 0, pbData.Length);
|
||||||
if(string.IsNullOrEmpty(strData)) { Debug.Assert(false); return; }
|
if(string.IsNullOrEmpty(strData)) { Debug.Assert(false); return; }
|
||||||
|
|
||||||
if(!char.IsWhiteSpace(strData[strData.Length - 1]))
|
|
||||||
strData += "\n";
|
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for(int i = 0; i < strData.Length; ++i)
|
for(int i = 0; i <= strData.Length; ++i)
|
||||||
{
|
{
|
||||||
char ch = strData[i];
|
char ch = ((i == strData.Length) ? ' ' : strData[i]);
|
||||||
|
|
||||||
if(char.IsWhiteSpace(ch))
|
if(char.IsWhiteSpace(ch))
|
||||||
{
|
{
|
||||||
int cc = sb.Length;
|
int cc = sb.Length;
|
||||||
if(cc > 0)
|
if(cc > 0)
|
||||||
{
|
{
|
||||||
string strWord = sb.ToString();
|
char[] vWord = new char[cc];
|
||||||
Debug.Assert(strWord.Length == cc);
|
sb.CopyTo(0, vWord, 0, cc);
|
||||||
|
|
||||||
Dictionary<string, bool> d;
|
Dictionary<char[], bool> d;
|
||||||
if(!m_dicts.TryGetValue(cc, out d))
|
if(!m_dicts.TryGetValue(cc, out d))
|
||||||
{
|
{
|
||||||
d = new Dictionary<string, bool>();
|
d = new Dictionary<char[], bool>(MemUtil.ArrayHelperExOfChar);
|
||||||
m_dicts[cc] = d;
|
m_dicts[cc] = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
d[strWord] = true;
|
d[vWord] = true;
|
||||||
sb.Remove(0, cc);
|
sb.Remove(0, cc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
using ModernKeePassLib.Cryptography.PasswordGenerator;
|
using ModernKeePassLib.Cryptography.PasswordGenerator;
|
||||||
using ModernKeePassLib.Utility;
|
using ModernKeePassLib.Utility;
|
||||||
@@ -318,30 +318,30 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Estimate the quality of a password.
|
/// Estimate the quality of a password.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="vPasswordChars">Password to check.</param>
|
/// <param name="vPassword">Password to check.</param>
|
||||||
/// <returns>Estimated bit-strength of the password.</returns>
|
/// <returns>Estimated bit-strength of the password.</returns>
|
||||||
public static uint EstimatePasswordBits(char[] vPasswordChars)
|
public static uint EstimatePasswordBits(char[] vPassword)
|
||||||
{
|
{
|
||||||
if(vPasswordChars == null) { Debug.Assert(false); return 0; }
|
if(vPassword == null) { Debug.Assert(false); return 0; }
|
||||||
if(vPasswordChars.Length == 0) return 0;
|
if(vPassword.Length == 0) return 0;
|
||||||
|
|
||||||
EnsureInitialized();
|
EnsureInitialized();
|
||||||
|
|
||||||
int n = vPasswordChars.Length;
|
int n = vPassword.Length;
|
||||||
List<QePatternInstance>[] vPatterns = new List<QePatternInstance>[n];
|
List<QePatternInstance>[] vPatterns = new List<QePatternInstance>[n];
|
||||||
for(int i = 0; i < n; ++i)
|
for(int i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
vPatterns[i] = new List<QePatternInstance>();
|
vPatterns[i] = new List<QePatternInstance>();
|
||||||
|
|
||||||
QePatternInstance piChar = new QePatternInstance(i, 1,
|
QePatternInstance piChar = new QePatternInstance(i, 1,
|
||||||
GetCharType(vPasswordChars[i]));
|
GetCharType(vPassword[i]));
|
||||||
vPatterns[i].Add(piChar);
|
vPatterns[i].Add(piChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
FindRepetitions(vPasswordChars, vPatterns);
|
FindRepetitions(vPassword, vPatterns);
|
||||||
FindNumbers(vPasswordChars, vPatterns);
|
FindNumbers(vPassword, vPatterns);
|
||||||
FindDiffSeqs(vPasswordChars, vPatterns);
|
FindDiffSeqs(vPassword, vPatterns);
|
||||||
FindPopularPasswords(vPasswordChars, vPatterns);
|
FindPopularPasswords(vPassword, vPatterns);
|
||||||
|
|
||||||
// Encoders must not be static, because the entropy estimation
|
// Encoders must not be static, because the entropy estimation
|
||||||
// may run concurrently in multiple threads and the encoders are
|
// may run concurrently in multiple threads and the encoders are
|
||||||
@@ -382,7 +382,7 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
{
|
{
|
||||||
Debug.Assert(s.Position == n);
|
Debug.Assert(s.Position == n);
|
||||||
|
|
||||||
double dblCost = ComputePathCost(s.Path, vPasswordChars,
|
double dblCost = ComputePathCost(s.Path, vPassword,
|
||||||
ecPattern, mcData);
|
ecPattern, mcData);
|
||||||
if(dblCost < dblMinCost) dblMinCost = dblCost;
|
if(dblCost < dblMinCost) dblMinCost = dblCost;
|
||||||
}
|
}
|
||||||
@@ -482,7 +482,7 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
vLeet[i] = char.ToLower(DecodeLeetChar(ch));
|
vLeet[i] = char.ToLower(DecodeLeetChar(ch));
|
||||||
}
|
}
|
||||||
|
|
||||||
char chErased = default(char);
|
char chErased = default(char); // The value that Array.Clear uses
|
||||||
Debug.Assert(chErased == char.MinValue);
|
Debug.Assert(chErased == char.MinValue);
|
||||||
|
|
||||||
int nMaxLen = Math.Min(n, PopularPasswords.MaxLength);
|
int nMaxLen = Math.Min(n, PopularPasswords.MaxLength);
|
||||||
@@ -515,7 +515,12 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
Debug.Assert(vLower[i] == chErased);
|
Debug.Assert(vLower[i] == chErased);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MemUtil.ZeroArray<char>(vSub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MemUtil.ZeroArray<char>(vLower);
|
||||||
|
MemUtil.ZeroArray<char>(vLeet);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool EvalAddPopularPasswordPattern(List<QePatternInstance>[] vPatterns,
|
private static bool EvalAddPopularPasswordPattern(List<QePatternInstance>[] vPatterns,
|
||||||
@@ -659,6 +664,8 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
if(bFoundRep) ErasePart(v, x1, m, ref chErased);
|
if(bFoundRep) ErasePart(v, x1, m, ref chErased);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MemUtil.ZeroArray<char>(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool PartsEqual(char[] v, int x1, int x2, int nLength)
|
private static bool PartsEqual(char[] v, int x1, int x2, int nLength)
|
||||||
@@ -685,23 +692,25 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
{
|
{
|
||||||
int n = vPassword.Length;
|
int n = vPassword.Length;
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < n; ++i)
|
for(int i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
char ch = vPassword[i];
|
char ch = vPassword[i];
|
||||||
if((ch >= '0') && (ch <= '9')) sb.Append(ch);
|
if((ch >= '0') && (ch <= '9')) sb.Append(ch);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddNumberPattern(vPatterns, sb.ToString(), i - sb.Length);
|
AddNumberPattern(vPatterns, sb, i - sb.Length);
|
||||||
sb.Remove(0, sb.Length);
|
sb.Remove(0, sb.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AddNumberPattern(vPatterns, sb.ToString(), n - sb.Length);
|
AddNumberPattern(vPatterns, sb, n - sb.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddNumberPattern(List<QePatternInstance>[] vPatterns,
|
private static void AddNumberPattern(List<QePatternInstance>[] vPatterns,
|
||||||
string strNumber, int i)
|
StringBuilder sb, int i)
|
||||||
{
|
{
|
||||||
if(strNumber.Length <= 2) return;
|
if(sb.Length <= 2) return;
|
||||||
|
string strNumber = sb.ToString();
|
||||||
|
|
||||||
int nZeros = 0;
|
int nZeros = 0;
|
||||||
for(int j = 0; j < strNumber.Length; ++j)
|
for(int j = 0; j < strNumber.Length; ++j)
|
||||||
@@ -733,17 +742,18 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
private static void FindDiffSeqs(char[] vPassword,
|
private static void FindDiffSeqs(char[] vPassword,
|
||||||
List<QePatternInstance>[] vPatterns)
|
List<QePatternInstance>[] vPatterns)
|
||||||
{
|
{
|
||||||
int d = int.MinValue, p = 0;
|
int n = vPassword.Length;
|
||||||
string str = new string(vPassword) + new string(char.MaxValue, 1);
|
int d = int.MaxValue, p = 0;
|
||||||
|
|
||||||
for(int i = 1; i < str.Length; ++i)
|
for(int i = 1; i <= n; ++i)
|
||||||
{
|
{
|
||||||
int dCur = (int)str[i] - (int)str[i - 1];
|
int dCur = ((i == n) ? int.MinValue :
|
||||||
|
((int)vPassword[i] - (int)vPassword[i - 1]));
|
||||||
if(dCur != d)
|
if(dCur != d)
|
||||||
{
|
{
|
||||||
if((i - p) >= 3) // At least 3 chars involved
|
if((i - p) >= 3) // At least 3 chars involved
|
||||||
{
|
{
|
||||||
QeCharType ct = GetCharType(str[p]);
|
QeCharType ct = GetCharType(vPassword[p]);
|
||||||
double dblCost = ct.CharSize + Log2(i - p - 1);
|
double dblCost = ct.CharSize + Log2(i - p - 1);
|
||||||
|
|
||||||
vPatterns[p].Add(new QePatternInstance(p,
|
vPatterns[p].Add(new QePatternInstance(p,
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -822,6 +822,21 @@ namespace ModernKeePassLib.Cryptography
|
|||||||
throw new Exception("MemUtil-9");
|
throw new Exception("MemUtil-9");
|
||||||
if(MemUtil.BytesToInt32(pbRes) != i)
|
if(MemUtil.BytesToInt32(pbRes) != i)
|
||||||
throw new Exception("MemUtil-10");
|
throw new Exception("MemUtil-10");
|
||||||
|
|
||||||
|
ArrayHelperEx<char> ah = MemUtil.ArrayHelperExOfChar;
|
||||||
|
for(int j = 0; j < 30; ++j)
|
||||||
|
{
|
||||||
|
string strA = r.Next(30).ToString();
|
||||||
|
string strB = r.Next(30).ToString();
|
||||||
|
char[] vA = strA.ToCharArray();
|
||||||
|
char[] vB = strB.ToCharArray();
|
||||||
|
|
||||||
|
if(ah.Equals(vA, vB) != string.Equals(strA, strB))
|
||||||
|
throw new Exception("MemUtil-11");
|
||||||
|
if((vA.Length == vB.Length) && (Math.Sign(ah.Compare(vA, vB)) !=
|
||||||
|
Math.Sign(string.CompareOrdinal(strA, strB))))
|
||||||
|
throw new Exception("MemUtil-12");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -44,6 +44,23 @@ namespace ModernKeePassLib.Delegates
|
|||||||
public delegate bool EntryHandler(PwEntry pe);
|
public delegate bool EntryHandler(PwEntry pe);
|
||||||
|
|
||||||
public delegate void VoidDelegate();
|
public delegate void VoidDelegate();
|
||||||
|
|
||||||
public delegate string StrPwEntryDelegate(string str, PwEntry pe);
|
public delegate string StrPwEntryDelegate(string str, PwEntry pe);
|
||||||
|
|
||||||
|
// Action<...> with 0 or >= 2 parameters has been introduced in .NET 3.5
|
||||||
|
public delegate void GAction();
|
||||||
|
public delegate void GAction<T>(T o);
|
||||||
|
public delegate void GAction<T1, T2>(T1 o1, T2 o2);
|
||||||
|
public delegate void GAction<T1, T2, T3>(T1 o1, T2 o2, T3 o3);
|
||||||
|
public delegate void GAction<T1, T2, T3, T4>(T1 o1, T2 o2, T3 o3, T4 o4);
|
||||||
|
public delegate void GAction<T1, T2, T3, T4, T5>(T1 o1, T2 o2, T3 o3, T4 o4, T5 o5);
|
||||||
|
public delegate void GAction<T1, T2, T3, T4, T5, T6>(T1 o1, T2 o2, T3 o3, T4 o4, T5 o5, T6 o6);
|
||||||
|
|
||||||
|
// Func<...> has been introduced in .NET 3.5
|
||||||
|
public delegate TResult GFunc<TResult>();
|
||||||
|
public delegate TResult GFunc<T, TResult>(T o);
|
||||||
|
public delegate TResult GFunc<T1, T2, TResult>(T1 o1, T2 o2);
|
||||||
|
public delegate TResult GFunc<T1, T2, T3, TResult>(T1 o1, T2 o2, T3 o3);
|
||||||
|
public delegate TResult GFunc<T1, T2, T3, T4, TResult>(T1 o1, T2 o2, T3 o3, T4 o4);
|
||||||
|
public delegate TResult GFunc<T1, T2, T3, T4, T5, TResult>(T1 o1, T2 o2, T3 o3, T4 o4, T5 o5);
|
||||||
|
public delegate TResult GFunc<T1, T2, T3, T4, T5, T6, TResult>(T1 o1, T2 o2, T3 o3, T4 o4, T5 o5, T6 o6);
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -35,58 +35,58 @@ using ModernKeePassLib.Utility;
|
|||||||
|
|
||||||
namespace ModernKeePassLib.Keys
|
namespace ModernKeePassLib.Keys
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A user key depending on the currently logged on Windows user account.
|
/// A user key depending on the currently logged on Windows user account.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class KcpUserAccount : IUserKey
|
public sealed class KcpUserAccount : IUserKey
|
||||||
{
|
{
|
||||||
private ProtectedBinary m_pbKeyData = null;
|
private ProtectedBinary m_pbKeyData = null;
|
||||||
|
|
||||||
// Constant initialization vector (unique for KeePass)
|
// Constant initialization vector (unique for KeePass)
|
||||||
private static readonly byte[] m_pbEntropy = new byte[] {
|
private static readonly byte[] m_pbEntropy = new byte[] {
|
||||||
0xDE, 0x13, 0x5B, 0x5F, 0x18, 0xA3, 0x46, 0x70,
|
0xDE, 0x13, 0x5B, 0x5F, 0x18, 0xA3, 0x46, 0x70,
|
||||||
0xB2, 0x57, 0x24, 0x29, 0x69, 0x88, 0x98, 0xE6
|
0xB2, 0x57, 0x24, 0x29, 0x69, 0x88, 0x98, 0xE6
|
||||||
};
|
};
|
||||||
|
|
||||||
private const string UserKeyFileName = "ProtectedUserKey.bin";
|
private const string UserKeyFileName = "ProtectedUserKey.bin";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get key data. Querying this property is fast (it returns a
|
/// Get key data. Querying this property is fast (it returns a
|
||||||
/// reference to a cached <c>ProtectedBinary</c> object).
|
/// reference to a cached <c>ProtectedBinary</c> object).
|
||||||
/// If no key data is available, <c>null</c> is returned.
|
/// If no key data is available, <c>null</c> is returned.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ProtectedBinary KeyData
|
public ProtectedBinary KeyData
|
||||||
{
|
{
|
||||||
get { return m_pbKeyData; }
|
get { return m_pbKeyData; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Construct a user account key.
|
/// Construct a user account key.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public KcpUserAccount()
|
public KcpUserAccount()
|
||||||
{
|
{
|
||||||
// Test if ProtectedData is supported -- throws an exception
|
// Test if ProtectedData is supported -- throws an exception
|
||||||
// when running on an old system (Windows 98 / ME).
|
// when running on an old system (Windows 98 / ME).
|
||||||
byte[] pbDummyData = new byte[128];
|
byte[] pbDummyData = new byte[128];
|
||||||
ProtectedData.Protect(pbDummyData, m_pbEntropy,
|
ProtectedData.Protect(pbDummyData, m_pbEntropy,
|
||||||
DataProtectionScope.CurrentUser);
|
DataProtectionScope.CurrentUser);
|
||||||
|
|
||||||
byte[] pbKey = LoadUserKey(false);
|
byte[] pbKey = LoadUserKey(false);
|
||||||
if (pbKey == null) pbKey = CreateUserKey();
|
if(pbKey == null) pbKey = CreateUserKey();
|
||||||
if (pbKey == null) // Should never happen
|
if(pbKey == null) // Should never happen
|
||||||
{
|
{
|
||||||
Debug.Assert(false);
|
Debug.Assert(false);
|
||||||
throw new SecurityException(KLRes.UserAccountKeyError);
|
throw new SecurityException(KLRes.UserAccountKeyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pbKeyData = new ProtectedBinary(true, pbKey);
|
m_pbKeyData = new ProtectedBinary(true, pbKey);
|
||||||
MemUtil.ZeroByteArray(pbKey);
|
MemUtil.ZeroByteArray(pbKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void Clear()
|
// public void Clear()
|
||||||
// {
|
// {
|
||||||
// m_pbKeyData = null;
|
// m_pbKeyData = null;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private static string GetUserKeyFilePath(bool bCreate)
|
private static string GetUserKeyFilePath(bool bCreate)
|
||||||
{
|
{
|
||||||
@@ -99,23 +99,26 @@ namespace ModernKeePassLib.Keys
|
|||||||
|
|
||||||
strUserDir = UrlUtil.EnsureTerminatingSeparator(strUserDir, false);
|
strUserDir = UrlUtil.EnsureTerminatingSeparator(strUserDir, false);
|
||||||
strUserDir += PwDefs.ShortProductName;
|
strUserDir += PwDefs.ShortProductName;
|
||||||
|
|
||||||
#if !ModernKeePassLib
|
#if !ModernKeePassLib
|
||||||
|
|
||||||
if(bCreate && !Directory.Exists(strUserDir))
|
if(bCreate && !Directory.Exists(strUserDir))
|
||||||
Directory.CreateDirectory(strUserDir);
|
Directory.CreateDirectory(strUserDir);
|
||||||
#endif
|
#endif
|
||||||
strUserDir = UrlUtil.EnsureTerminatingSeparator(strUserDir, false);
|
|
||||||
return (strUserDir + UserKeyFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static byte[] LoadUserKey(bool bThrow)
|
strUserDir = UrlUtil.EnsureTerminatingSeparator(strUserDir, false);
|
||||||
{
|
return (strUserDir + UserKeyFileName);
|
||||||
byte[] pbKey = null;
|
}
|
||||||
|
|
||||||
|
private static byte[] LoadUserKey(bool bThrow)
|
||||||
|
{
|
||||||
|
byte[] pbKey = null;
|
||||||
|
|
||||||
#if !KeePassLibSD
|
#if !KeePassLibSD
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string strFilePath = GetUserKeyFilePath(false);
|
string strFilePath = GetUserKeyFilePath(false);
|
||||||
|
|
||||||
#if ModernKeePassLib
|
#if ModernKeePassLib
|
||||||
var fileStream = StorageFile.GetFileFromPathAsync(strFilePath).GetAwaiter().GetResult().OpenStreamForReadAsync().GetAwaiter().GetResult();
|
var fileStream = StorageFile.GetFileFromPathAsync(strFilePath).GetAwaiter().GetResult().OpenStreamForReadAsync().GetAwaiter().GetResult();
|
||||||
var pbProtectedKey = new byte[(int)fileStream.Length];
|
var pbProtectedKey = new byte[(int)fileStream.Length];
|
||||||
@@ -124,25 +127,26 @@ namespace ModernKeePassLib.Keys
|
|||||||
#else
|
#else
|
||||||
byte[] pbProtectedKey = File.ReadAllBytes(strFilePath);
|
byte[] pbProtectedKey = File.ReadAllBytes(strFilePath);
|
||||||
#endif
|
#endif
|
||||||
pbKey = ProtectedData.Unprotect(pbProtectedKey, m_pbEntropy,
|
|
||||||
DataProtectionScope.CurrentUser);
|
pbKey = ProtectedData.Unprotect(pbProtectedKey, m_pbEntropy,
|
||||||
}
|
DataProtectionScope.CurrentUser);
|
||||||
catch (Exception)
|
}
|
||||||
{
|
catch(Exception)
|
||||||
if (bThrow) throw;
|
{
|
||||||
pbKey = null;
|
if(bThrow) throw;
|
||||||
}
|
pbKey = null;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return pbKey;
|
return pbKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] CreateUserKey()
|
private static byte[] CreateUserKey()
|
||||||
{
|
{
|
||||||
#if KeePassLibSD
|
#if KeePassLibSD
|
||||||
return null;
|
return null;
|
||||||
#else
|
#else
|
||||||
string strFilePath = GetUserKeyFilePath(true);
|
string strFilePath = GetUserKeyFilePath(true);
|
||||||
|
|
||||||
byte[] pbRandomKey = CryptoRandom.Instance.GetRandomBytes(64);
|
byte[] pbRandomKey = CryptoRandom.Instance.GetRandomBytes(64);
|
||||||
byte[] pbProtectedKey = ProtectedData.Protect(pbRandomKey,
|
byte[] pbProtectedKey = ProtectedData.Protect(pbRandomKey,
|
||||||
@@ -155,12 +159,12 @@ namespace ModernKeePassLib.Keys
|
|||||||
File.WriteAllBytes(strFilePath, pbProtectedKey);
|
File.WriteAllBytes(strFilePath, pbProtectedKey);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
byte[] pbKey = LoadUserKey(true);
|
byte[] pbKey = LoadUserKey(true);
|
||||||
Debug.Assert(MemUtil.ArraysEqual(pbKey, pbRandomKey));
|
Debug.Assert(MemUtil.ArraysEqual(pbKey, pbRandomKey));
|
||||||
|
|
||||||
MemUtil.ZeroByteArray(pbRandomKey);
|
MemUtil.ZeroByteArray(pbRandomKey);
|
||||||
return pbKey;
|
return pbKey;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
<package >
|
<package >
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>ModernKeePassLib</id>
|
<id>ModernKeePassLib</id>
|
||||||
<version>2.37.8000</version>
|
<version>2.38.1</version>
|
||||||
<title>ModernKeePassLib</title>
|
<title>ModernKeePassLib</title>
|
||||||
<authors>Geoffroy Bonneville</authors>
|
<authors>Geoffroy Bonneville</authors>
|
||||||
<owners>Geoffroy Bonneville</owners>
|
<owners>Geoffroy Bonneville</owners>
|
||||||
@@ -10,8 +10,8 @@
|
|||||||
<projectUrl>https://github.com/wismna/ModernKeePass</projectUrl>
|
<projectUrl>https://github.com/wismna/ModernKeePass</projectUrl>
|
||||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||||
<description>Portable KeePass Password Management Library that targets .Net Standard and WinRT. Allows reading, editing and writing to KeePass 2.x databases.</description>
|
<description>Portable KeePass Password Management Library that targets .Net Standard and WinRT. Allows reading, editing and writing to KeePass 2.x databases.</description>
|
||||||
<releaseNotes></releaseNotes>
|
<releaseNotes>Version bump to 2.38</releaseNotes>
|
||||||
<copyright>Copyright © 2017 Geoffroy Bonneville</copyright>
|
<copyright>Copyright © 2018 Geoffroy Bonneville</copyright>
|
||||||
<tags>KeePass KeePassLib Portable PCL NetStandard</tags>
|
<tags>KeePass KeePassLib Portable PCL NetStandard</tags>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<group targetFramework=".NETStandard1.2">
|
<group targetFramework=".NETStandard1.2">
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2014 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -19,14 +19,17 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Windows.Forms;
|
#if !KeePassUAP
|
||||||
using System.Threading;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Threading;
|
||||||
using System.Diagnostics;
|
using System.Windows.Forms;
|
||||||
|
#endif
|
||||||
|
|
||||||
using ModernKeePassLib.Utility;
|
using ModernKeePassLib.Utility;
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2014 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -19,11 +19,14 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
#if !KeePassUAP
|
||||||
|
using System.Windows.Forms;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace ModernKeePassLib.Native
|
namespace ModernKeePassLib.Native
|
||||||
{
|
{
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2014 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -18,11 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Text;
|
|
||||||
using System.Security;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.IO;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
using ModernKeePassLib.Utility;
|
using ModernKeePassLib.Utility;
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -124,11 +124,11 @@ namespace ModernKeePassLib
|
|||||||
#if ModernKeePassLib
|
#if ModernKeePassLib
|
||||||
img = GfxUtil.ScaleImage(m_pbImageDataPng, w, h).GetAwaiter().GetResult();
|
img = GfxUtil.ScaleImage(m_pbImageDataPng, w, h).GetAwaiter().GetResult();
|
||||||
#else
|
#else
|
||||||
img = GfxUtil.ScaleImage(m_imgOrg, w, h, ScaleTransformFlags.UIIcon);
|
img = GfxUtil.ScaleImage(m_imgOrg, w, h, ScaleTransformFlags.UIIcon);
|
||||||
#endif
|
#endif
|
||||||
m_dImageCache[lID] = img;
|
m_dImageCache[lID] = img;
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2014 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -52,7 +52,7 @@ namespace ModernKeePassLib
|
|||||||
|
|
||||||
private static bool m_bPrimaryCreated = false;
|
private static bool m_bPrimaryCreated = false;
|
||||||
|
|
||||||
// Initializations see Clear()
|
// Initializations: see Clear()
|
||||||
private PwGroup m_pgRootGroup = null;
|
private PwGroup m_pgRootGroup = null;
|
||||||
private PwObjectList<PwDeletedObject> m_vDeletedObjects = new PwObjectList<PwDeletedObject>();
|
private PwObjectList<PwDeletedObject> m_vDeletedObjects = new PwObjectList<PwDeletedObject>();
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -55,20 +55,20 @@ namespace ModernKeePassLib
|
|||||||
/// e.g. 2.19 = 0x02130000.
|
/// e.g. 2.19 = 0x02130000.
|
||||||
/// It is highly recommended to use <c>FileVersion64</c> instead.
|
/// It is highly recommended to use <c>FileVersion64</c> instead.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const uint Version32 = 0x02250000;
|
public const uint Version32 = 0x02260000;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Version, encoded as 64-bit unsigned integer
|
/// Version, encoded as 64-bit unsigned integer
|
||||||
/// (component-wise, 16 bits per component).
|
/// (component-wise, 16 bits per component).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const ulong FileVersion64 = 0x0002002500000000UL;
|
public const ulong FileVersion64 = 0x0002002600000000UL;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Version, encoded as string.
|
/// Version, encoded as string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string VersionString = "2.37";
|
public const string VersionString = "2.38";
|
||||||
|
|
||||||
public const string Copyright = @"Copyright © 2003-2017 Dominik Reichl";
|
public const string Copyright = @"Copyright © 2003-2018 Dominik Reichl";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Product website URL. Terminated by a forward slash.
|
/// Product website URL. Terminated by a forward slash.
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Xml;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
using ModernKeePassLib.Collections;
|
using ModernKeePassLib.Collections;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -21,7 +21,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
#if ModernKeePassLib
|
#if ModernKeePassLib
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -634,10 +634,15 @@ namespace ModernKeePassLib.Serialization
|
|||||||
|
|
||||||
private static Stream OpenWriteLocal(IOConnectionInfo ioc)
|
private static Stream OpenWriteLocal(IOConnectionInfo ioc)
|
||||||
{
|
{
|
||||||
|
#if ModernKeePassLib
|
||||||
return ioc.StorageFile.OpenAsync(FileAccessMode.ReadWrite).GetAwaiter().GetResult().AsStream();
|
return ioc.StorageFile.OpenAsync(FileAccessMode.ReadWrite).GetAwaiter().GetResult().AsStream();
|
||||||
}
|
#else
|
||||||
|
return new FileStream(ioc.Path, FileMode.Create, FileAccess.Write,
|
||||||
|
FileShare.None);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
public static bool FileExists(IOConnectionInfo ioc)
|
public static bool FileExists(IOConnectionInfo ioc)
|
||||||
{
|
{
|
||||||
return FileExists(ioc, false);
|
return FileExists(ioc, false);
|
||||||
}
|
}
|
||||||
@@ -647,16 +652,72 @@ namespace ModernKeePassLib.Serialization
|
|||||||
if(ioc == null) { Debug.Assert(false); return false; }
|
if(ioc == null) { Debug.Assert(false); return false; }
|
||||||
|
|
||||||
RaiseIOAccessPreEvent(ioc, IOAccessType.Exists);
|
RaiseIOAccessPreEvent(ioc, IOAccessType.Exists);
|
||||||
|
|
||||||
|
#if ModernKeePassLib
|
||||||
return ioc.StorageFile.IsAvailable;
|
return ioc.StorageFile.IsAvailable;
|
||||||
|
#else
|
||||||
|
if(ioc.IsLocalFile()) return File.Exists(ioc.Path);
|
||||||
|
|
||||||
|
#if !KeePassLibSD
|
||||||
|
if(ioc.Path.StartsWith("ftp://", StrUtil.CaseIgnoreCmp))
|
||||||
|
{
|
||||||
|
bool b = SendCommand(ioc, WebRequestMethods.Ftp.GetDateTimestamp);
|
||||||
|
if(!b && bThrowErrors) throw new InvalidOperationException();
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Stream s = OpenRead(ioc);
|
||||||
|
if(s == null) throw new FileNotFoundException();
|
||||||
|
|
||||||
|
try { s.ReadByte(); }
|
||||||
|
catch(Exception) { }
|
||||||
|
|
||||||
|
// We didn't download the file completely; close may throw
|
||||||
|
// an exception -- that's okay
|
||||||
|
try { s.Close(); }
|
||||||
|
catch(Exception) { }
|
||||||
|
}
|
||||||
|
catch(Exception)
|
||||||
|
{
|
||||||
|
if(bThrowErrors) throw;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DeleteFile(IOConnectionInfo ioc)
|
public static void DeleteFile(IOConnectionInfo ioc)
|
||||||
{
|
{
|
||||||
RaiseIOAccessPreEvent(ioc, IOAccessType.Delete);
|
RaiseIOAccessPreEvent(ioc, IOAccessType.Delete);
|
||||||
|
|
||||||
if (!ioc.IsLocalFile()) return;
|
#if ModernKeePassLib
|
||||||
|
if (!ioc.IsLocalFile()) return;
|
||||||
ioc.StorageFile?.DeleteAsync().GetAwaiter().GetResult();
|
ioc.StorageFile?.DeleteAsync().GetAwaiter().GetResult();
|
||||||
|
#else
|
||||||
|
if(ioc.IsLocalFile()) { File.Delete(ioc.Path); return; }
|
||||||
|
|
||||||
|
#if !KeePassLibSD
|
||||||
|
WebRequest req = CreateWebRequest(ioc);
|
||||||
|
if(req != null)
|
||||||
|
{
|
||||||
|
if(IsHttpWebRequest(req)) req.Method = "DELETE";
|
||||||
|
else if(IsFtpWebRequest(req))
|
||||||
|
req.Method = WebRequestMethods.Ftp.DeleteFile;
|
||||||
|
else if(IsFileWebRequest(req))
|
||||||
|
{
|
||||||
|
File.Delete(UrlUtil.FileUrlToPath(ioc.Path));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else req.Method = WrmDeleteFile;
|
||||||
|
|
||||||
|
DisposeResponse(req.GetResponse(), true);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -671,10 +732,76 @@ namespace ModernKeePassLib.Serialization
|
|||||||
public static void RenameFile(IOConnectionInfo iocFrom, IOConnectionInfo iocTo)
|
public static void RenameFile(IOConnectionInfo iocFrom, IOConnectionInfo iocTo)
|
||||||
{
|
{
|
||||||
RaiseIOAccessPreEvent(iocFrom, iocTo, IOAccessType.Move);
|
RaiseIOAccessPreEvent(iocFrom, iocTo, IOAccessType.Move);
|
||||||
|
|
||||||
if (!iocFrom.IsLocalFile()) return;
|
#if ModernKeePassLib
|
||||||
|
if (!iocFrom.IsLocalFile()) return;
|
||||||
iocFrom.StorageFile?.RenameAsync(iocTo.Path).GetAwaiter().GetResult();
|
iocFrom.StorageFile?.RenameAsync(iocTo.Path).GetAwaiter().GetResult();
|
||||||
}
|
#else
|
||||||
|
if(iocFrom.IsLocalFile()) { File.Move(iocFrom.Path, iocTo.Path); return; }
|
||||||
|
|
||||||
|
#if !KeePassLibSD
|
||||||
|
WebRequest req = CreateWebRequest(iocFrom);
|
||||||
|
if(req != null)
|
||||||
|
{
|
||||||
|
if(IsHttpWebRequest(req))
|
||||||
|
{
|
||||||
|
#if KeePassUAP
|
||||||
|
throw new NotSupportedException();
|
||||||
|
#else
|
||||||
|
req.Method = "MOVE";
|
||||||
|
req.Headers.Set("Destination", iocTo.Path); // Full URL supported
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if(IsFtpWebRequest(req))
|
||||||
|
{
|
||||||
|
#if KeePassUAP
|
||||||
|
throw new NotSupportedException();
|
||||||
|
#else
|
||||||
|
req.Method = WebRequestMethods.Ftp.Rename;
|
||||||
|
string strTo = UrlUtil.GetFileName(iocTo.Path);
|
||||||
|
|
||||||
|
// We're affected by .NET bug 621450:
|
||||||
|
// https://connect.microsoft.com/VisualStudio/feedback/details/621450/problem-renaming-file-on-ftp-server-using-ftpwebrequest-in-net-framework-4-0-vs2010-only
|
||||||
|
// Prepending "./", "%2E/" or "Dummy/../" doesn't work.
|
||||||
|
|
||||||
|
((FtpWebRequest)req).RenameTo = strTo;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if(IsFileWebRequest(req))
|
||||||
|
{
|
||||||
|
File.Move(UrlUtil.FileUrlToPath(iocFrom.Path),
|
||||||
|
UrlUtil.FileUrlToPath(iocTo.Path));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if KeePassUAP
|
||||||
|
throw new NotSupportedException();
|
||||||
|
#else
|
||||||
|
req.Method = WrmMoveFile;
|
||||||
|
req.Headers.Set(WrhMoveFileTo, iocTo.Path);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !KeePassUAP // Unreachable code
|
||||||
|
DisposeResponse(req.GetResponse(), true);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// using(Stream sIn = IOConnection.OpenRead(iocFrom))
|
||||||
|
// {
|
||||||
|
// using(Stream sOut = IOConnection.OpenWrite(iocTo))
|
||||||
|
// {
|
||||||
|
// MemUtil.CopyStream(sIn, sOut);
|
||||||
|
// sOut.Close();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// sIn.Close();
|
||||||
|
// }
|
||||||
|
// DeleteFile(iocFrom);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassRT)
|
#if (!ModernKeePassLib && !KeePassLibSD && !KeePassRT)
|
||||||
private static bool SendCommand(IOConnectionInfo ioc, string strMethod)
|
private static bool SendCommand(IOConnectionInfo ioc, string strMethod)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -215,7 +215,7 @@ namespace ModernKeePassLib.Serialization
|
|||||||
if (m_uFileVersion >= FileVersion32_4) xws.CloseOutput = true;
|
if (m_uFileVersion >= FileVersion32_4) xws.CloseOutput = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XmlWriter xw = XmlWriter.Create(sXml, xws);
|
XmlWriter xw = XmlWriter.Create(sXml, xws);
|
||||||
#else
|
#else
|
||||||
XmlTextWriter xw = new XmlTextWriter(sXml, encNoBom);
|
XmlTextWriter xw = new XmlTextWriter(sXml, encNoBom);
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -469,8 +469,14 @@ namespace ModernKeePassLib.Serialization
|
|||||||
Debug.Assert((lStreams.IndexOf(lStreams[i]) == i) &&
|
Debug.Assert((lStreams.IndexOf(lStreams[i]) == i) &&
|
||||||
(lStreams.LastIndexOf(lStreams[i]) == i));
|
(lStreams.LastIndexOf(lStreams[i]) == i));
|
||||||
|
|
||||||
try { lStreams[i].Dispose(); }
|
try { lStreams[i].Dispose(); }
|
||||||
catch(Exception) { Debug.Assert(false); }
|
// Unnecessary exception from CryptoStream with
|
||||||
|
// RijndaelManagedTransform when a stream hasn't been
|
||||||
|
// read completely (e.g. incorrect master key)
|
||||||
|
#if !ModernKeePassLib
|
||||||
|
catch(CryptographicException) { }
|
||||||
|
#endif
|
||||||
|
catch (Exception) { Debug.Assert(false); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not clear the list
|
// Do not clear the list
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -32,7 +32,7 @@ namespace ModernKeePassLib.Translation
|
|||||||
set { m_strApp = value; }
|
set { m_strApp = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private string m_strForVersion = PwDefs.VersionString;
|
private string m_strForVersion = string.Empty;
|
||||||
public string ApplicationVersion
|
public string ApplicationVersion
|
||||||
{
|
{
|
||||||
get { return m_strForVersion; }
|
get { return m_strForVersion; }
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -37,7 +37,10 @@ namespace ModernKeePassLib.Utility
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class MemUtil
|
public static class MemUtil
|
||||||
{
|
{
|
||||||
public static readonly byte[] EmptyByteArray = new byte[0];
|
internal static readonly byte[] EmptyByteArray = new byte[0];
|
||||||
|
|
||||||
|
internal static readonly ArrayHelperEx<char> ArrayHelperExOfChar =
|
||||||
|
new ArrayHelperEx<char>();
|
||||||
|
|
||||||
private static readonly uint[] m_vSBox = new uint[256] {
|
private static readonly uint[] m_vSBox = new uint[256] {
|
||||||
0xCD2FACB3, 0xE78A7F5C, 0x6F0803FC, 0xBCF6E230,
|
0xCD2FACB3, 0xE78A7F5C, 0x6F0803FC, 0xBCF6E230,
|
||||||
@@ -782,4 +785,78 @@ namespace ModernKeePassLib.Utility
|
|||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal sealed class ArrayHelperEx<T> : IEqualityComparer<T[]>, IComparer<T[]>
|
||||||
|
where T : IEquatable<T>, IComparable<T>
|
||||||
|
{
|
||||||
|
public int GetHashCode(T[] obj)
|
||||||
|
{
|
||||||
|
if(obj == null) throw new ArgumentNullException("obj");
|
||||||
|
|
||||||
|
uint h = 0xC17962B7U;
|
||||||
|
unchecked
|
||||||
|
{
|
||||||
|
int n = obj.Length;
|
||||||
|
for(int i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
h += (uint)obj[i].GetHashCode();
|
||||||
|
h = MemUtil.RotateLeft32(h * 0x5FC34C67U, 13);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int)h;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* internal ulong GetHashCodeEx(T[] obj)
|
||||||
|
{
|
||||||
|
if(obj == null) throw new ArgumentNullException("obj");
|
||||||
|
|
||||||
|
ulong h = 0x207CAC8E509A3FC9UL;
|
||||||
|
unchecked
|
||||||
|
{
|
||||||
|
int n = obj.Length;
|
||||||
|
for(int i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
h += (uint)obj[i].GetHashCode();
|
||||||
|
h = MemUtil.RotateLeft64(h * 0x54724D3EA2860CBBUL, 29);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return h;
|
||||||
|
} */
|
||||||
|
|
||||||
|
public bool Equals(T[] x, T[] y)
|
||||||
|
{
|
||||||
|
if(object.ReferenceEquals(x, y)) return true;
|
||||||
|
if((x == null) || (y == null)) return false;
|
||||||
|
|
||||||
|
int n = x.Length;
|
||||||
|
if(n != y.Length) return false;
|
||||||
|
|
||||||
|
for(int i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
if(!x[i].Equals(y[i])) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Compare(T[] x, T[] y)
|
||||||
|
{
|
||||||
|
if(object.ReferenceEquals(x, y)) return 0;
|
||||||
|
if(x == null) return -1;
|
||||||
|
if(y == null) return 1;
|
||||||
|
|
||||||
|
int n = x.Length, m = y.Length;
|
||||||
|
if(n != m) return ((n < m) ? -1 : 1);
|
||||||
|
|
||||||
|
for(int i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
T tX = x[i], tY = y[i];
|
||||||
|
if(!tX.Equals(tY)) return tX.CompareTo(tY);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2017 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -101,6 +101,9 @@ namespace ModernKeePassLib.Utility
|
|||||||
// 1632:
|
// 1632:
|
||||||
// RichTextBox rendering bug for bold/italic text.
|
// RichTextBox rendering bug for bold/italic text.
|
||||||
// https://sourceforge.net/p/keepass/bugs/1632/
|
// https://sourceforge.net/p/keepass/bugs/1632/
|
||||||
|
// 1690:
|
||||||
|
// Removing items from a list view doesn't work properly.
|
||||||
|
// https://sourceforge.net/p/keepass/bugs/1690/
|
||||||
// 2139:
|
// 2139:
|
||||||
// Shortcut keys are ignored.
|
// Shortcut keys are ignored.
|
||||||
// https://sourceforge.net/p/keepass/feature-requests/2139/
|
// https://sourceforge.net/p/keepass/feature-requests/2139/
|
||||||
@@ -157,6 +160,9 @@ namespace ModernKeePassLib.Utility
|
|||||||
// 2449941153:
|
// 2449941153:
|
||||||
// RichTextBox doesn't properly escape '}' when generating RTF data.
|
// RichTextBox doesn't properly escape '}' when generating RTF data.
|
||||||
// https://sourceforge.net/p/keepass/discussion/329221/thread/920722a1/
|
// https://sourceforge.net/p/keepass/discussion/329221/thread/920722a1/
|
||||||
|
// 3471228285:
|
||||||
|
// Mono requires command line arguments to be encoded differently.
|
||||||
|
// https://sourceforge.net/p/keepass/discussion/329221/thread/cee6bd7d/
|
||||||
// 3574233558:
|
// 3574233558:
|
||||||
// Problems with minimizing windows, no content rendered.
|
// Problems with minimizing windows, no content rendered.
|
||||||
// https://sourceforge.net/p/keepass/discussion/329220/thread/d50a79d6/
|
// https://sourceforge.net/p/keepass/discussion/329220/thread/d50a79d6/
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2014 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -21,24 +21,22 @@ using System;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
using System.Drawing;
|
||||||
#if ModernKeePassLib
|
#if ModernKeePassLib
|
||||||
using Windows.Security.Cryptography;
|
using ModernKeePassLib.Cryptography;
|
||||||
#else
|
#else
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using ModernKeePassLib.Collections;
|
using ModernKeePassLib.Collections;
|
||||||
using ModernKeePassLib.Cryptography;
|
|
||||||
using ModernKeePassLib.Cryptography.PasswordGenerator;
|
using ModernKeePassLib.Cryptography.PasswordGenerator;
|
||||||
using ModernKeePassLib.Native;
|
using ModernKeePassLib.Native;
|
||||||
using ModernKeePassLib.Security;
|
using ModernKeePassLib.Security;
|
||||||
using ModernKeePassLib.Resources;
|
|
||||||
|
|
||||||
namespace ModernKeePassLib.Utility
|
namespace ModernKeePassLib.Utility
|
||||||
{
|
{
|
||||||
@@ -225,11 +223,11 @@ namespace ModernKeePassLib.Utility
|
|||||||
List<StrEncodingInfo> l = new List<StrEncodingInfo>();
|
List<StrEncodingInfo> l = new List<StrEncodingInfo>();
|
||||||
|
|
||||||
l.Add(new StrEncodingInfo(StrEncodingType.Default,
|
l.Add(new StrEncodingInfo(StrEncodingType.Default,
|
||||||
#if ModernKeePassLib || KeePassRT
|
#if ModernKeePassLib ||KeePassUAP
|
||||||
StrUtil.Utf8.WebName, StrUtil.Utf8, 1, null));
|
"Unicode (UTF-8)", StrUtil.Utf8, 1, new byte[] { 0xEF, 0xBB, 0xBF }));
|
||||||
#else
|
#else
|
||||||
#if !KeePassLibSD
|
#if !KeePassLibSD
|
||||||
Encoding.Default.EncodingName,
|
Encoding.Default.EncodingName,
|
||||||
#else
|
#else
|
||||||
Encoding.Default.WebName,
|
Encoding.Default.WebName,
|
||||||
#endif
|
#endif
|
||||||
@@ -304,20 +302,27 @@ namespace ModernKeePassLib.Utility
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert a string into a valid HTML sequence representing that string.
|
/// Convert a string to a HTML sequence representing that string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="str">String to convert.</param>
|
/// <param name="str">String to convert.</param>
|
||||||
/// <returns>String, HTML-encoded.</returns>
|
/// <returns>String, HTML-encoded.</returns>
|
||||||
public static string StringToHtml(string str)
|
public static string StringToHtml(string str)
|
||||||
|
{
|
||||||
|
return StringToHtml(str, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static string StringToHtml(string str, bool bNbsp)
|
||||||
{
|
{
|
||||||
Debug.Assert(str != null); if(str == null) throw new ArgumentNullException("str");
|
Debug.Assert(str != null); if(str == null) throw new ArgumentNullException("str");
|
||||||
|
|
||||||
str = str.Replace(@"&", @"&");
|
str = str.Replace(@"&", @"&"); // Must be first
|
||||||
str = str.Replace(@"<", @"<");
|
str = str.Replace(@"<", @"<");
|
||||||
str = str.Replace(@">", @">");
|
str = str.Replace(@">", @">");
|
||||||
str = str.Replace("\"", @""");
|
str = str.Replace("\"", @""");
|
||||||
str = str.Replace("\'", @"'");
|
str = str.Replace("\'", @"'");
|
||||||
|
|
||||||
|
if(bNbsp) str = str.Replace(" ", @" "); // Before <br />
|
||||||
|
|
||||||
str = NormalizeNewLines(str, false);
|
str = NormalizeNewLines(str, false);
|
||||||
str = str.Replace("\n", @"<br />" + Environment.NewLine);
|
str = str.Replace("\n", @"<br />" + Environment.NewLine);
|
||||||
|
|
||||||
@@ -833,10 +838,10 @@ namespace ModernKeePassLib.Utility
|
|||||||
#if ModernKeePassLib
|
#if ModernKeePassLib
|
||||||
if (bExpNum != bExpNumY) return StringComparer.OrdinalIgnoreCase.Compare(strX, strY);
|
if (bExpNum != bExpNumY) return StringComparer.OrdinalIgnoreCase.Compare(strX, strY);
|
||||||
#else
|
#else
|
||||||
if(bExpNum != bExpNumY) return string.Compare(strX, strY, true);
|
if(bExpNum != bExpNumY) return string.Compare(strX, strY, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int pX = 0;
|
int pX = 0;
|
||||||
int pY = 0;
|
int pY = 0;
|
||||||
while((pX < cX) && (pY < cY))
|
while((pX < cX) && (pY < cY))
|
||||||
{
|
{
|
||||||
@@ -894,7 +899,7 @@ namespace ModernKeePassLib.Utility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(bStrCmp)
|
if(bStrCmp)
|
||||||
{
|
{
|
||||||
#if ModernKeePassLib
|
#if ModernKeePassLib
|
||||||
int c = StringComparer.OrdinalIgnoreCase.Compare(strPartX, strPartY);
|
int c = StringComparer.OrdinalIgnoreCase.Compare(strPartX, strPartY);
|
||||||
#else
|
#else
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2014 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
using ModernKeePassLib.Interfaces;
|
using ModernKeePassLib.Interfaces;
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
KeePass Password Safe - The Open-Source Password Manager
|
KeePass Password Safe - The Open-Source Password Manager
|
||||||
Copyright (C) 2003-2014 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -19,13 +19,12 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
#if ModernKeePassLib
|
#if ModernKeePassLib
|
||||||
//using PCLStorage;
|
|
||||||
using Windows.Storage;
|
using Windows.Storage;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -56,7 +55,7 @@ namespace ModernKeePassLib.Utility
|
|||||||
#else
|
#else
|
||||||
get { return Path.DirectorySeparatorChar; }
|
get { return Path.DirectorySeparatorChar; }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the directory (path) of a file name. The returned string may be
|
/// Get the directory (path) of a file name. The returned string may be
|
||||||
@@ -650,8 +649,7 @@ namespace ModernKeePassLib.Utility
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(Directory.Exists(strDir) == false)
|
if(!Directory.Exists(strDir)) Directory.CreateDirectory(strDir);
|
||||||
Directory.CreateDirectory(strDir);
|
|
||||||
}
|
}
|
||||||
catch(Exception) { Debug.Assert(false); }
|
catch(Exception) { Debug.Assert(false); }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user