Skip to content

Commit

Permalink
Version 1.3 - fix for #1 and #2
Browse files Browse the repository at this point in the history
Fixed some error and bugs, update the UI
  • Loading branch information
sbidy committed Jan 15, 2018
1 parent 7c06d51 commit f494042
Show file tree
Hide file tree
Showing 19 changed files with 324 additions and 195 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/.vs
/KeyManagerUI/obj/Release
/KeyManagerUI/obj/Debug
/KeyManagerUI/obj
/KeyManagerUI/bin
/KeyManagerUI/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
/KeyManagerUI/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
/KeyManagerUI/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
Binary file added KeyManagerUI.plgx
Binary file not shown.
13 changes: 5 additions & 8 deletions KeyManagerUI.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeyManagerUI", "KeyManagerUI\KeyManagerUI.csproj", "{20ADD178-ADF3-4589-AD7B-EE38E02E861D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeePassKeyManager", "..\KeePassKeyManager\KeePassKeyManager\KeePassKeyManager.csproj", "{709F0DBB-5776-408B-9D0C-D03875084F1A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -17,12 +15,11 @@ Global
{20ADD178-ADF3-4589-AD7B-EE38E02E861D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20ADD178-ADF3-4589-AD7B-EE38E02E861D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{20ADD178-ADF3-4589-AD7B-EE38E02E861D}.Release|Any CPU.Build.0 = Release|Any CPU
{709F0DBB-5776-408B-9D0C-D03875084F1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{709F0DBB-5776-408B-9D0C-D03875084F1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{709F0DBB-5776-408B-9D0C-D03875084F1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{709F0DBB-5776-408B-9D0C-D03875084F1A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {06426689-554B-4764-819F-13BB1FFC7524}
EndGlobalSection
EndGlobal
56 changes: 30 additions & 26 deletions KeyManagerUI/Certmanager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.Xml;
Expand Down Expand Up @@ -36,28 +37,35 @@ public byte[] EncryptMsg(Byte[] msg, X509Certificate2Collection recipientCerts)
ContentInfo contentInfo = new ContentInfo(msg);

recipientCerts = checkCerts(recipientCerts);

// Instantiate an EnvelopedCms object with the ContentInfo
// above.
// Has default SubjectIdentifierType IssuerAndSerialNumber.
// Has default ContentEncryptionAlgorithm property value
// RSA_DES_EDE3_CBC.
EnvelopedCms envelopedCms = new EnvelopedCms(contentInfo);

// Formulate a CmsRecipient object collection that
// represent information about the recipients
// to encrypt the message for.
if (recipientCerts.Count > 0)

if (recipientCerts != null)
{
CmsRecipientCollection recips = new CmsRecipientCollection(SubjectIdentifierType.IssuerAndSerialNumber, recipientCerts);
// Instantiate an EnvelopedCms object with the ContentInfo
// above.
// Has default SubjectIdentifierType IssuerAndSerialNumber.
// Has default ContentEncryptionAlgorithm property value
// RSA_DES_EDE3_CBC.
EnvelopedCms envelopedCms = new EnvelopedCms(contentInfo);

// Formulate a CmsRecipient object collection that
// represent information about the recipients
// to encrypt the message for.
if (recipientCerts.Count > 0)
{
CmsRecipientCollection recips = new CmsRecipientCollection(SubjectIdentifierType.IssuerAndSerialNumber, recipientCerts);

// Encrypt the message for the recipient.
envelopedCms.Encrypt(recips);
// Encrypt the message for the recipient.
envelopedCms.Encrypt(recips);

// The encoded EnvelopedCms message contains the message
// ciphertext and the information about each recipient
// that the message was enveloped for.
return envelopedCms.Encode();
// The encoded EnvelopedCms message contains the message
// ciphertext and the information about each recipient
// that the message was enveloped for.
return envelopedCms.Encode();
}
}
else
{
throw new CryptographicException();
}
return null;
}
Expand Down Expand Up @@ -175,7 +183,7 @@ public void addFromStore()

X509Certificate2Collection fcollection = allCerts.Find(X509FindType.FindByTimeValid, DateTime.Now, false);
fcollection = fcollection.Find(X509FindType.FindByKeyUsage, X509KeyUsageFlags.KeyEncipherment, false);
X509Certificate2Collection store_certs = X509Certificate2UI.SelectFromCollection(fcollection, "SelectEncCert", "SelectEncCertLong", X509SelectionFlag.MultiSelection);
X509Certificate2Collection store_certs = X509Certificate2UI.SelectFromCollection(fcollection, "Select certificate", "Select a certificate from local Microsoft Windows store:", X509SelectionFlag.MultiSelection);

applied_certs.AddRange(store_certs);
}
Expand Down Expand Up @@ -212,12 +220,8 @@ private X509Certificate2Collection checkCerts(X509Certificate2Collection certs_t
{
reason.AppendLine(chain.ChainStatus[index].StatusInformation);
}
DialogResult decision = MessageBox.Show("Certificate:\n"+cert.SubjectName.Name+"\n\ncan't validated - add anyway?\nReasons:"+reason, "Error",
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button3);
if (decision == DialogResult.Cancel)
{
return null;
}
DialogResult decision = MessageBox.Show("Certificate:\n"+cert.SubjectName.Name+ "\n\ncan't validated and maybe not applicable - try anyway?\nReasons: " + reason, "Error",
MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
if (decision == DialogResult.No)
{
toRemove.Insert(0, cert);
Expand Down
4 changes: 2 additions & 2 deletions KeyManagerUI/KeyManagerUIClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using KeePassLib.Utility;
using KeePass.UI;

// Build : & 'C:\Program Files (x86)\KeePass Password Safe 2\KeePass.exe' --plgx-create "C:\Users\TraubS\Documents\Visual Studio 2015\Projects\KeyManagerUI\KeyManagerUI"
// Build : & 'C:\Program Files (x86)\KeePass Password Safe 2\KeePass.exe' --plgx-create "C:\Users\TraubS\Documents\GitHub\KeePass-KeyManager\KeyManagerUI"

namespace KeyManagerUI
{
Expand Down Expand Up @@ -167,7 +167,7 @@ byte[] GetExistingKey(IOConnectionInfo ioc)
}
catch (SystemException ex) // covers IOException and CryptographicException
{
MessageBox.Show("Error at encryption or IO error!");
MessageBox.Show("Error at encryption or IO error!\nIf you used a smart card for encryption, please provide/plugin fist!");
return null;
}
}
Expand Down
Loading

0 comments on commit f494042

Please sign in to comment.