Exemplo n.º 1
0
        public bool ResetPinCode(SecureString pin)
        {
            try
            {
                X509Certificate2 certificate = CertManager.GetCertificateFromStorage(StoreName.My, StoreLocation.LocalMachine, username);

                X509Certificate2 certificateSign = CertManager.GetCertificateFromStorage(StoreName.My, StoreLocation.LocalMachine, username + "Sign");

                // hash klijentskog PINa
                byte[] hash = DigitalSignature.CreateHash(new System.Net.NetworkCredential(string.Empty, pin).Password, "SHA1");

                /// Create a signature using SHA1 hash algorithm
                byte[] signature = DigitalSignature.Create(new System.Net.NetworkCredential(string.Empty, pin).Password, "SHA1", certificateSign);

                Console.WriteLine("Delete all cert files and press any key");
                Console.ReadKey();

                return(ResetPinCode(signature, certificate));
            }
            catch (Exception e)
            {
                Console.WriteLine("[ResetPinCode] ERROR = {0}", e.Message);
                return(false);
            }
        }
Exemplo n.º 2
0
        public bool WithdrawSmartCardClient(SecureString pin)
        {
            try
            {
                X509Certificate2 certificateSign = CertManager.GetCertificateFromStorage(StoreName.My, StoreLocation.LocalMachine, username + "Sign");

                // hash klijentskog PINa
                byte[] hash = DigitalSignature.CreateHash(new System.Net.NetworkCredential(string.Empty, pin).Password, "SHA1");

                /// Create a signature using SHA1 hash algorithm
                byte[] signature = DigitalSignature.Create(new System.Net.NetworkCredential(string.Empty, pin).Password, "SHA1", certificateSign);

                return(factory.WithdrawSmartCardClient(signature));
            }
            catch (Exception e)
            {
                Console.WriteLine("[WithdrawSmartCardClient] ERROR = {0}", e.Message);
                return(false);
            }
        }
Exemplo n.º 3
0
        public bool SendPin(SecureString pin)
        {
            try
            {
                string signCertCN = Formatter.ParseName(WindowsIdentity.GetCurrent().Name) + "Sign";

                /// Create a signature based on the "signCertCN"
                X509Certificate2 signCert = CertManager.GetCertificateFromStorage(StoreName.My, StoreLocation.LocalMachine, signCertCN);
                // hash klijentskog PINa
                byte[] hash = DigitalSignature.CreateHash(new System.Net.NetworkCredential(string.Empty, pin).Password, "SHA1");
                /// Create a signature using SHA1 hash algorithm
                byte[] signature = DigitalSignature.Create(new System.Net.NetworkCredential(string.Empty, pin).Password, "SHA1", signCert);
                return(SendPin(signature));
            }
            catch (Exception e)
            {
                Console.WriteLine("[SendPin] ERROR = {0}", e.Message);
                return(false);
            }
        }