예제 #1
0
파일: Package.cs 프로젝트: pvp-by/ValvePak
        /// <summary>
        /// Verifies the RSA signature.
        /// </summary>
        /// <returns>True if signature is valid, false otherwise.</returns>
        public bool IsSignatureValid()
        {
            Reader.BaseStream.Position = 0;

            var keyParser = new AsnKeyParser(PublicKey);

            var rsa = RSA.Create();

            rsa.ImportParameters(keyParser.ParseRSAPublicKey());

            var data = Reader.ReadBytes((int)(HeaderSize + TreeSize + FileDataSectionSize + ArchiveMD5SectionSize + OtherMD5SectionSize));

            return(rsa.VerifyData(data, Signature, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1));
        }
예제 #2
0
        /// <summary>
        /// Verifies the RSA signature.
        /// </summary>
        /// <returns>True if signature is valid, false otherwise.</returns>
        public bool IsSignatureValid()
        {
            Reader.BaseStream.Position = 0;

            var keyParser = new AsnKeyParser(PublicKey);

            var rsa = new RSACryptoServiceProvider();

            rsa.ImportParameters(keyParser.ParseRSAPublicKey());

            var deformatter = new RSAPKCS1SignatureDeformatter(rsa);

            deformatter.SetHashAlgorithm("SHA256");

            var hash = new SHA256Managed().ComputeHash(Reader.ReadBytes((int)(HeaderSize + TreeSize + FileDataSectionSize + ArchiveMD5SectionSize + OtherMD5SectionSize)));

            return(deformatter.VerifySignature(hash, Signature));
        }