Compare commits
163 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
cc7ee35500 | ||
![]() |
2e5ee5f836 | ||
![]() |
177b36d869 | ||
![]() |
cd484c0398 | ||
![]() |
a6e3c2024f | ||
![]() |
31e7037d4f | ||
![]() |
13c2e297a8 | ||
![]() |
45d08a5762 | ||
![]() |
0568efc94b | ||
![]() |
b61edb44bf | ||
![]() |
415d01b36d | ||
![]() |
b2864feb73 | ||
![]() |
9ddafb6525 | ||
![]() |
3771e86169 | ||
![]() |
e8533afe78 | ||
![]() |
28361f4105 | ||
![]() |
110ef46f56 | ||
![]() |
5cb23cd9b4 | ||
![]() |
6d368e57af | ||
![]() |
36bbaa7270 | ||
![]() |
eb4888c361 | ||
![]() |
1773f9672e | ||
![]() |
59fbaf87e6 | ||
![]() |
305a2aa6dc | ||
![]() |
ed92b3476f | ||
![]() |
b32fa9672f | ||
![]() |
dd07271550 | ||
![]() |
430db12d6f | ||
![]() |
53b881c451 | ||
![]() |
a4219bb9c7 | ||
![]() |
7609260218 | ||
![]() |
2c8bd15474 | ||
![]() |
d6f3ad8b56 | ||
![]() |
b9d2f57d41 | ||
![]() |
cd34858f9a | ||
![]() |
1639d5abee | ||
![]() |
dd2e4546b9 | ||
![]() |
5b6af723b0 | ||
![]() |
9e660f957f | ||
![]() |
1960af5149 | ||
![]() |
792d16aba7 | ||
![]() |
e6e854138b | ||
![]() |
2117e5abf9 | ||
![]() |
04151becfe | ||
![]() |
6cc007e47e | ||
![]() |
cd1877d34d | ||
![]() |
df3bc19fc0 | ||
![]() |
e4e7b1cb48 | ||
![]() |
c46b7be051 | ||
![]() |
5a8fa21cd1 | ||
![]() |
7df048263b | ||
![]() |
aba45f4cf5 | ||
![]() |
d9bcac600c | ||
![]() |
533021da3f | ||
![]() |
ceeb7e23b4 | ||
![]() |
f226edf018 | ||
![]() |
e6f0f12240 | ||
![]() |
9df7c03e02 | ||
![]() |
1b8e290b30 | ||
![]() |
a90fd17bea | ||
![]() |
3fb358ca85 | ||
![]() |
83d638e0e5 | ||
![]() |
20a147fd04 | ||
![]() |
730af8b9ac | ||
![]() |
9a400cecd2 | ||
![]() |
b5d9ac859f | ||
![]() |
144cc3c40a | ||
![]() |
2b514598d4 | ||
![]() |
9c55f7d9e0 | ||
![]() |
7fb070c5fc | ||
![]() |
b0dccaea98 | ||
![]() |
7939a0c9e7 | ||
![]() |
5bccc32bb1 | ||
![]() |
1bf7ce27da | ||
![]() |
59085fd790 | ||
![]() |
7f004ca720 | ||
![]() |
71098fd9ac | ||
![]() |
1ec17c77b5 | ||
![]() |
adb3a81b2a | ||
![]() |
ccf3a53253 | ||
![]() |
9a7a3c6400 | ||
![]() |
1963e2d7bb | ||
![]() |
e385eb78e2 | ||
![]() |
e80ac513c4 | ||
![]() |
cf36613c65 | ||
![]() |
ca3a9a7722 | ||
![]() |
e85d5d519a | ||
![]() |
2eccf190b4 | ||
![]() |
2c18da0fbc | ||
![]() |
776a13ef28 | ||
![]() |
b5e6e4904c | ||
![]() |
1e2d1503fe | ||
![]() |
50d16acee9 | ||
![]() |
710e0f9bba | ||
![]() |
84efc14b00 | ||
![]() |
ddb58119be | ||
![]() |
3ced852eb4 | ||
![]() |
9928c85d0a | ||
![]() |
8a095a4032 | ||
![]() |
9372cb7190 | ||
![]() |
bf3a5891e3 | ||
![]() |
ca61fa9d1d | ||
![]() |
42eb8222fc | ||
![]() |
2aca631390 | ||
![]() |
b175295d43 | ||
![]() |
0226456d41 | ||
![]() |
d18aba0747 | ||
![]() |
449b5e3f0a | ||
![]() |
301216fc2e | ||
![]() |
c3bef01fe9 | ||
![]() |
19abf7a1b0 | ||
![]() |
3e36a6e5fa | ||
![]() |
e65bd9a524 | ||
![]() |
697b331a65 | ||
![]() |
3767450343 | ||
![]() |
2ffa9b06c5 | ||
![]() |
c1e80d209f | ||
![]() |
a36f5a375a | ||
![]() |
4e7f6d62d2 | ||
![]() |
f8e637cdbc | ||
![]() |
abf32cf499 | ||
![]() |
eee24819d5 | ||
![]() |
b7e4bf0be5 | ||
![]() |
be65fe2521 | ||
![]() |
05e62bd40d | ||
![]() |
ca4e819183 | ||
![]() |
80b75f11a0 | ||
![]() |
a18f013d8c | ||
![]() |
ffc06404c1 | ||
![]() |
849cb0c707 | ||
![]() |
219932258c | ||
![]() |
59a5bb0c89 | ||
![]() |
29fca5c1f0 | ||
![]() |
fec0e7768a | ||
![]() |
3dcb8ed32b | ||
![]() |
2b1f5cfd0a | ||
![]() |
84e08d39a4 | ||
![]() |
0a171a6a72 | ||
![]() |
cdcbe148c9 | ||
![]() |
fea28640b5 | ||
![]() |
295f19c54e | ||
![]() |
de759e5870 | ||
![]() |
e9995e0c80 | ||
![]() |
234fd59d22 | ||
![]() |
7617012292 | ||
![]() |
e8085c1c0e | ||
![]() |
9e8a9e7b9e | ||
![]() |
e47516b0e0 | ||
![]() |
b85cb20177 | ||
![]() |
612c7927e9 | ||
![]() |
e69af9cfbe | ||
![]() |
23f324b1d8 | ||
![]() |
a1f7a4245a | ||
![]() |
5dab309921 | ||
![]() |
44d324bc7d | ||
![]() |
ebadedae41 | ||
![]() |
3f89a34946 | ||
![]() |
d823768464 | ||
![]() |
ee340b069b | ||
![]() |
d13a35b9a8 | ||
![]() |
0ce41b9f54 | ||
![]() |
1be1829cfe | ||
![]() |
160922c9fb |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -170,3 +170,4 @@ src/java/Keepass2AndroidPluginSDK2/build/generated/mockable-Google-Inc.-Google-A
|
||||
/src/java/KP2ASoftkeyboard_AS/app/.cxx
|
||||
/src/java/KP2ASoftkeyboard_AS/app/src/main/libs
|
||||
/src/java/KP2AKdbLibrary/app/.cxx
|
||||
/src/ActionViewFilterTest
|
||||
|
@@ -8,7 +8,7 @@ The password database file can be synchronized across different devices. This wo
|
||||
# Where to get it?
|
||||
Regular stable releases of Keepass2Android are available on [Google Play](https://play.google.com/store/apps/details?id=keepass2android.keepass2android).
|
||||
|
||||
Beta-releases can be obtained by opting in to the [Beta testing channel](https://play.google.com/apps/testing/keepass2android.keepass2android) or [Beta testing channel for Keepass2Android Offline](https://play.google.com/apps/testing/keepass2android.keepass2android_nonet). Please join the [Beta tester group](https://plus.google.com/communities/107293657110547776032) for news and discussions about the latest beta releases.
|
||||
Beta-releases can be obtained by opting in to the [Beta testing channel](https://play.google.com/apps/testing/keepass2android.keepass2android) or [Beta testing channel for Keepass2Android Offline](https://play.google.com/apps/testing/keepass2android.keepass2android_nonet).
|
||||
|
||||
# How can I contribute?
|
||||
* Help to translate Keepass2Android into your language or improve translations at [our Crowdin page](http://crowdin.net/project/keepass2android)
|
||||
@@ -19,4 +19,4 @@ Beta-releases can be obtained by opting in to the [Beta testing channel](https:/
|
||||
# How do I learn more?
|
||||
Please see the [documentation](Documentation.md).
|
||||
|
||||
[](https://www.bitrise.io/app/43a23ab54dee9f7e)
|
||||
[](https://www.bitrise.io/app/43a23ab54dee9f7e)
|
||||
|
@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kp2aBusinessLogic", "Kp2aBu
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TwofishCipher", "TwofishCipher\TwofishCipher.csproj", "{5CF675A5-9BEE-4720-BED9-D5BF14A2EBF9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavaFileStorageBindings", "JavaFileStorageBindings\JavaFileStorageBindings.csproj", "{48574278-4779-4B3A-A9E4-9CF1BC285D0B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AndroidFileChooserBinding", "AndroidFileChooserBinding\AndroidFileChooserBinding.csproj", "{3C0F7FE5-639F-4422-A087-8B26CF862D1B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KP2AKdbLibraryBinding", "KP2AKdbLibraryBinding\KP2AKdbLibraryBinding.csproj", "{70D3844A-D9FA-4A64-B205-A84C6A822196}"
|
||||
@@ -107,8 +109,8 @@ Global
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.Release|Win32.Build.0 = Release|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.Release|x64.Build.0 = Release|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.ReleaseNoNet|Any CPU.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.ReleaseNoNet|Any CPU.Build.0 = ReleaseNoNet|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.ReleaseNoNet|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.ReleaseNoNet|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.ReleaseNoNet|Mixed Platforms.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.ReleaseNoNet|Mixed Platforms.Build.0 = ReleaseNoNet|Any CPU
|
||||
{A8779D4D-7C49-4C2F-82BD-2CDC448391DA}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
|
||||
@@ -185,8 +187,8 @@ Global
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.ReleaseNoNet|Any CPU.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.ReleaseNoNet|Any CPU.Build.0 = ReleaseNoNet|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.ReleaseNoNet|Mixed Platforms.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.ReleaseNoNet|Mixed Platforms.Build.0 = ReleaseNoNet|Any CPU
|
||||
{3C0F7FE5-639F-4422-A087-8B26CF862D1B}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
|
||||
@@ -203,8 +205,8 @@ Global
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.ReleaseNoNet|Any CPU.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.ReleaseNoNet|Any CPU.Build.0 = ReleaseNoNet|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.ReleaseNoNet|Mixed Platforms.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.ReleaseNoNet|Mixed Platforms.Build.0 = ReleaseNoNet|Any CPU
|
||||
{70D3844A-D9FA-4A64-B205-A84C6A822196}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
|
||||
@@ -221,8 +223,8 @@ Global
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.ReleaseNoNet|Any CPU.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.ReleaseNoNet|Any CPU.Build.0 = ReleaseNoNet|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.ReleaseNoNet|Mixed Platforms.ActiveCfg = ReleaseNoNet|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.ReleaseNoNet|Mixed Platforms.Build.0 = ReleaseNoNet|Any CPU
|
||||
{3DA3911E-36DE-465E-8F15-F1991B6437E5}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
|
||||
|
@@ -367,5 +367,27 @@ namespace KeePassLib.Cryptography
|
||||
Debug.Assert(iPos == pbRes.Length);
|
||||
return pbRes;
|
||||
}
|
||||
|
||||
|
||||
private static int g_iWeakSeed = 0;
|
||||
public static Random NewWeakRandom()
|
||||
{
|
||||
long s64 = DateTime.UtcNow.ToBinary();
|
||||
int s32 = (int)((s64 >> 32) ^ s64);
|
||||
|
||||
lock (g_oSyncRoot)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
g_iWeakSeed += 0x78A8C4B7; // Prime number
|
||||
s32 ^= g_iWeakSeed;
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent overflow in the Random constructor of .NET 2.0
|
||||
if (s32 == int.MinValue) s32 = int.MaxValue;
|
||||
|
||||
return new Random(s32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
KeePass Password Safe - The Open-Source Password Manager
|
||||
Copyright (C) 2003-2017 Dominik Reichl <dominik.reichl@t-online.de>
|
||||
Copyright (C) 2003-2020 Dominik Reichl <dominik.reichl@t-online.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -20,28 +20,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
#if !KeePassUAP
|
||||
using System.Security.Cryptography;
|
||||
#endif
|
||||
|
||||
using KeePassLib.Native;
|
||||
using KeePassLib.Utility;
|
||||
|
||||
namespace KeePassLib.Cryptography
|
||||
{
|
||||
public static class CryptoUtil
|
||||
{
|
||||
private static bool? g_obProtData = null;
|
||||
public static bool IsProtectedDataSupported
|
||||
{
|
||||
get
|
||||
{
|
||||
if (g_obProtData.HasValue) return g_obProtData.Value;
|
||||
|
||||
bool b = false;
|
||||
try
|
||||
{
|
||||
Random r = CryptoRandom.NewWeakRandom();
|
||||
|
||||
byte[] pbData = new byte[137];
|
||||
r.NextBytes(pbData);
|
||||
|
||||
byte[] pbEnt = new byte[41];
|
||||
r.NextBytes(pbEnt);
|
||||
|
||||
byte[] pbEnc = ProtectedData.Protect(pbData, pbEnt,
|
||||
DataProtectionScope.CurrentUser);
|
||||
if ((pbEnc != null) && !MemUtil.ArraysEqual(pbEnc, pbData))
|
||||
{
|
||||
byte[] pbDec = ProtectedData.Unprotect(pbEnc, pbEnt,
|
||||
DataProtectionScope.CurrentUser);
|
||||
if ((pbDec != null) && MemUtil.ArraysEqual(pbDec, pbData))
|
||||
b = true;
|
||||
}
|
||||
}
|
||||
catch (Exception) { Debug.Assert(false); }
|
||||
|
||||
Debug.Assert(b); // Should be supported on all systems
|
||||
g_obProtData = b;
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] HashSha256(byte[] pbData)
|
||||
{
|
||||
if(pbData == null) throw new ArgumentNullException("pbData");
|
||||
if (pbData == null) throw new ArgumentNullException("pbData");
|
||||
|
||||
return HashSha256(pbData, 0, pbData.Length);
|
||||
}
|
||||
|
||||
public static byte[] HashSha256(byte[] pbData, int iOffset, int cbCount)
|
||||
{
|
||||
if(pbData == null) throw new ArgumentNullException("pbData");
|
||||
if (pbData == null) throw new ArgumentNullException("pbData");
|
||||
|
||||
#if DEBUG
|
||||
byte[] pbCopy = new byte[pbData.Length];
|
||||
@@ -49,7 +88,7 @@ namespace KeePassLib.Cryptography
|
||||
#endif
|
||||
|
||||
byte[] pbHash;
|
||||
using(SHA256Managed h = new SHA256Managed())
|
||||
using (SHA256Managed h = new SHA256Managed())
|
||||
{
|
||||
pbHash = h.ComputeHash(pbData, iOffset, cbCount);
|
||||
}
|
||||
@@ -66,6 +105,22 @@ namespace KeePassLib.Cryptography
|
||||
return pbHash;
|
||||
}
|
||||
|
||||
internal static byte[] HashSha256(string strFilePath)
|
||||
{
|
||||
byte[] pbHash = null;
|
||||
|
||||
using (FileStream fs = new FileStream(strFilePath, FileMode.Open,
|
||||
FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
using (SHA256Managed h = new SHA256Managed())
|
||||
{
|
||||
pbHash = h.ComputeHash(fs);
|
||||
}
|
||||
}
|
||||
|
||||
return pbHash;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a cryptographic key of length <paramref name="cbOut" />
|
||||
/// (in bytes) from <paramref name="pbIn" />.
|
||||
@@ -73,34 +128,34 @@ namespace KeePassLib.Cryptography
|
||||
public static byte[] ResizeKey(byte[] pbIn, int iInOffset,
|
||||
int cbIn, int cbOut)
|
||||
{
|
||||
if(pbIn == null) throw new ArgumentNullException("pbIn");
|
||||
if(cbOut < 0) throw new ArgumentOutOfRangeException("cbOut");
|
||||
if (pbIn == null) throw new ArgumentNullException("pbIn");
|
||||
if (cbOut < 0) throw new ArgumentOutOfRangeException("cbOut");
|
||||
|
||||
if(cbOut == 0) return MemUtil.EmptyByteArray;
|
||||
if (cbOut == 0) return MemUtil.EmptyByteArray;
|
||||
|
||||
byte[] pbHash;
|
||||
if(cbOut <= 32) pbHash = HashSha256(pbIn, iInOffset, cbIn);
|
||||
if (cbOut <= 32) pbHash = HashSha256(pbIn, iInOffset, cbIn);
|
||||
else
|
||||
{
|
||||
using(SHA512Managed h = new SHA512Managed())
|
||||
using (SHA512Managed h = new SHA512Managed())
|
||||
{
|
||||
pbHash = h.ComputeHash(pbIn, iInOffset, cbIn);
|
||||
}
|
||||
}
|
||||
|
||||
if(cbOut == pbHash.Length) return pbHash;
|
||||
if (cbOut == pbHash.Length) return pbHash;
|
||||
|
||||
byte[] pbRet = new byte[cbOut];
|
||||
if(cbOut < pbHash.Length)
|
||||
if (cbOut < pbHash.Length)
|
||||
Array.Copy(pbHash, pbRet, cbOut);
|
||||
else
|
||||
{
|
||||
int iPos = 0;
|
||||
ulong r = 0;
|
||||
while(iPos < cbOut)
|
||||
while (iPos < cbOut)
|
||||
{
|
||||
Debug.Assert(pbHash.Length == 64);
|
||||
using(HMACSHA256 h = new HMACSHA256(pbHash))
|
||||
using (HMACSHA256 h = new HMACSHA256(pbHash))
|
||||
{
|
||||
byte[] pbR = MemUtil.UInt64ToBytes(r);
|
||||
byte[] pbPart = h.ComputeHash(pbR);
|
||||
@@ -125,5 +180,75 @@ namespace KeePassLib.Cryptography
|
||||
MemUtil.ZeroByteArray(pbHash);
|
||||
return pbRet;
|
||||
}
|
||||
|
||||
#if !KeePassUAP
|
||||
private static bool? g_obAesCsp = null;
|
||||
internal static SymmetricAlgorithm CreateAes()
|
||||
{
|
||||
if (g_obAesCsp.HasValue)
|
||||
return (g_obAesCsp.Value ? CreateAesCsp() : new RijndaelManaged());
|
||||
|
||||
SymmetricAlgorithm a = CreateAesCsp();
|
||||
g_obAesCsp = (a != null);
|
||||
return (a ?? new RijndaelManaged());
|
||||
}
|
||||
|
||||
private static SymmetricAlgorithm CreateAesCsp()
|
||||
{
|
||||
try
|
||||
{
|
||||
// On Windows, the CSP implementation is only minimally
|
||||
// faster (and for key derivations it's not used anyway,
|
||||
// as KeePass uses a native implementation based on
|
||||
// CNG/BCrypt, which is much faster)
|
||||
if (!NativeLib.IsUnix()) return null;
|
||||
|
||||
string strFqn = Assembly.CreateQualifiedName(
|
||||
"System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
|
||||
"System.Security.Cryptography.AesCryptoServiceProvider");
|
||||
|
||||
Type t = Type.GetType(strFqn);
|
||||
if (t == null) return null;
|
||||
|
||||
return (Activator.CreateInstance(t) as SymmetricAlgorithm);
|
||||
}
|
||||
catch (Exception) { Debug.Assert(false); }
|
||||
|
||||
return null;
|
||||
}
|
||||
#endif
|
||||
|
||||
public static byte[] ProtectData(byte[] pb, byte[] pbOptEntropy,
|
||||
DataProtectionScope s)
|
||||
{
|
||||
return ProtectDataPriv(pb, true, pbOptEntropy, s);
|
||||
}
|
||||
|
||||
public static byte[] UnprotectData(byte[] pb, byte[] pbOptEntropy,
|
||||
DataProtectionScope s)
|
||||
{
|
||||
return ProtectDataPriv(pb, false, pbOptEntropy, s);
|
||||
}
|
||||
|
||||
private static byte[] ProtectDataPriv(byte[] pb, bool bProtect,
|
||||
byte[] pbOptEntropy, DataProtectionScope s)
|
||||
{
|
||||
if (pb == null) throw new ArgumentNullException("pb");
|
||||
|
||||
if ((pbOptEntropy != null) && (pbOptEntropy.Length == 0))
|
||||
pbOptEntropy = null;
|
||||
|
||||
if (CryptoUtil.IsProtectedDataSupported)
|
||||
{
|
||||
if (bProtect)
|
||||
return ProtectedData.Protect(pb, pbOptEntropy, s);
|
||||
return ProtectedData.Unprotect(pb, pbOptEntropy, s);
|
||||
}
|
||||
|
||||
Debug.Assert(false);
|
||||
byte[] pbCopy = new byte[pb.Length];
|
||||
Array.Copy(pb, pbCopy, pb.Length);
|
||||
return pbCopy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -46,6 +46,8 @@ namespace KeePassLib.Cryptography.KeyDerivation
|
||||
private const ulong NbBlockSizeInQW = NbBlockSize / 8UL;
|
||||
private const ulong NbSyncPoints = 4;
|
||||
|
||||
private const ulong NbAddressesInBlock = 128;
|
||||
|
||||
private const int NbPreHashDigestLength = 64;
|
||||
private const int NbPreHashSeedLength = NbPreHashDigestLength + 8;
|
||||
|
||||
@@ -56,6 +58,7 @@ namespace KeePassLib.Cryptography.KeyDerivation
|
||||
|
||||
private sealed class Argon2Ctx
|
||||
{
|
||||
public Argon2Type Type = Argon2Type.D;
|
||||
public uint Version = 0;
|
||||
|
||||
public ulong Lanes = 0;
|
||||
@@ -89,9 +92,9 @@ namespace KeePassLib.Cryptography.KeyDerivation
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] Argon2d(byte[] pbMsg, byte[] pbSalt, uint uParallel,
|
||||
ulong uMem, ulong uIt, int cbOut, uint uVersion, byte[] pbSecretKey,
|
||||
byte[] pbAssocData)
|
||||
private byte[] Argon2Transform(byte[] pbMsg, byte[] pbSalt, uint uParallel,
|
||||
ulong uMem, ulong uIt, int cbOut, uint uVersion, byte[] pbSecretKey,
|
||||
byte[] pbAssocData)
|
||||
{
|
||||
pbSecretKey = (pbSecretKey ?? MemUtil.EmptyByteArray);
|
||||
pbAssocData = (pbAssocData ?? MemUtil.EmptyByteArray);
|
||||
@@ -101,6 +104,7 @@ namespace KeePassLib.Cryptography.KeyDerivation
|
||||
#endif
|
||||
|
||||
Argon2Ctx ctx = new Argon2Ctx();
|
||||
ctx.Type = m_t;
|
||||
ctx.Version = uVersion;
|
||||
|
||||
ctx.Lanes = uParallel;
|
||||
@@ -137,7 +141,7 @@ namespace KeePassLib.Cryptography.KeyDerivation
|
||||
h.TransformBlock(pbBuf, 0, pbBuf.Length, pbBuf, 0);
|
||||
MemUtil.UInt32ToBytesEx(uVersion, pbBuf, 0);
|
||||
h.TransformBlock(pbBuf, 0, pbBuf.Length, pbBuf, 0);
|
||||
MemUtil.UInt32ToBytesEx(0, pbBuf, 0); // Argon2d type = 0
|
||||
MemUtil.UInt32ToBytesEx((uint)m_t, pbBuf, 0);
|
||||
h.TransformBlock(pbBuf, 0, pbBuf.Length, pbBuf, 0);
|
||||
MemUtil.UInt32ToBytesEx((uint)pbMsg.Length, pbBuf, 0);
|
||||
h.TransformBlock(pbBuf, 0, pbBuf.Length, pbBuf, 0);
|
||||
@@ -487,18 +491,43 @@ namespace KeePassLib.Cryptography.KeyDerivation
|
||||
private static void FillSegmentThr(object o)
|
||||
{
|
||||
Argon2ThreadInfo ti = (o as Argon2ThreadInfo);
|
||||
if(ti == null) { Debug.Assert(false); return; }
|
||||
if (ti == null) { Debug.Assert(false); return; }
|
||||
|
||||
try
|
||||
{
|
||||
Argon2Ctx ctx = ti.Context;
|
||||
if(ctx == null) { Debug.Assert(false); return; }
|
||||
if (ctx == null) { Debug.Assert(false); return; }
|
||||
|
||||
Debug.Assert(ctx.Version >= MinVersion);
|
||||
bool bCanXor = (ctx.Version >= 0x13U);
|
||||
|
||||
ulong[] pbR = new ulong[NbBlockSizeInQW];
|
||||
ulong[] pbTmp = new ulong[NbBlockSizeInQW];
|
||||
ulong[] pbAddrInputZero = null;
|
||||
|
||||
bool bDataIndependentAddr = ((ctx.Type == Argon2Type.ID) &&
|
||||
(ti.Pass == 0) && (ti.Slice < (NbSyncPoints / 2)));
|
||||
if (bDataIndependentAddr)
|
||||
{
|
||||
pbAddrInputZero = new ulong[NbBlockSizeInQW * 3];
|
||||
|
||||
const int iInput = (int)NbBlockSizeInQW;
|
||||
pbAddrInputZero[iInput] = ti.Pass;
|
||||
pbAddrInputZero[iInput + 1] = ti.Lane;
|
||||
pbAddrInputZero[iInput + 2] = ti.Slice;
|
||||
pbAddrInputZero[iInput + 3] = ctx.MemoryBlocks;
|
||||
pbAddrInputZero[iInput + 4] = ctx.TCost;
|
||||
pbAddrInputZero[iInput + 5] = (ulong)ctx.Type;
|
||||
}
|
||||
|
||||
ulong uStart = 0;
|
||||
if((ti.Pass == 0) && (ti.Slice == 0)) uStart = 2;
|
||||
if ((ti.Pass == 0) && (ti.Slice == 0))
|
||||
{
|
||||
uStart = 2;
|
||||
|
||||
if (bDataIndependentAddr)
|
||||
NextAddresses(pbAddrInputZero, pbR, pbTmp);
|
||||
}
|
||||
|
||||
ulong uCur = (ti.Lane * ctx.LaneLength) + (ti.Slice *
|
||||
ctx.SegmentLength) + uStart;
|
||||
@@ -506,17 +535,23 @@ namespace KeePassLib.Cryptography.KeyDerivation
|
||||
ulong uPrev = (((uCur % ctx.LaneLength) == 0) ?
|
||||
(uCur + ctx.LaneLength - 1UL) : (uCur - 1UL));
|
||||
|
||||
ulong[] pbR = new ulong[NbBlockSizeInQW];
|
||||
ulong[] pbTmp = new ulong[NbBlockSizeInQW];
|
||||
|
||||
for(ulong i = uStart; i < ctx.SegmentLength; ++i)
|
||||
for (ulong i = uStart; i < ctx.SegmentLength; ++i)
|
||||
{
|
||||
if((uCur % ctx.LaneLength) == 1)
|
||||
if ((uCur % ctx.LaneLength) == 1)
|
||||
uPrev = uCur - 1UL;
|
||||
|
||||
ulong uPseudoRand = ctx.Mem[uPrev * NbBlockSizeInQW];
|
||||
ulong uPseudoRand;
|
||||
if (bDataIndependentAddr)
|
||||
{
|
||||
ulong iMod = i % NbAddressesInBlock;
|
||||
if (iMod == 0)
|
||||
NextAddresses(pbAddrInputZero, pbR, pbTmp);
|
||||
uPseudoRand = pbAddrInputZero[iMod];
|
||||
}
|
||||
else uPseudoRand = ctx.Mem[uPrev * NbBlockSizeInQW];
|
||||
|
||||
ulong uRefLane = (uPseudoRand >> 32) % ctx.Lanes;
|
||||
if((ti.Pass == 0) && (ti.Slice == 0))
|
||||
if ((ti.Pass == 0) && (ti.Slice == 0))
|
||||
uRefLane = ti.Lane;
|
||||
|
||||
ti.Index = i;
|
||||
@@ -536,11 +571,12 @@ namespace KeePassLib.Cryptography.KeyDerivation
|
||||
|
||||
MemUtil.ZeroArray<ulong>(pbR);
|
||||
MemUtil.ZeroArray<ulong>(pbTmp);
|
||||
if (pbAddrInputZero != null) MemUtil.ZeroArray<ulong>(pbAddrInputZero);
|
||||
}
|
||||
catch(Exception) { Debug.Assert(false); }
|
||||
catch (Exception) { Debug.Assert(false); }
|
||||
|
||||
try { ti.Finished.Set(); }
|
||||
catch(Exception) { Debug.Assert(false); }
|
||||
catch (Exception) { Debug.Assert(false); }
|
||||
}
|
||||
|
||||
#if ARGON2_B2ROUND_ARRAYS
|
||||
@@ -610,6 +646,19 @@ namespace KeePassLib.Cryptography.KeyDerivation
|
||||
XorBlock(pMem, uNext, pbR, 0);
|
||||
}
|
||||
|
||||
private static void NextAddresses(ulong[] pbAddrInputZero, ulong[] pbR,
|
||||
ulong[] pbTmp)
|
||||
{
|
||||
// pbAddrInputZero contains an address block, an input block and a zero block
|
||||
const ulong uAddr = 0;
|
||||
const ulong uInput = NbBlockSizeInQW;
|
||||
const ulong uZero = NbBlockSizeInQW * 2;
|
||||
|
||||
++pbAddrInputZero[uInput + 6];
|
||||
FillBlock(pbAddrInputZero, uZero, uInput, uAddr, false, pbR, pbTmp);
|
||||
FillBlock(pbAddrInputZero, uZero, uAddr, uAddr, false, pbR, pbTmp);
|
||||
}
|
||||
|
||||
private static byte[] FinalHash(Argon2Ctx ctx, int cbOut, Blake2b h)
|
||||
{
|
||||
ulong[] pqBlockHash = new ulong[NbBlockSizeInQW];
|
||||
|
@@ -25,11 +25,22 @@ using System.Text;
|
||||
|
||||
namespace KeePassLib.Cryptography.KeyDerivation
|
||||
{
|
||||
public sealed partial class Argon2Kdf : KdfEngine
|
||||
public enum Argon2Type
|
||||
{
|
||||
// The values must be the same as in the Argon2 specification
|
||||
D = 0,
|
||||
ID = 2
|
||||
}
|
||||
public sealed partial class Argon2Kdf : KdfEngine
|
||||
{
|
||||
private static readonly PwUuid g_uuid = new PwUuid(new byte[] {
|
||||
0xEF, 0x63, 0x6D, 0xDF, 0x8C, 0x29, 0x44, 0x4B,
|
||||
0x91, 0xF7, 0xA9, 0xA4, 0x03, 0xE3, 0x0A, 0x0C });
|
||||
|
||||
|
||||
private static readonly PwUuid g_uuidD = new PwUuid(new byte[] {
|
||||
0xEF, 0x63, 0x6D, 0xDF, 0x8C, 0x29, 0x44, 0x4B,
|
||||
0x91, 0xF7, 0xA9, 0xA4, 0x03, 0xE3, 0x0A, 0x0C });
|
||||
private static readonly PwUuid g_uuidID = new PwUuid(new byte[] {
|
||||
0x9E, 0x29, 0x8B, 0x19, 0x56, 0xDB, 0x47, 0x73,
|
||||
0xB2, 0x3D, 0xFC, 0x3E, 0xC6, 0xF0, 0xA1, 0xE6 });
|
||||
|
||||
public const string ParamSalt = "S"; // Byte[]
|
||||
public const string ParamParallelism = "P"; // UInt32
|
||||
@@ -55,28 +66,37 @@ namespace KeePassLib.Cryptography.KeyDerivation
|
||||
internal const uint MinParallelism = 1;
|
||||
internal const uint MaxParallelism = (1 << 24) - 1;
|
||||
|
||||
internal const ulong DefaultIterations = 2;
|
||||
internal const ulong DefaultMemory = 1024 * 1024; // 1 MB
|
||||
internal const uint DefaultParallelism = 2;
|
||||
internal const ulong DefaultIterations = 2;
|
||||
internal const ulong DefaultMemory = 64 * 1024 * 1024; // 64 MB
|
||||
internal const uint DefaultParallelism = 2;
|
||||
|
||||
public override PwUuid Uuid
|
||||
{
|
||||
get { return g_uuid; }
|
||||
}
|
||||
private readonly Argon2Type m_t;
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "Argon2"; }
|
||||
}
|
||||
public override PwUuid Uuid
|
||||
{
|
||||
get { return ((m_t == Argon2Type.D) ? g_uuidD : g_uuidID); }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return ((m_t == Argon2Type.D) ? "Argon2d" : "Argon2id"); }
|
||||
}
|
||||
|
||||
public Argon2Kdf() : this(Argon2Type.D)
|
||||
{
|
||||
}
|
||||
|
||||
public Argon2Kdf(Argon2Type t)
|
||||
{
|
||||
if ((t != Argon2Type.D) && (t != Argon2Type.ID))
|
||||
throw new NotSupportedException();
|
||||
|
||||
m_t = t;
|
||||
}
|
||||
public override byte[] GetSeed(KdfParameters p)
|
||||
{ return p.GetByteArray(ParamSalt); }
|
||||
|
||||
public Argon2Kdf()
|
||||
{
|
||||
}
|
||||
|
||||
public override KdfParameters GetDefaultParameters()
|
||||
public override KdfParameters GetDefaultParameters()
|
||||
{
|
||||
KdfParameters p = base.GetDefaultParameters();
|
||||
|
||||
@@ -92,7 +112,7 @@ namespace KeePassLib.Cryptography.KeyDerivation
|
||||
public override void Randomize(KdfParameters p)
|
||||
{
|
||||
if(p == null) { Debug.Assert(false); return; }
|
||||
Debug.Assert(g_uuid.Equals(p.KdfUuid));
|
||||
Debug.Assert(p.KdfUuid.Equals(this.Uuid));
|
||||
|
||||
byte[] pb = CryptoRandom.Instance.GetRandomBytes(32);
|
||||
p.SetByteArray(ParamSalt, pb);
|
||||
@@ -128,46 +148,59 @@ namespace KeePassLib.Cryptography.KeyDerivation
|
||||
byte[] pbSecretKey = p.GetByteArray(ParamSecretKey);
|
||||
byte[] pbAssocData = p.GetByteArray(ParamAssocData);
|
||||
|
||||
if (pbSecretKey != null) {
|
||||
throw new ArgumentOutOfRangeException("Unsupported configuration: non-null pbSecretKey");
|
||||
byte[] pbRet;
|
||||
|
||||
if (m_t == Argon2Type.ID)
|
||||
{
|
||||
pbRet = Argon2Transform(pbMsg, pbSalt, uPar, uMem,
|
||||
uIt, 32, v, pbSecretKey, pbAssocData);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pbSecretKey != null)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("Unsupported configuration: non-null pbSecretKey");
|
||||
}
|
||||
|
||||
if (pbAssocData != null)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("Unsupported configuration: non-null pbAssocData");
|
||||
}
|
||||
|
||||
/*
|
||||
byte[] pbRet = Argon2d(pbMsg, pbSalt, uPar, uMem, uIt,
|
||||
32, v, pbSecretKey, pbAssocData);
|
||||
*/
|
||||
|
||||
IntPtr msgPtr = Marshal.AllocHGlobal(pbMsg.Length);
|
||||
IntPtr saltPtr = Marshal.AllocHGlobal(pbSalt.Length);
|
||||
IntPtr retPtr = Marshal.AllocHGlobal(32);
|
||||
Marshal.Copy(pbMsg, 0, msgPtr, pbMsg.Length);
|
||||
Marshal.Copy(pbSalt, 0, saltPtr, pbSalt.Length);
|
||||
|
||||
const UInt32 Argon2_d = 0;
|
||||
|
||||
int ret = argon2_hash(
|
||||
(UInt32)uIt, (UInt32)(uMem / 1024), uPar,
|
||||
msgPtr, (IntPtr)pbMsg.Length,
|
||||
saltPtr, (IntPtr)pbSalt.Length,
|
||||
retPtr, (IntPtr)32,
|
||||
(IntPtr)0, (IntPtr)0, Argon2_d, v);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
throw new Exception("argon2_hash failed with " + ret);
|
||||
}
|
||||
|
||||
pbRet = new byte[32];
|
||||
Marshal.Copy(retPtr, pbRet, 0, 32);
|
||||
|
||||
Marshal.FreeHGlobal(msgPtr);
|
||||
Marshal.FreeHGlobal(saltPtr);
|
||||
Marshal.FreeHGlobal(retPtr);
|
||||
}
|
||||
|
||||
if (pbAssocData != null) {
|
||||
throw new ArgumentOutOfRangeException("Unsupported configuration: non-null pbAssocData");
|
||||
}
|
||||
|
||||
/*
|
||||
byte[] pbRet = Argon2d(pbMsg, pbSalt, uPar, uMem, uIt,
|
||||
32, v, pbSecretKey, pbAssocData);
|
||||
*/
|
||||
|
||||
IntPtr msgPtr = Marshal.AllocHGlobal(pbMsg.Length);
|
||||
IntPtr saltPtr = Marshal.AllocHGlobal(pbSalt.Length);
|
||||
IntPtr retPtr = Marshal.AllocHGlobal(32);
|
||||
Marshal.Copy(pbMsg, 0, msgPtr, pbMsg.Length);
|
||||
Marshal.Copy(pbSalt, 0, saltPtr, pbSalt.Length);
|
||||
|
||||
const UInt32 Argon2_d = 0;
|
||||
|
||||
int ret = argon2_hash(
|
||||
(UInt32)uIt, (UInt32)(uMem / 1024), uPar,
|
||||
msgPtr, (IntPtr)pbMsg.Length,
|
||||
saltPtr, (IntPtr)pbSalt.Length,
|
||||
retPtr, (IntPtr)32,
|
||||
(IntPtr)0, (IntPtr)0, Argon2_d, v);
|
||||
|
||||
if (ret != 0) {
|
||||
throw new Exception("argon2_hash failed with " + ret);
|
||||
}
|
||||
|
||||
byte[] pbRet = new byte[32];
|
||||
Marshal.Copy(retPtr, pbRet, 0, 32);
|
||||
|
||||
Marshal.FreeHGlobal(msgPtr);
|
||||
Marshal.FreeHGlobal(saltPtr);
|
||||
Marshal.FreeHGlobal(retPtr);
|
||||
|
||||
if(uMem > (100UL * 1024UL * 1024UL)) GC.Collect();
|
||||
if(uMem > (100UL * 1024UL * 1024UL)) GC.Collect();
|
||||
return pbRet;
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
KeePass Password Safe - The Open-Source Password Manager
|
||||
Copyright (C) 2003-2017 Dominik Reichl <dominik.reichl@t-online.de>
|
||||
Copyright (C) 2003-2020 Dominik Reichl <dominik.reichl@t-online.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
KeePass Password Safe - The Open-Source Password Manager
|
||||
Copyright (C) 2003-2017 Dominik Reichl <dominik.reichl@t-online.de>
|
||||
Copyright (C) 2003-2020 Dominik Reichl <dominik.reichl@t-online.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -41,10 +41,11 @@ namespace KeePassLib.Cryptography.KeyDerivation
|
||||
|
||||
private static void EnsureInitialized()
|
||||
{
|
||||
if(g_l.Count > 0) return;
|
||||
if(g_l.Count != 0) return;
|
||||
|
||||
g_l.Add(new AesKdf());
|
||||
g_l.Add(new Argon2Kdf());
|
||||
g_l.Add(new Argon2Kdf(Argon2Type.D));
|
||||
g_l.Add(new Argon2Kdf(Argon2Type.ID));
|
||||
}
|
||||
|
||||
internal static KdfParameters GetDefaultParameters()
|
||||
|
@@ -50,6 +50,7 @@
|
||||
<HintPath>..\ProtoBuf\protobuf-net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Mono.Android" />
|
||||
@@ -71,6 +72,7 @@
|
||||
<Compile Include="Cryptography\KeyDerivation\KdfParameters.cs" />
|
||||
<Compile Include="Cryptography\KeyDerivation\KdfPool.cs" />
|
||||
<Compile Include="IDatabaseFormat.cs" />
|
||||
<Compile Include="Keys\KcpKeyFile.Xml.cs" />
|
||||
<Compile Include="Kp2aLog.cs" />
|
||||
<Compile Include="Resources\Resource.designer.cs" />
|
||||
<Compile Include="Resources\KLRes.Generated.cs" />
|
||||
@@ -160,6 +162,7 @@
|
||||
<Compile Include="Utility\UrlUtil.cs" />
|
||||
<Compile Include="Utility\TimeUtil.cs" />
|
||||
<Compile Include="Delegates\Handlers.cs" />
|
||||
<Compile Include="Utility\XmlUtilEx.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
281
src/KeePassLib2Android/Keys/KcpKeyFile.Xml.cs
Normal file
281
src/KeePassLib2Android/Keys/KcpKeyFile.Xml.cs
Normal file
@@ -0,0 +1,281 @@
|
||||
/*
|
||||
KeePass Password Safe - The Open-Source Password Manager
|
||||
Copyright (C) 2003-2021 Dominik Reichl <dominik.reichl@t-online.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
using KeePassLib.Cryptography;
|
||||
using KeePassLib.Resources;
|
||||
using KeePassLib.Serialization;
|
||||
using KeePassLib.Utility;
|
||||
|
||||
namespace KeePassLib.Keys
|
||||
{
|
||||
[XmlType("KeyFile")]
|
||||
public sealed class KfxFile
|
||||
{
|
||||
private const ulong KfxVersionCriticalMask = 0xFFFF000000000000UL;
|
||||
private const int KfxDataHashLength = 4;
|
||||
|
||||
private KfxMeta m_meta = new KfxMeta();
|
||||
public KfxMeta Meta
|
||||
{
|
||||
get { return m_meta; }
|
||||
set
|
||||
{
|
||||
if(value == null) throw new ArgumentNullException("value");
|
||||
m_meta = value;
|
||||
}
|
||||
}
|
||||
|
||||
private KfxKey m_key = new KfxKey();
|
||||
public KfxKey Key
|
||||
{
|
||||
get { return m_key; }
|
||||
set
|
||||
{
|
||||
if(value == null) throw new ArgumentNullException("value");
|
||||
m_key = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static KfxFile Create(ulong uVersion, byte[] pbKey, byte[] pbHash)
|
||||
{
|
||||
if(pbKey == null) throw new ArgumentNullException("pbKey");
|
||||
if(pbKey.Length == 0) throw new ArgumentOutOfRangeException("pbKey");
|
||||
|
||||
if(uVersion == 0) uVersion = 0x0002000000000000;
|
||||
|
||||
// Null hash: generate one, empty hash: store no hash
|
||||
if(pbHash == null) pbHash = HashData(pbKey);
|
||||
VerifyHash(pbKey, pbHash);
|
||||
|
||||
KfxFile kf = new KfxFile();
|
||||
|
||||
if(uVersion == 0x0001000000000000)
|
||||
kf.Meta.Version = "1.00"; // KeePass <= 2.46 used two zeros
|
||||
else kf.Meta.Version = StrUtil.VersionToString(uVersion, 2);
|
||||
|
||||
if(uVersion == 0x0001000000000000)
|
||||
kf.Key.Data.Value = Convert.ToBase64String(pbKey);
|
||||
else if(uVersion == 0x0002000000000000)
|
||||
{
|
||||
kf.Key.Data.Value = FormatKeyHex(pbKey, 3);
|
||||
|
||||
if(pbHash.Length != 0)
|
||||
kf.Key.Data.Hash = MemUtil.ByteArrayToHexString(pbHash);
|
||||
}
|
||||
else throw new NotSupportedException(KLRes.FileVersionUnsupported);
|
||||
|
||||
return kf;
|
||||
}
|
||||
|
||||
internal static KfxFile Create(ulong uVersion, string strKey, string strHash)
|
||||
{
|
||||
byte[] pbKey = ParseKey(uVersion, strKey);
|
||||
byte[] pbHash = ((strHash != null) ? ParseHash(strHash) : null);
|
||||
|
||||
return Create(uVersion, pbKey, pbHash);
|
||||
}
|
||||
|
||||
internal static bool CanLoad(string strFilePath)
|
||||
{
|
||||
if(string.IsNullOrEmpty(strFilePath)) { Debug.Assert(false); return false; }
|
||||
|
||||
try
|
||||
{
|
||||
IOConnectionInfo ioc = IOConnectionInfo.FromPath(strFilePath);
|
||||
using(Stream s = IOConnection.OpenRead(ioc))
|
||||
{
|
||||
return (Load(s) != null);
|
||||
}
|
||||
}
|
||||
catch(Exception) { }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static KfxFile Load(Stream s)
|
||||
{
|
||||
return XmlUtilEx.Deserialize<KfxFile>(s);
|
||||
}
|
||||
|
||||
public void Save(Stream s)
|
||||
{
|
||||
XmlUtilEx.Serialize<KfxFile>(s, this, true);
|
||||
}
|
||||
|
||||
private static string FormatKeyHex(byte[] pb, int cTabs)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
string str = MemUtil.ByteArrayToHexString(pb);
|
||||
|
||||
for(int i = 0; i < str.Length; ++i)
|
||||
{
|
||||
if((i & 0x1F) == 0)
|
||||
{
|
||||
sb.AppendLine();
|
||||
sb.Append('\t', cTabs);
|
||||
}
|
||||
else if((i & 0x07) == 0) sb.Append(' ');
|
||||
|
||||
sb.Append(str[i]);
|
||||
}
|
||||
|
||||
sb.AppendLine();
|
||||
if(cTabs > 0) sb.Append('\t', cTabs - 1);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private ulong GetVersion()
|
||||
{
|
||||
string str = m_meta.Version;
|
||||
if(string.IsNullOrEmpty(str)) return 0;
|
||||
|
||||
return StrUtil.ParseVersion(str);
|
||||
}
|
||||
|
||||
public byte[] GetKey()
|
||||
{
|
||||
ulong uVersion = GetVersion();
|
||||
|
||||
byte[] pbKey = ParseKey(uVersion, m_key.Data.Value);
|
||||
if((pbKey == null) || (pbKey.Length == 0))
|
||||
throw new FormatException(KLRes.FileCorrupted);
|
||||
|
||||
byte[] pbHash = ParseHash(m_key.Data.Hash);
|
||||
VerifyHash(pbKey, pbHash);
|
||||
|
||||
return pbKey;
|
||||
}
|
||||
|
||||
private static byte[] HashData(byte[] pb)
|
||||
{
|
||||
return MemUtil.Mid(CryptoUtil.HashSha256(pb), 0, KfxDataHashLength);
|
||||
}
|
||||
|
||||
private static void VerifyHash(byte[] pbKey, byte[] pbHash)
|
||||
{
|
||||
// The hash is optional; empty hash means success
|
||||
if((pbHash == null) || (pbHash.Length == 0)) return;
|
||||
|
||||
byte[] pbHashCmp = HashData(pbKey);
|
||||
if(!MemUtil.ArraysEqual(pbHash, pbHashCmp))
|
||||
throw new Exception("Keyfile hash mismatch!");
|
||||
}
|
||||
|
||||
private static byte[] ParseKey(ulong uVersion, string strKey)
|
||||
{
|
||||
if(strKey == null) throw new ArgumentNullException("strKey");
|
||||
|
||||
strKey = StrUtil.RemoveWhiteSpace(strKey);
|
||||
if(string.IsNullOrEmpty(strKey)) return MemUtil.EmptyByteArray;
|
||||
|
||||
uVersion &= KfxVersionCriticalMask;
|
||||
|
||||
byte[] pbKey;
|
||||
if(uVersion == 0x0001000000000000)
|
||||
pbKey = Convert.FromBase64String(strKey);
|
||||
else if(uVersion == 0x0002000000000000)
|
||||
pbKey = ParseHex(strKey);
|
||||
else throw new NotSupportedException(KLRes.FileVersionUnsupported);
|
||||
|
||||
return pbKey;
|
||||
}
|
||||
|
||||
private static byte[] ParseHash(string strHash)
|
||||
{
|
||||
return ParseHex(strHash);
|
||||
}
|
||||
|
||||
private static byte[] ParseHex(string str)
|
||||
{
|
||||
if(str == null) throw new ArgumentNullException("str");
|
||||
if(str.Length == 0) return MemUtil.EmptyByteArray;
|
||||
|
||||
if(((str.Length & 1) != 0) || !StrUtil.IsHexString(str, true))
|
||||
throw new FormatException();
|
||||
|
||||
return MemUtil.HexStringToByteArray(str);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class KfxMeta
|
||||
{
|
||||
private string m_strVersion = string.Empty;
|
||||
[DefaultValue("")]
|
||||
public string Version
|
||||
{
|
||||
get { return m_strVersion; }
|
||||
set
|
||||
{
|
||||
if(value == null) throw new ArgumentNullException("value");
|
||||
m_strVersion = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class KfxKey
|
||||
{
|
||||
private KfxData m_data = new KfxData();
|
||||
public KfxData Data
|
||||
{
|
||||
get { return m_data; }
|
||||
set
|
||||
{
|
||||
if(value == null) throw new ArgumentNullException("value");
|
||||
m_data = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class KfxData
|
||||
{
|
||||
private string m_strHash = string.Empty;
|
||||
[DefaultValue("")]
|
||||
[XmlAttribute("Hash")]
|
||||
public string Hash
|
||||
{
|
||||
get { return m_strHash; }
|
||||
set
|
||||
{
|
||||
if(value == null) throw new ArgumentNullException("value");
|
||||
m_strHash = value;
|
||||
}
|
||||
}
|
||||
|
||||
private string m_strValue = string.Empty;
|
||||
[DefaultValue("")]
|
||||
[XmlText]
|
||||
public string Value
|
||||
{
|
||||
get { return m_strValue; }
|
||||
set
|
||||
{
|
||||
if(value == null) throw new ArgumentNullException("value");
|
||||
m_strValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -127,10 +127,9 @@ namespace KeePassLib.Keys
|
||||
#endif
|
||||
}
|
||||
|
||||
byte[] pbKey = LoadXmlKeyFile(pbFileData);
|
||||
if(pbKey == null) pbKey = LoadKeyFile(pbFileData);
|
||||
byte[] pbKey = LoadKeyFile(pbFileData);
|
||||
|
||||
if(pbKey == null) throw new InvalidOperationException();
|
||||
if (pbKey == null) throw new InvalidOperationException();
|
||||
|
||||
m_ioc = iocKeyFile;
|
||||
m_pbKeyData = new ProtectedBinary(true, pbKey);
|
||||
@@ -150,54 +149,60 @@ namespace KeePassLib.Keys
|
||||
// }
|
||||
|
||||
|
||||
private static byte[] LoadKeyFile(byte[] pbFileData)
|
||||
{
|
||||
if(pbFileData == null) { Debug.Assert(false); return null; }
|
||||
private static byte[] LoadKeyFile(byte[] pbFileData)
|
||||
{
|
||||
if (pbFileData == null) throw new ArgumentNullException("pbFileData");
|
||||
|
||||
int iLength = pbFileData.Length;
|
||||
byte[] pbKey = LoadKeyFileXml(pbFileData);
|
||||
if (pbKey != null) return pbKey;
|
||||
|
||||
byte[] pbKey = null;
|
||||
if(iLength == 32) pbKey = LoadBinaryKey32(pbFileData);
|
||||
else if(iLength == 64) pbKey = LoadHexKey32(pbFileData);
|
||||
int cb = pbFileData.Length;
|
||||
if (cb == 32) return pbFileData;
|
||||
|
||||
if(pbKey == null)
|
||||
pbKey = CryptoUtil.HashSha256(pbFileData);
|
||||
if (cb == 64)
|
||||
{
|
||||
pbKey = LoadKeyFileHex(pbFileData);
|
||||
if (pbKey != null) return pbKey;
|
||||
}
|
||||
|
||||
return pbKey;
|
||||
}
|
||||
return CryptoUtil.HashSha256(pbFileData);
|
||||
}
|
||||
|
||||
private static byte[] LoadBinaryKey32(byte[] pbFileData)
|
||||
{
|
||||
if(pbFileData == null) { Debug.Assert(false); return null; }
|
||||
if(pbFileData.Length != 32) { Debug.Assert(false); return null; }
|
||||
private static byte[] LoadKeyFileXml(byte[] pbFileData)
|
||||
{
|
||||
KfxFile kf;
|
||||
try
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream(pbFileData, false))
|
||||
{
|
||||
kf = KfxFile.Load(ms);
|
||||
}
|
||||
}
|
||||
catch (Exception) { return null; }
|
||||
|
||||
return pbFileData;
|
||||
}
|
||||
// We have a syntactically valid XML key file;
|
||||
// failing to verify the key should throw an exception
|
||||
return ((kf != null) ? kf.GetKey() : null);
|
||||
}
|
||||
|
||||
private static byte[] LoadHexKey32(byte[] pbFileData)
|
||||
{
|
||||
if(pbFileData == null) { Debug.Assert(false); return null; }
|
||||
if(pbFileData.Length != 64) { Debug.Assert(false); return null; }
|
||||
private static byte[] LoadKeyFileHex(byte[] pbFileData)
|
||||
{
|
||||
if (pbFileData == null) { Debug.Assert(false); return null; }
|
||||
|
||||
try
|
||||
{
|
||||
if(!StrUtil.IsHexString(pbFileData, true)) return null;
|
||||
try
|
||||
{
|
||||
int cc = pbFileData.Length;
|
||||
if ((cc & 1) != 0) { Debug.Assert(false); return null; }
|
||||
|
||||
string strHex = StrUtil.Utf8.GetString(pbFileData);
|
||||
byte[] pbKey = MemUtil.HexStringToByteArray(strHex);
|
||||
if((pbKey == null) || (pbKey.Length != 32))
|
||||
{
|
||||
Debug.Assert(false);
|
||||
return null;
|
||||
}
|
||||
if (!StrUtil.IsHexString(pbFileData, true)) return null;
|
||||
|
||||
return pbKey;
|
||||
}
|
||||
catch(Exception) { Debug.Assert(false); }
|
||||
|
||||
return null;
|
||||
}
|
||||
string strHex = StrUtil.Utf8.GetString(pbFileData);
|
||||
return MemUtil.HexStringToByteArray(strHex);
|
||||
}
|
||||
catch (Exception) { Debug.Assert(false); }
|
||||
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Create a new, random key-file.
|
||||
/// </summary>
|
||||
|
@@ -118,5 +118,10 @@ namespace keepass2android
|
||||
sendIntent.SetType("text/plain");
|
||||
ctx.StartActivity(Intent.CreateChooser(sendIntent, "Send log to..."));
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogTask(object task, string activityName)
|
||||
{
|
||||
Log($"Task in activity {activityName} changed to {task?.GetType()?.Name ?? "null"}");
|
||||
}
|
||||
}
|
||||
}
|
@@ -37,7 +37,7 @@ namespace KeePassLib.Utility
|
||||
/// </summary>
|
||||
public static class MemUtil
|
||||
{
|
||||
internal static readonly byte[] EmptyByteArray = new byte[0];
|
||||
public static readonly byte[] EmptyByteArray = new byte[0];
|
||||
|
||||
private static readonly uint[] m_vSBox = new uint[256] {
|
||||
0xCD2FACB3, 0xE78A7F5C, 0x6F0803FC, 0xBCF6E230,
|
||||
|
@@ -1734,5 +1734,24 @@ namespace KeePassLib.Utility
|
||||
// behavior of Notepad (on Windows 10)
|
||||
return str.Replace('\0', ' ');
|
||||
}
|
||||
|
||||
internal static string RemoveWhiteSpace(string str)
|
||||
{
|
||||
if (str == null) { Debug.Assert(false); return string.Empty; }
|
||||
|
||||
int cc = str.Length;
|
||||
if (cc == 0) return string.Empty;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < cc; ++i)
|
||||
{
|
||||
char ch = str[i];
|
||||
if (char.IsWhiteSpace(ch)) continue;
|
||||
sb.Append(ch);
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
290
src/KeePassLib2Android/Utility/XmlUtilEx.cs
Normal file
290
src/KeePassLib2Android/Utility/XmlUtilEx.cs
Normal file
@@ -0,0 +1,290 @@
|
||||
/*
|
||||
KeePass Password Safe - The Open-Source Password Manager
|
||||
Copyright (C) 2003-2021 Dominik Reichl <dominik.reichl@t-online.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml.XPath;
|
||||
|
||||
using KeePassLib.Delegates;
|
||||
using KeePassLib.Interfaces;
|
||||
using KeePassLib.Serialization;
|
||||
|
||||
namespace KeePassLib.Utility
|
||||
{
|
||||
public static class XmlUtilEx
|
||||
{
|
||||
public static XmlDocument CreateXmlDocument()
|
||||
{
|
||||
XmlDocument d = new XmlDocument();
|
||||
|
||||
// .NET 4.5.2 and newer do not resolve external XML resources
|
||||
// by default; for older .NET versions, we explicitly
|
||||
// prevent resolving
|
||||
d.XmlResolver = null; // Default in old .NET: XmlUrlResolver object
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
public static XmlReaderSettings CreateXmlReaderSettings()
|
||||
{
|
||||
XmlReaderSettings xrs = new XmlReaderSettings();
|
||||
|
||||
xrs.CloseInput = false;
|
||||
xrs.IgnoreComments = true;
|
||||
xrs.IgnoreProcessingInstructions = true;
|
||||
xrs.IgnoreWhitespace = true;
|
||||
|
||||
#if KeePassUAP
|
||||
xrs.DtdProcessing = DtdProcessing.Prohibit;
|
||||
#else
|
||||
// Also see PrepMonoDev.sh script
|
||||
xrs.ProhibitDtd = true; // Obsolete in .NET 4, but still there
|
||||
// xrs.DtdProcessing = DtdProcessing.Prohibit; // .NET 4 only
|
||||
#endif
|
||||
|
||||
xrs.ValidationType = ValidationType.None;
|
||||
xrs.XmlResolver = null;
|
||||
|
||||
return xrs;
|
||||
}
|
||||
|
||||
public static XmlReader CreateXmlReader(Stream s)
|
||||
{
|
||||
if(s == null) { Debug.Assert(false); throw new ArgumentNullException("s"); }
|
||||
|
||||
return XmlReader.Create(s, CreateXmlReaderSettings());
|
||||
}
|
||||
|
||||
public static XmlWriterSettings CreateXmlWriterSettings()
|
||||
{
|
||||
XmlWriterSettings xws = new XmlWriterSettings();
|
||||
|
||||
xws.CloseOutput = false;
|
||||
xws.Encoding = StrUtil.Utf8;
|
||||
xws.Indent = true;
|
||||
xws.IndentChars = "\t";
|
||||
xws.NewLineOnAttributes = false;
|
||||
|
||||
return xws;
|
||||
}
|
||||
|
||||
public static XmlWriter CreateXmlWriter(Stream s)
|
||||
{
|
||||
if(s == null) { Debug.Assert(false); throw new ArgumentNullException("s"); }
|
||||
|
||||
return XmlWriter.Create(s, CreateXmlWriterSettings());
|
||||
}
|
||||
|
||||
public static T Deserialize<T>(Stream s)
|
||||
{
|
||||
if(s == null) { Debug.Assert(false); throw new ArgumentNullException("s"); }
|
||||
|
||||
XmlSerializer xs = new XmlSerializer(typeof(T));
|
||||
|
||||
T t = default(T);
|
||||
using(XmlReader xr = CreateXmlReader(s))
|
||||
{
|
||||
t = (T)xs.Deserialize(xr);
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
public static void Serialize<T>(Stream s, T t)
|
||||
{
|
||||
if(s == null) { Debug.Assert(false); throw new ArgumentNullException("s"); }
|
||||
|
||||
XmlSerializer xs = new XmlSerializer(typeof(T));
|
||||
using(XmlWriter xw = CreateXmlWriter(s))
|
||||
{
|
||||
xs.Serialize(xw, t);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void Serialize<T>(Stream s, T t, bool bRemoveXsdXsi)
|
||||
{
|
||||
// One way to remove the "xsd" and "xsi" namespace declarations
|
||||
// is to use an XmlSerializerNamespaces object containing only
|
||||
// a ""/"" pair; this seems to work, but Microsoft's
|
||||
// documentation explicitly states that it isn't supported:
|
||||
// https://docs.microsoft.com/en-us/dotnet/api/system.xml.serialization.xmlserializernamespaces
|
||||
// There are other, more complex ways, but these either rely on
|
||||
// undocumented details or require the type T to be modified.
|
||||
|
||||
string str;
|
||||
using(MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
Serialize<T>(ms, t);
|
||||
|
||||
str = StrUtil.Utf8.GetString(ms.ToArray());
|
||||
}
|
||||
|
||||
Func<string, string, bool> fFindPfx = delegate(string strText, string strSub)
|
||||
{
|
||||
int i = strText.IndexOf(strSub, StringComparison.Ordinal);
|
||||
if(i < 0) return false;
|
||||
if(i == 0) return true;
|
||||
return char.IsWhiteSpace(strText[i - 1]);
|
||||
};
|
||||
|
||||
if(bRemoveXsdXsi)
|
||||
{
|
||||
if(!fFindPfx(str, "xsd:") && !fFindPfx(str, "xsi:"))
|
||||
{
|
||||
Debug.Assert(str.IndexOf("xmlns:xsd") > 0);
|
||||
str = str.Replace(" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"", string.Empty);
|
||||
Debug.Assert(str.IndexOf("xmlns:xsd") < 0);
|
||||
|
||||
Debug.Assert(str.IndexOf("xmlns:xsi") > 0);
|
||||
str = str.Replace(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"", string.Empty);
|
||||
Debug.Assert(str.IndexOf("xmlns:xsi") < 0);
|
||||
}
|
||||
else { Debug.Assert(false); } // "xsd"/"xsi" decl. may be required
|
||||
}
|
||||
|
||||
MemUtil.Write(s, StrUtil.Utf8.GetBytes(str));
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
internal static void ValidateXml(string strXml, bool bReplaceStdEntities)
|
||||
{
|
||||
if(strXml == null) throw new ArgumentNullException("strXml");
|
||||
if(strXml.Length == 0) { Debug.Assert(false); return; }
|
||||
|
||||
string str = strXml;
|
||||
|
||||
if(bReplaceStdEntities)
|
||||
str = str.Replace(" ", " ");
|
||||
|
||||
XmlDocument d = new XmlDocument();
|
||||
d.LoadXml(str);
|
||||
}
|
||||
#endif
|
||||
|
||||
internal static XPathNodeIterator FindNodes(PwDatabase pd, string strXPath,
|
||||
IStatusLogger sl, out XmlDocument xd)
|
||||
{
|
||||
if(pd == null) throw new ArgumentNullException("pd");
|
||||
if(strXPath == null) { Debug.Assert(false); strXPath = string.Empty; }
|
||||
|
||||
KdbxFile kdbx = new KdbxFile(pd);
|
||||
|
||||
byte[] pbXml;
|
||||
using(MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
kdbx.Save(ms, null, KdbxFormat.PlainXml, sl);
|
||||
pbXml = ms.ToArray();
|
||||
}
|
||||
string strXml = StrUtil.Utf8.GetString(pbXml);
|
||||
|
||||
xd = CreateXmlDocument();
|
||||
xd.LoadXml(strXml);
|
||||
|
||||
XPathNavigator xpNav = xd.CreateNavigator();
|
||||
return xpNav.Select(strXPath);
|
||||
// XPathExpression xpExpr = xpNav.Compile(strXPath);
|
||||
// xpExpr.SetContext(new XuXsltContext());
|
||||
// return xpNav.Select(xpExpr);
|
||||
}
|
||||
|
||||
/* private sealed class XuFnMatches : IXsltContextFunction
|
||||
{
|
||||
private readonly XPathResultType[] m_vArgTypes = new XPathResultType[] {
|
||||
XPathResultType.String, XPathResultType.String, XPathResultType.String
|
||||
};
|
||||
public XPathResultType[] ArgTypes { get { return m_vArgTypes; } }
|
||||
|
||||
public int Maxargs { get { return 3; } }
|
||||
public int Minargs { get { return 2; } }
|
||||
|
||||
public XPathResultType ReturnType { get { return XPathResultType.Boolean; } }
|
||||
|
||||
private static string GetArgString(object[] args, int i, string strDefault)
|
||||
{
|
||||
if(args == null) { Debug.Assert(false); return strDefault; }
|
||||
if(i >= args.Length) return strDefault;
|
||||
|
||||
object o = args[i];
|
||||
if(o == null) return strDefault;
|
||||
|
||||
XPathNodeIterator it = (o as XPathNodeIterator);
|
||||
if(it != null) o = it.Current.Value;
|
||||
|
||||
return (o.ToString() ?? strDefault);
|
||||
}
|
||||
|
||||
public object Invoke(XsltContext xsltContext, object[] args,
|
||||
XPathNavigator docContext)
|
||||
{
|
||||
string strInput = GetArgString(args, 0, string.Empty);
|
||||
string strPattern = GetArgString(args, 1, string.Empty);
|
||||
string strFlags = GetArgString(args, 2, null);
|
||||
|
||||
RegexOptions ro = RegexOptions.None;
|
||||
if(!string.IsNullOrEmpty(strFlags))
|
||||
{
|
||||
if(strFlags.IndexOf('s') >= 0) ro |= RegexOptions.Singleline;
|
||||
if(strFlags.IndexOf('m') >= 0) ro |= RegexOptions.Multiline;
|
||||
if(strFlags.IndexOf('i') >= 0) ro |= RegexOptions.IgnoreCase;
|
||||
if(strFlags.IndexOf('x') >= 0) ro |= RegexOptions.IgnorePatternWhitespace;
|
||||
}
|
||||
|
||||
return Regex.IsMatch(strInput, strPattern, ro);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class XuXsltContext : XsltContext
|
||||
{
|
||||
public override bool Whitespace { get { return false; } }
|
||||
|
||||
public override int CompareDocument(string baseUri, string nextbaseUri)
|
||||
{
|
||||
return string.CompareOrdinal(baseUri, nextbaseUri);
|
||||
}
|
||||
|
||||
public override bool PreserveWhitespace(XPathNavigator node)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override IXsltContextFunction ResolveFunction(string prefix,
|
||||
string name, XPathResultType[] ArgTypes)
|
||||
{
|
||||
if(prefix != "kp") { Debug.Assert(false); return null; }
|
||||
|
||||
if(name == "matches") return new XuFnMatches();
|
||||
|
||||
Debug.Assert(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
public override IXsltContextVariable ResolveVariable(string prefix,
|
||||
string name)
|
||||
{
|
||||
Debug.Assert(false);
|
||||
return null;
|
||||
}
|
||||
} */
|
||||
}
|
||||
}
|
@@ -120,10 +120,14 @@ namespace keepass2android.Io
|
||||
|
||||
public bool IsCached(IOConnectionInfo ioc)
|
||||
{
|
||||
return File.Exists(CachedFilePath(ioc))
|
||||
bool result = File.Exists(CachedFilePath(ioc))
|
||||
&& File.Exists(VersionFilePath(ioc))
|
||||
&& File.Exists(BaseVersionFilePath(ioc));
|
||||
}
|
||||
|
||||
Kp2aLog.Log(ioc.GetDisplayName() + " isCached = " + result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Delete(IOConnectionInfo ioc)
|
||||
{
|
||||
@@ -593,11 +597,15 @@ namespace keepass2android.Io
|
||||
|
||||
public string GetBaseVersionHash(IOConnectionInfo ioc)
|
||||
{
|
||||
return File.ReadAllText(BaseVersionFilePath(ioc));
|
||||
}
|
||||
string hash = File.ReadAllText(BaseVersionFilePath(ioc));
|
||||
Kp2aLog.Log(ioc.GetDisplayName() + " baseVersionHash = " + hash);
|
||||
return hash;
|
||||
}
|
||||
public string GetLocalVersionHash(IOConnectionInfo ioc)
|
||||
{
|
||||
return File.ReadAllText(VersionFilePath(ioc));
|
||||
string hash = File.ReadAllText(VersionFilePath(ioc));
|
||||
Kp2aLog.Log(ioc.GetDisplayName() + " localVersionHash = " + hash);
|
||||
return hash;
|
||||
}
|
||||
public bool HasLocalChanges(IOConnectionInfo ioc)
|
||||
{
|
||||
|
@@ -31,7 +31,7 @@
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NoNet;EXCLUDE_JAVAFILESTORAGE</DefineConstants>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<JavaMaximumHeapSize>4G</JavaMaximumHeapSize>
|
||||
@@ -54,6 +54,7 @@
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
@@ -77,13 +78,23 @@
|
||||
<Compile Include="Io\AndroidContentStorage.cs" />
|
||||
<Compile Include="Io\BuiltInFileStorage.cs" />
|
||||
<Compile Include="Io\CachingFileStorage.cs" />
|
||||
<Compile Include="Io\DropboxFileStorage.cs" />
|
||||
<Compile Include="Io\DropboxFileStorageKeys.cs" />
|
||||
<Compile Include="Io\FileDescription.cs" />
|
||||
<Compile Include="Io\FileStorageSetupActivity.cs" />
|
||||
<Compile Include="Io\FileStorageSetupInitiatorActivity.cs" />
|
||||
<Compile Include="Io\GDriveFileStorage.cs" />
|
||||
<Compile Include="Io\IFileStorage.cs" />
|
||||
<Compile Include="Io\IoUtil.cs" />
|
||||
<Compile Include="Io\JavaFileStorage.cs" />
|
||||
<Compile Include="Io\NetFtpFileStorage.cs" />
|
||||
<Compile Include="Io\OfflineSwitchableFileStorage.cs" />
|
||||
|
||||
<Compile Include="Io\OneDrive2FileStorage.cs" />
|
||||
<Compile Include="Io\OneDrive2PrefixContainer.cs" />
|
||||
<Compile Include="Io\PCloudFileStorage.cs" />
|
||||
<Compile Include="Io\SftpFileStorage.cs" />
|
||||
<Compile Include="Io\OneDriveFileStorage.cs" />
|
||||
<Compile Include="Io\WebDavFileStorage.cs" />
|
||||
<Compile Include="IProgressDialog.cs" />
|
||||
<Compile Include="PreferenceKey.cs" />
|
||||
<Compile Include="SelectStorageLocationActivityBase.cs" />
|
||||
@@ -119,6 +130,14 @@
|
||||
<Compile Include="Utils\Spr\SprEngine.PickChars.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AndroidFileChooserBinding\AndroidFileChooserBinding.csproj">
|
||||
<Project>{3c0f7fe5-639f-4422-a087-8b26cf862d1b}</Project>
|
||||
<Name>AndroidFileChooserBinding</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\JavaFileStorageBindings\JavaFileStorageBindings.csproj">
|
||||
<Project>{48574278-4779-4b3a-a9e4-9cf1bc285d0b}</Project>
|
||||
<Name>JavaFileStorageBindings</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\KeePassLib2Android\KeePassLib2Android.csproj">
|
||||
<Project>{545B4A6B-8BBA-4FBE-92FC-4AC060122A54}</Project>
|
||||
<Name>KeePassLib2Android</Name>
|
||||
@@ -127,7 +146,10 @@
|
||||
<Project>{70D3844A-D9FA-4A64-B205-A84C6A822196}</Project>
|
||||
<Name>KP2AKdbLibraryBinding</Name>
|
||||
</ProjectReference>
|
||||
|
||||
<ProjectReference Include="..\PCloudBindings\PCloudBindings.csproj">
|
||||
<Project>{2db80c77-d46f-4970-b967-e9ffa9b2ac2e}</Project>
|
||||
<Name>PCloudBindings</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\TwofishCipher\TwofishCipher.csproj">
|
||||
<Project>{5CF675A5-9BEE-4720-BED9-D5BF14A2EBF9}</Project>
|
||||
<Name>TwofishCipher</Name>
|
||||
@@ -140,8 +162,20 @@
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentFTP">
|
||||
<Version>31.3.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Graph">
|
||||
<Version>1.21.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Graph.Auth">
|
||||
<Version>1.0.0-preview.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Identity.Client">
|
||||
<Version>4.8.2</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Xamarin.Android.Arch.Core.Common">
|
||||
<Version>1.1.1.1</Version>
|
||||
<Version>1.1.1.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Xamarin.Android.Arch.Core.Runtime">
|
||||
<Version>1.1.1.3</Version>
|
||||
|
4380
src/Kp2aBusinessLogic/Resources/Resource.Designer.cs
generated
4380
src/Kp2aBusinessLogic/Resources/Resource.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -43,17 +43,21 @@ namespace keepass2android
|
||||
try
|
||||
{
|
||||
remoteData = cachingFileStorage.GetRemoteDataAndHash(ioc, out hash);
|
||||
Kp2aLog.Log("Checking for file change. Current hash = " + hash);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
StatusLogger.UpdateSubMessage(_app.GetResourceString(UiStringKey.RestoringRemoteFile));
|
||||
cachingFileStorage.UpdateRemoteFile(ioc, _app.GetBooleanPreference(PreferenceKey.UseFileTransactions));
|
||||
Finish(true, _app.GetResourceString(UiStringKey.SynchronizedDatabaseSuccessfully));
|
||||
Kp2aLog.Log("Checking for file change: file not found");
|
||||
return;
|
||||
}
|
||||
|
||||
//check if remote file was modified:
|
||||
if (cachingFileStorage.GetBaseVersionHash(ioc) != hash)
|
||||
var baseVersionHash = cachingFileStorage.GetBaseVersionHash(ioc);
|
||||
Kp2aLog.Log("Checking for file change. baseVersionHash = " + baseVersionHash);
|
||||
if (baseVersionHash != hash)
|
||||
{
|
||||
//remote file is modified
|
||||
if (cachingFileStorage.HasLocalChanges(ioc))
|
||||
|
@@ -116,14 +116,18 @@ namespace keepass2android
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (
|
||||
(_streamForOrigFile != null)
|
||||
|| fileStorage.CheckForFileChangeFast(ioc, _db.LastFileVersion) //first try to use the fast change detection
|
||||
|| (FileHashChanged(ioc, _db.KpDatabase.HashOfFileOnDisk) == FileHashChange.Changed) //if that fails, hash the file and compare:
|
||||
)
|
||||
|
||||
bool hasStreamForOrigFile = (_streamForOrigFile != null);
|
||||
bool hasChangeFast = hasStreamForOrigFile ||
|
||||
fileStorage.CheckForFileChangeFast(ioc, _db.LastFileVersion); //first try to use the fast change detection;
|
||||
bool hasHashChanged = hasChangeFast ||
|
||||
(FileHashChanged(ioc, _db.KpDatabase.HashOfFileOnDisk) ==
|
||||
FileHashChange.Changed); //if that fails, hash the file and compare:
|
||||
|
||||
if (hasHashChanged)
|
||||
{
|
||||
Kp2aLog.Log("Conflict. " + hasStreamForOrigFile + " " + hasChangeFast + " " + hasHashChanged);
|
||||
|
||||
//ask user...
|
||||
_app.AskYesNoCancel(UiStringKey.TitleSyncQuestion, UiStringKey.MessageSyncQuestion,
|
||||
|
Binary file not shown.
BIN
src/PCloudBindings/Jars/pcloud-sdk-android-1.2.0.aar
Normal file
BIN
src/PCloudBindings/Jars/pcloud-sdk-android-1.2.0.aar
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/PCloudBindings/Jars/pcloud-sdk-java-core-1.2.0.jar
Normal file
BIN
src/PCloudBindings/Jars/pcloud-sdk-java-core-1.2.0.jar
Normal file
Binary file not shown.
@@ -55,7 +55,7 @@
|
||||
<ItemGroup>
|
||||
<None Include="Jars\AboutJars.txt" />
|
||||
<None Include="Additions\AboutAdditions.txt" />
|
||||
<LibraryProjectZip Include="Jars\pcloud-sdk-android-1.1.0.aar" />
|
||||
<LibraryProjectZip Include="Jars\pcloud-sdk-android-1.2.0.aar" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<TransformFile Include="Transforms\Metadata.xml" />
|
||||
@@ -71,6 +71,6 @@
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<EmbeddedReferenceJar Include="Jars\pcloud-sdk-java-core-1.1.0.jar" />
|
||||
<EmbeddedReferenceJar Include="Jars\pcloud-sdk-java-core-1.2.0.jar" />
|
||||
</ItemGroup>
|
||||
</Project>
|
Submodule src/SamsungPass updated: f3c6bbe224...56538a5be1
@@ -6,11 +6,11 @@ if exist "DropboxFileStorageKeys.cs" (
|
||||
)
|
||||
|
||||
cd ..\..\keepass2android
|
||||
call UseManifestNoNet.bat
|
||||
call UseManifestDebug.bat
|
||||
cd ..
|
||||
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64
|
||||
|
||||
msbuild KeePass.sln /target:keepass2android /p:BuildProjectReferences=true /p:Configuration="Release" /p:Platform="Any CPU"
|
||||
msbuild KeePass.sln /target:keepass2android /p:BuildProjectReferences=true /p:Configuration="Debug" /p:Platform="Any CPU"
|
||||
|
||||
cd build-scripts
|
@@ -40,8 +40,8 @@ dependencies {
|
||||
compile('com.onedrive.sdk:onedrive-sdk-android:1.2.0') {
|
||||
transitive = false
|
||||
}
|
||||
compile 'com.pcloud.sdk:java-core:1.1.0'
|
||||
compile 'com.pcloud.sdk:android:1.1.0'
|
||||
compile 'com.pcloud.sdk:java-core:1.2.0'
|
||||
compile 'com.pcloud.sdk:android:1.2.0'
|
||||
compile 'com.google.code.gson:gson:2.3.1'
|
||||
compile 'com.microsoft.services.msa:msa-auth:0.8.6'
|
||||
compile 'com.microsoft.aad:adal:1.14.0'
|
||||
|
@@ -6,7 +6,6 @@
|
||||
android:versionName="1.0">
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
android:targetSdkVersion="14" />
|
||||
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2006-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2006-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2005-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2005-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2013-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2013-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2015-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2015-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2015-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2015-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2015-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2004-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2004-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2004-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2004-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -93,7 +93,13 @@ class IdentityFile implements Identity{
|
||||
* @return "ssh-rsa" or "ssh-dss"
|
||||
*/
|
||||
public String getAlgName(){
|
||||
return new String(kpair.getKeyTypeName());
|
||||
byte[] name = kpair.getKeyTypeName();
|
||||
try {
|
||||
return new String(name, "UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e){
|
||||
return new String(name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2012-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2012-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -66,9 +66,9 @@ public class JSch{
|
||||
config.put("diffie-hellman-group-exchange-sha256",
|
||||
"com.jcraft.jsch.DHGEX256"); // available since JDK1.4.2.
|
||||
// On JDK8, 2048bits will be used.
|
||||
config.put("ecdsa-sha2-nistp256", "com.jcraft.jsch.jce.SignatureECDSA");
|
||||
config.put("ecdsa-sha2-nistp384", "com.jcraft.jsch.jce.SignatureECDSA");
|
||||
config.put("ecdsa-sha2-nistp521", "com.jcraft.jsch.jce.SignatureECDSA");
|
||||
config.put("ecdsa-sha2-nistp256", "com.jcraft.jsch.jce.SignatureECDSA256");
|
||||
config.put("ecdsa-sha2-nistp384", "com.jcraft.jsch.jce.SignatureECDSA384");
|
||||
config.put("ecdsa-sha2-nistp521", "com.jcraft.jsch.jce.SignatureECDSA521");
|
||||
|
||||
config.put("ecdh-sha2-nistp256", "com.jcraft.jsch.DHEC256");
|
||||
config.put("ecdh-sha2-nistp384", "com.jcraft.jsch.DHEC384");
|
||||
@@ -94,7 +94,6 @@ public class JSch{
|
||||
config.put("md5", "com.jcraft.jsch.jce.MD5");
|
||||
config.put("signature.dss", "com.jcraft.jsch.jce.SignatureDSA");
|
||||
config.put("signature.rsa", "com.jcraft.jsch.jce.SignatureRSA");
|
||||
config.put("signature.ecdsa", "com.jcraft.jsch.jce.SignatureECDSA");
|
||||
config.put("keypairgen.dsa", "com.jcraft.jsch.jce.KeyPairGenDSA");
|
||||
config.put("keypairgen.rsa", "com.jcraft.jsch.jce.KeyPairGenRSA");
|
||||
config.put("keypairgen.ecdsa", "com.jcraft.jsch.jce.KeyPairGenECDSA");
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -301,7 +301,7 @@ public abstract class KeyExchange{
|
||||
|
||||
SignatureECDSA sig=null;
|
||||
try{
|
||||
Class c=Class.forName(session.getConfig("signature.ecdsa"));
|
||||
Class c=Class.forName(session.getConfig(alg));
|
||||
sig=(SignatureECDSA)(c.newInstance());
|
||||
sig.init();
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -599,7 +599,7 @@ public abstract class KeyPair{
|
||||
}
|
||||
else if(_type.equals("ecdsa-sha2-nistp256") ||
|
||||
_type.equals("ecdsa-sha2-nistp384") ||
|
||||
_type.equals("ecdsa-sha2-nistp512")){
|
||||
_type.equals("ecdsa-sha2-nistp521")){
|
||||
kpair=KeyPairECDSA.fromSSHAgent(jsch, buf);
|
||||
}
|
||||
else{
|
||||
@@ -924,7 +924,7 @@ public abstract class KeyPair{
|
||||
KeyPair kpair=null;
|
||||
if(type==DSA){ kpair=new KeyPairDSA(jsch); }
|
||||
else if(type==RSA){ kpair=new KeyPairRSA(jsch); }
|
||||
else if(type==ECDSA){ kpair=new KeyPairECDSA(jsch); }
|
||||
else if(type==ECDSA){ kpair=new KeyPairECDSA(jsch, pubkey); }
|
||||
else if(vendor==VENDOR_PKCS8){ kpair = new KeyPairPKCS8(jsch); }
|
||||
|
||||
if(kpair!=null){
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2015-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -55,6 +55,23 @@ public class KeyPairECDSA extends KeyPair{
|
||||
this(jsch, null, null, null, null);
|
||||
}
|
||||
|
||||
public KeyPairECDSA(JSch jsch , byte[] pubkey){
|
||||
this(jsch, null, null, null, null);
|
||||
|
||||
if(pubkey!=null){
|
||||
byte[] name = new byte[8];
|
||||
System.arraycopy(pubkey, 11, name, 0, 8);
|
||||
if(Util.array_equals(name, Util.str2byte("nistp384"))){
|
||||
key_size=384;
|
||||
this.name=name;
|
||||
}
|
||||
if(Util.array_equals(name, Util.str2byte("nistp521"))){
|
||||
key_size=521;
|
||||
this.name=name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public KeyPairECDSA(JSch jsch,
|
||||
byte[] name,
|
||||
byte[] r_array,
|
||||
@@ -283,8 +300,8 @@ public class KeyPairECDSA extends KeyPair{
|
||||
}
|
||||
|
||||
public byte[] getSignature(byte[] data){
|
||||
try{
|
||||
Class c=Class.forName((String)jsch.getConfig("signature.ecdsa"));
|
||||
try{
|
||||
Class c=Class.forName((String)jsch.getConfig("ecdsa-sha2-"+new String(name)));
|
||||
SignatureECDSA ecdsa=(SignatureECDSA)(c.newInstance());
|
||||
ecdsa.init();
|
||||
ecdsa.setPrvKey(prv_array);
|
||||
@@ -304,8 +321,8 @@ public class KeyPairECDSA extends KeyPair{
|
||||
}
|
||||
|
||||
public Signature getVerifier(){
|
||||
try{
|
||||
Class c=Class.forName((String)jsch.getConfig("signature.ecdsa"));
|
||||
try{
|
||||
Class c=Class.forName((String)jsch.getConfig("ecdsa-sha2-"+new String(name)));
|
||||
final SignatureECDSA ecdsa=(SignatureECDSA)(c.newInstance());
|
||||
ecdsa.init();
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2015-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2013-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2013-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2012-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2012-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2006-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2006-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2013-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2013-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -212,6 +212,20 @@ public class OpenSSHConfig implements ConfigRepository {
|
||||
if(value != null)
|
||||
break;
|
||||
}
|
||||
// TODO: The following change should be applied,
|
||||
// but it is breaking changes.
|
||||
// The consensus is required to enable it.
|
||||
/*
|
||||
if(value!=null &&
|
||||
(key.equals("SERVERALIVEINTERVAL") ||
|
||||
key.equals("CONNECTTIMEOUT"))){
|
||||
try {
|
||||
int timeout = Integer.parseInt(value);
|
||||
value = Integer.toString(timeout*1000);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
*/
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2013-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2013-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2006-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2006-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2006-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2006-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2005-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2005-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
Copyright (c) 2002-2016 ymnk, JCraft,Inc. All rights reserved.
|
||||
Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user