Skip to content

Commit

Permalink
Add support of other key providers to Quick Unlock
Browse files Browse the repository at this point in the history
  • Loading branch information
Rookiestyle committed Aug 28, 2021
1 parent 9474ba5 commit 7665433
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1")]
[assembly: AssemblyFileVersion("1.1")]
[assembly: AssemblyVersion("1.2")]
[assembly: AssemblyFileVersion("1.2")]
15 changes: 14 additions & 1 deletion src/QuickUnlockKeyProv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class QuickUnlockOldKeyInfo
public ProtectedString QuickUnlockKey = ProtectedString.EmptyEx;
public ProtectedBinary pwHash = null;
public string keyFile = string.Empty;
public string CustomKeyProviderName = string.Empty;
public ProtectedBinary CustomKeyProviderData = null;
public bool account = false;
public ProtectedBinary PINCheck = null;
public bool HasPassword = false;
Expand Down Expand Up @@ -111,6 +113,12 @@ private static void RestoreOldMasterKeyInternal(PwDatabase db, IOConnectionInfo
ck.AddUserKey(p);
}
if (!string.IsNullOrEmpty(quOldKey.keyFile)) ck.AddUserKey(new KcpKeyFile(quOldKey.keyFile));
if (!string.IsNullOrEmpty(quOldKey.CustomKeyProviderName))
{
var ckHashedData = quOldKey.CustomKeyProviderData.ReadData();
ck.AddUserKey(new KcpCustomKey(quOldKey.CustomKeyProviderName, ckHashedData, false));
MemUtil.ZeroByteArray(ckHashedData);
}
if (quOldKey.account) ck.AddUserKey(new KcpUserAccount());

if (db != null) db.MasterKey = ck;
Expand Down Expand Up @@ -147,7 +155,7 @@ internal static QuickUnlockOldKeyInfo GetOldKey(PwDatabase db)
if ((quOldKey.pwHash != null) && (quOldKey.pwHash.Length != 0))
quOldKey.pwHash = DecryptKey(quOldKey.QuickUnlockKey, quOldKey.pwHash);
m_originalKey.Remove(db.IOConnectionInfo.Path);
return quOldKey;
return quOldKey;
}

internal static void AddDb(PwDatabase db, ProtectedString QuickUnlockKey, bool savePw)
Expand All @@ -171,6 +179,11 @@ private static void AddOldMasterKey(PwDatabase db, ProtectedString QuickUnlockKe
}
if (db.MasterKey.ContainsType(typeof(KcpKeyFile)))
quOldKey.keyFile = (db.MasterKey.GetUserKey(typeof(KcpKeyFile)) as KcpKeyFile).Path;
if (db.MasterKey.ContainsType(typeof(KcpCustomKey)))
{
quOldKey.CustomKeyProviderName = (db.MasterKey.GetUserKey(typeof(KcpCustomKey)) as KcpCustomKey).Name;
quOldKey.CustomKeyProviderData = (db.MasterKey.GetUserKey(typeof(KcpCustomKey)) as KcpCustomKey).KeyData;
}
quOldKey.account = db.MasterKey.ContainsType(typeof(KcpUserAccount));
quOldKey.PINCheck = EncryptKey(QuickUnlockKey, new ProtectedBinary(true, m_PINCheck));
int iValidity = LockAssistConfig.GetQuickUnlockOptions(db).QU_ValiditySeconds;
Expand Down
2 changes: 1 addition & 1 deletion version.info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:
LockAssist:1.1
LockAssist:1.2
LockAssist!de:2
:

0 comments on commit 7665433

Please sign in to comment.