Exemple #1
0
        public static string ComputeHashForFiles(IEnumerable <string> fileNames)
        {
            StringBuilder stringBuilder = new StringBuilder();

            foreach (string fileName in fileNames)
            {
                stringBuilder.Append(SEBProtectionController.ComputeFileHash(fileName));
            }
            return(BitConverter.ToString(new SHA256Managed().ComputeHash(Encoding.UTF8.GetBytes(stringBuilder.ToString()))).Replace("-", string.Empty));
        }
Exemple #2
0
        public static X509Certificate2 GetCertificateFromStore(byte[] publicKeyHash)
        {
            X509Store        store1 = new X509Store(StoreLocation.CurrentUser);
            X509Certificate2 certificateFromPassedStore = SEBProtectionController.GetCertificateFromPassedStore(publicKeyHash, store1);

            if (certificateFromPassedStore == null)
            {
                X509Store store2 = new X509Store(StoreLocation.LocalMachine);
                certificateFromPassedStore = SEBProtectionController.GetCertificateFromPassedStore(publicKeyHash, store2);
            }
            return(certificateFromPassedStore);
        }
Exemple #3
0
        public static ArrayList GetCertificatesAndNames(ref ArrayList certificateNames)
        {
            ArrayList arrayList          = new ArrayList();
            X509Store store1             = new X509Store(StoreLocation.CurrentUser);
            ArrayList andNamesFromStore1 = SEBProtectionController.GetCertificatesAndNamesFromStore(ref certificateNames, store1);
            ArrayList certificateNames1  = new ArrayList();
            X509Store store2             = new X509Store(StoreLocation.LocalMachine);
            ArrayList andNamesFromStore2 = SEBProtectionController.GetCertificatesAndNamesFromStore(ref certificateNames1, store2);

            andNamesFromStore1.AddRange((ICollection)andNamesFromStore2);
            certificateNames.AddRange((ICollection)certificateNames1);
            return(andNamesFromStore1);
        }
Exemple #4
0
        public static ArrayList GetSSLCertificatesAndNames(ref ArrayList certificateNames)
        {
            ArrayList arrayList  = new ArrayList();
            X509Store x509Store1 = new X509Store(StoreName.CertificateAuthority);

            x509Store1.Open(OpenFlags.ReadOnly);
            X509Certificate2Collection certificate2Collection = x509Store1.Certificates.Find(X509FindType.FindByKeyUsage, (object)X509KeyUsageFlags.DigitalSignature, false);
            X509Store x509Store2 = new X509Store(StoreName.AddressBook);

            x509Store2.Open(OpenFlags.ReadOnly);
            X509Certificate2Collection certificates = x509Store2.Certificates.Find(X509FindType.FindByKeyUsage, (object)X509KeyUsageFlags.DigitalSignature, false);

            certificate2Collection.AddRange(certificates);
            foreach (X509Certificate2 x509Certificate2 in certificate2Collection)
            {
                arrayList.Add((object)x509Certificate2);
                certificateNames.Add((object)SEBProtectionController.Parse(x509Certificate2.Subject, "CN").FirstOrDefault <string>());
            }
            x509Store2.Close();
            return(arrayList);
        }
Exemple #5
0
        private static string ComputeSEBComponentsHash()
        {
            string        directoryName = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
            List <string> stringList    = new List <string>()
            {
                Path.Combine(directoryName, "SafeExamBrowser.exe"),
                Path.Combine(directoryName, "SEBConfigTool.exe"),
                Path.Combine(directoryName, "Fleck.dll"),
                Path.Combine(directoryName, "IconLib.dll"),
                Path.Combine(directoryName, "MetroFramework.dll"),
                Path.Combine(directoryName, "SEBWindowsServiceContracts.dll"),
                Path.Combine(directoryName, "SebWindowsServiceWCF", "SebWindowsServiceWCF.exe"),
                Path.Combine(directoryName, "SebWindowsServiceWCF", "SEBWindowsServiceContracts.dll"),
                Path.Combine(directoryName, "SebWindowsServiceWCF", "Interop.WUApiLib.dll")
            };
            string path = Path.Combine(directoryName, "SebWindowsBrowser");

            if (Directory.Exists(path))
            {
                stringList.AddRange((IEnumerable <string>)Directory.GetFiles(path, "*.*", SearchOption.AllDirectories));
            }
            return(SEBProtectionController.ComputeHashForFiles((IEnumerable <string>)stringList));
        }
Exemple #6
0
        public static List <string> Parse(string data, string delimiter)
        {
            if (data == null)
            {
                return((List <string>)null);
            }
            if (!delimiter.EndsWith("="))
            {
                delimiter += "=";
            }
            if (!data.Contains(delimiter))
            {
                return((List <string>)null);
            }
            List <string> stringList1 = new List <string>();
            int           startIndex  = data.IndexOf(delimiter) + delimiter.Length;
            int           length      = data.IndexOf(',', startIndex) - startIndex;

            if (length == 0)
            {
                return((List <string>)null);
            }
            if (length > 0)
            {
                stringList1.Add(data.Substring(startIndex, length));
                List <string> stringList2 = SEBProtectionController.Parse(data.Substring(startIndex + length), delimiter);
                if (stringList2 != null)
                {
                    stringList1.AddRange((IEnumerable <string>)stringList2);
                }
            }
            else
            {
                stringList1.Add(data.Substring(startIndex));
            }
            return(stringList1);
        }