diff --git a/TDESDUKPTTool/key.ico b/TDESDUKPTTool/Images/key.ico similarity index 100% rename from TDESDUKPTTool/key.ico rename to TDESDUKPTTool/Images/key.ico diff --git a/TDESDUKPTTool/TDESDUKPTTool.csproj b/TDESDUKPTTool/TDESDUKPTTool.csproj index f642865..658102d 100644 --- a/TDESDUKPTTool/TDESDUKPTTool.csproj +++ b/TDESDUKPTTool/TDESDUKPTTool.csproj @@ -55,7 +55,7 @@ - key.ico + Images\key.ico @@ -86,7 +86,6 @@ True Resources.resx - Form @@ -135,7 +134,7 @@ - + diff --git a/TDESDUKPTTool/Utils/CryptoUtils.cs b/TDESDUKPTTool/Utils/CryptoUtils.cs deleted file mode 100644 index 3ec6627..0000000 --- a/TDESDUKPTTool/Utils/CryptoUtils.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Linq; -using System.Security.Cryptography; - -namespace TDESDUKPTTool.Utils -{ - public static class CryptoUtils - { - - /// - /// Gets the next multiple of 8 - /// Works with both scenarios, getting 7 bytes instead of 8 and works when expecting 16 bytes and getting 15. - /// - private static int GetNearestWholeMultiple(decimal input, int multiple) - { - var output = Math.Round(input / multiple); - if (output == 0 && input > 0) output += 1; - output *= multiple; - return (int)output; - } - - /// - /// Get first 6 characters of X9.24 check value - /// - /// Key Part Byte Array - /// Key part check value - public static byte[] CalculateCheckValue(byte[] keyPart) - { - byte[] fullCheckData = CalculateCheckData(keyPart); - if (fullCheckData == null) - return null; - byte[] checkData = new byte[3]; - Buffer.BlockCopy(fullCheckData, 0, checkData, 0, 3); - return checkData; - } - - /// - /// Calculate Entire x9.24 Check Value for Key Part - /// - /// Key Part Byte Array - /// Entire key part check value array - public static byte[] CalculateCheckData(byte[] keyPartBytes) - { - try - { - - byte[] message = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - - using (var cipher = SymmetricAlgorithm.Create("TripleDES")) - { - var k = keyPartBytes; - cipher.Key = new byte[Math.Max(0, GetNearestWholeMultiple(k.Length, 8) - k.Length)].Concat(keyPartBytes).ToArray(); - cipher.IV = new byte[8]; - cipher.Mode = CipherMode.ECB; - cipher.Padding = PaddingMode.Zeros; - using (var crypto = cipher.CreateEncryptor()) - { - var data = message; - data = new byte[Math.Max(0, GetNearestWholeMultiple(data.Length, 8) - data.Length)].Concat(message).ToArray(); - return crypto.TransformFinalBlock(data, 0, data.Length); - } - } - } - catch - { - return null; - } - } - - } -}