mirror of
https://github.com/moparisthebest/keepass2android
synced 2025-02-17 23:40:23 -05:00
Added custom logger for better tracability of problems
This commit is contained in:
parent
4e8baf2b6a
commit
5f4d467da4
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
@ -55,6 +55,7 @@
|
|||||||
<Reference Include="Mono.Security" />
|
<Reference Include="Mono.Security" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Kp2aLog.cs" />
|
||||||
<Compile Include="Resources\Resource.designer.cs" />
|
<Compile Include="Resources\Resource.designer.cs" />
|
||||||
<Compile Include="Resources\KLRes.Generated.cs" />
|
<Compile Include="Resources\KLRes.Generated.cs" />
|
||||||
<Compile Include="Resources\KSRes.Generated.cs" />
|
<Compile Include="Resources\KSRes.Generated.cs" />
|
||||||
|
@ -28,6 +28,7 @@ using KeePassLib.Native;
|
|||||||
using KeePassLib.Resources;
|
using KeePassLib.Resources;
|
||||||
using KeePassLib.Security;
|
using KeePassLib.Security;
|
||||||
using KeePassLib.Utility;
|
using KeePassLib.Utility;
|
||||||
|
using keepass2android;
|
||||||
|
|
||||||
namespace KeePassLib.Keys
|
namespace KeePassLib.Keys
|
||||||
{
|
{
|
||||||
@ -266,7 +267,7 @@ namespace KeePassLib.Keys
|
|||||||
if (NativeLib.TransformKey256(pbNewKey, pbKeySeed32, uNumRounds))
|
if (NativeLib.TransformKey256(pbNewKey, pbKeySeed32, uNumRounds))
|
||||||
{
|
{
|
||||||
sw.Stop();
|
sw.Stop();
|
||||||
Android.Util.Log.Debug("DEBUG", "Native transform:" +sw.ElapsedMilliseconds+"ms");
|
Kp2aLog.Log("Native transform:" +sw.ElapsedMilliseconds+"ms");
|
||||||
return pbNewKey;
|
return pbNewKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +275,7 @@ namespace KeePassLib.Keys
|
|||||||
if(TransformKeyManaged(pbNewKey, pbKeySeed32, uNumRounds) == false)
|
if(TransformKeyManaged(pbNewKey, pbKeySeed32, uNumRounds) == false)
|
||||||
return null;
|
return null;
|
||||||
sw.Stop();
|
sw.Stop();
|
||||||
Android.Util.Log.Debug("DEBUG", "Managed transform:" +sw.ElapsedMilliseconds+"ms");
|
Kp2aLog.Log("Managed transform:" +sw.ElapsedMilliseconds+"ms");
|
||||||
|
|
||||||
SHA256Managed sha256 = new SHA256Managed();
|
SHA256Managed sha256 = new SHA256Managed();
|
||||||
return sha256.ComputeHash(pbNewKey);
|
return sha256.ComputeHash(pbNewKey);
|
||||||
|
58
src/KeePassLib2Android/Kp2aLog.cs
Normal file
58
src/KeePassLib2Android/Kp2aLog.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll.
|
||||||
|
|
||||||
|
Keepass2Android 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.
|
||||||
|
|
||||||
|
Keepass2Android 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 Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using Android.Preferences;
|
||||||
|
using KeePassLib.Serialization;
|
||||||
|
|
||||||
|
namespace keepass2android
|
||||||
|
{
|
||||||
|
public static class Kp2aLog
|
||||||
|
{
|
||||||
|
private static bool? _logToFile;
|
||||||
|
|
||||||
|
public static void Log(string message)
|
||||||
|
{
|
||||||
|
Android.Util.Log.Debug("KP2A", message);
|
||||||
|
if (LogToFile)
|
||||||
|
{
|
||||||
|
using (var streamWriter = File.AppendText(LogFilename))
|
||||||
|
{
|
||||||
|
string stringToLog = DateTime.Now+":"+DateTime.Now.Millisecond+ " -- " + message;
|
||||||
|
streamWriter.WriteLine(stringToLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string LogFilename
|
||||||
|
{
|
||||||
|
get { return "/mnt/sdcard/keepass2android.log"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool LogToFile
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_logToFile == null)
|
||||||
|
_logToFile = File.Exists(LogFilename);
|
||||||
|
return (bool) _logToFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -164,7 +164,7 @@ namespace KeePassLib.Native
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Android.Util.Log.Debug("DEBUG", "4+1"+new Kp2atest.TestClass().Add1(4));
|
//Kp2aLog.Log("4+1"+new Kp2atest.TestClass().Add1(4));
|
||||||
Com.Keepassdroid.Crypto.Finalkey.NativeFinalKey key = new Com.Keepassdroid.Crypto.Finalkey.NativeFinalKey();
|
Com.Keepassdroid.Crypto.Finalkey.NativeFinalKey key = new Com.Keepassdroid.Crypto.Finalkey.NativeFinalKey();
|
||||||
|
|
||||||
byte[] newKey = key.TransformMasterKey(pKey256, pBuf256, (int)uRounds);
|
byte[] newKey = key.TransformMasterKey(pKey256, pBuf256, (int)uRounds);
|
||||||
|
@ -34,6 +34,7 @@ using System.Net.Security;
|
|||||||
|
|
||||||
using KeePassLib.Native;
|
using KeePassLib.Native;
|
||||||
using KeePassLib.Utility;
|
using KeePassLib.Utility;
|
||||||
|
using keepass2android;
|
||||||
|
|
||||||
namespace KeePassLib.Serialization
|
namespace KeePassLib.Serialization
|
||||||
{
|
{
|
||||||
@ -211,10 +212,10 @@ namespace KeePassLib.Serialization
|
|||||||
wc.Credentials = credentialCache;
|
wc.Credentials = credentialCache;
|
||||||
} catch (NotImplementedException e)
|
} catch (NotImplementedException e)
|
||||||
{
|
{
|
||||||
Android.Util.Log.Debug("DEBUG", e.ToString());
|
Kp2aLog.Log(e.ToString());
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
Android.Util.Log.Debug("DEBUG", e.ToString());
|
Kp2aLog.Log(e.ToString());
|
||||||
Debug.Assert(false);
|
Debug.Assert(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user