Beispiel #1
0
        private void CheckSignaturesXml(string sigXmlPath, ISource source, List <string> fails)
        {
            var signatures = new S63SignaturesXmlFile(source.OpenRead(sigXmlPath));

            if (!XmlDataServersAreSignedBySA(signatures))
            {
                fails.Add(sigXmlPath);
            }

            foreach (var sig in signatures.Signatures)
            {
                string filePath = Path.Combine(source.Root, sig.FileLocation, sig.FileName);

                byte[] fileHash = SHA1.ComputeHash(source.OpenRead(filePath));

                var dataServer = signatures.DataServers.FirstOrDefault(ds => ds.ID.Equals(sig.DataServerID));

                if (dataServer is null)
                {
                    Write($"Data server not found {sig.DataServerID}");
                    fails.Add(filePath);
                    continue;
                }

                using (var dsaCell = new DSACryptoServiceProvider())
                {
                    dsaCell.ImportParameters(new DSAParameters()
                    {
                        P = dataServer.BigP,
                        Q = dataServer.BigQ,
                        G = dataServer.BigG,
                        Y = dataServer.BigY
                    });

                    bool isgood = dsaCell.VerifySignature(fileHash, sig.SignatureR.Concat(sig.SignatureS).ToArray());

                    if (isgood)
                    {
                        WriteVerbose($"PASS: {Path.Combine(sig.FileLocation, sig.FileName)}");
                    }
                    else
                    {
                        WriteVerbose($"FAIL: {Path.Combine(sig.FileLocation, sig.FileName)}\tSignature check failure");
                        fails.Add(filePath);
                    }
                }

                PathsChecked.Add(filePath.Replace(@"/", @"\"));
            }
        }
Beispiel #2
0
        private bool XmlDataServersAreSignedBySA(S63SignaturesXmlFile sf)
        {
            bool success = true;

            foreach (var ds in sf.DataServers)
            {
                if (XmlDataServersSignedBySA(ds))
                {
                    WriteVerbose($"PASS: XML data server {ds.ID} is signed by SA");
                }
                else
                {
                    WriteVerbose($"FAIL: XML data server {ds.ID} NOT signed by SA");
                    success = false;
                }
            }

            return(success);
        }