diff --git a/Borepin/Borepin/Model/CardConfig.cs b/Borepin/Borepin/Model/CardConfig.cs index 51c9524..d55a89e 100644 --- a/Borepin/Borepin/Model/CardConfig.cs +++ b/Borepin/Borepin/Model/CardConfig.cs @@ -1,6 +1,7 @@ using NFC.Helper; using System; using System.Globalization; +using System.Security.Cryptography; namespace Borepin.Model { @@ -9,8 +10,8 @@ namespace Borepin.Model #region Constructors public CardConfig() { - PICCKey = ByteOperation.GenerateEmptyArray(16); - APPKey = ByteOperation.GenerateEmptyArray(16); + PICCKey = GenerateEmptyKey(); + APPKey = GenerateEmptyKey(); } #endregion @@ -53,11 +54,15 @@ namespace Borepin.Model public byte[] GenerateRandomKey() { byte[] key = ByteOperation.GenerateEmptyArray(16); - Random random= new Random(); - - random.NextBytes(key); + RNGCryptoServiceProvider cryptoProvider = new RNGCryptoServiceProvider(); + cryptoProvider.GetBytes(key); return key; } + + public byte[] GenerateEmptyKey() + { + return ByteOperation.GenerateEmptyArray(16); + } #endregion } } diff --git a/Borepin/Borepin/Model/KeyScan.cs b/Borepin/Borepin/Model/KeyScan.cs new file mode 100644 index 0000000..c590bb9 --- /dev/null +++ b/Borepin/Borepin/Model/KeyScan.cs @@ -0,0 +1,14 @@ +namespace Borepin.Model +{ + public class KeyScan + { + public KeyScan(CardConfig cardConfig, KeyTypes keyType) + { + CardConfig = cardConfig; + KeyType = keyType; + } + + public CardConfig CardConfig; + public KeyTypes KeyType; + } +} diff --git a/Borepin/Borepin/Model/KeyTypes.cs b/Borepin/Borepin/Model/KeyTypes.cs new file mode 100644 index 0000000..e2e6391 --- /dev/null +++ b/Borepin/Borepin/Model/KeyTypes.cs @@ -0,0 +1,9 @@ +namespace Borepin.Model +{ + public enum KeyTypes + { + NONE, + PICC, + APP + }; +} diff --git a/Borepin/Borepin/Page/CreateCardPage.xaml b/Borepin/Borepin/Page/CreateCardPage.xaml index 7e2df60..5bf96a5 100644 --- a/Borepin/Borepin/Page/CreateCardPage.xaml +++ b/Borepin/Borepin/Page/CreateCardPage.xaml @@ -37,7 +37,6 @@ -