Пример #1
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 = 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));
        }