示例#1
0
        public void GetCertificatePublicKey()
        {
            using (GostCryptFacade keyContainer = Gost2001KeyContainer.Open(ContainerSert, ContainerPassword))
            {
                var certificateRawData = keyContainer.ExportCertificateData();
                var publicKeyFromCert  = Gost2001KeyContainer.GetCertificatePublicKey(certificateRawData);

                var containerKey = keyContainer.ExportPublicKey();

                Assert.AreEqual(containerKey, publicKeyFromCert);
            }
        }
示例#2
0
        public void GetCertificatePublicKey()
        {
            GostKeyContainer.Get(GostKeyContainer.Signature.Gost34102001,
                                 crypt =>
            {
                using (GostCryptFacade keyContainer = crypt.Open(ContainerSert, ContainerPassword))
                {
                    var certificateRawData = keyContainer.ExportCertificateData();
                    var publicKeyFromCert  = crypt.GetCertificatePublicKey(certificateRawData);

                    var containerKey = keyContainer.ExportPublicKey();

                    Assert.AreEqual(containerKey, publicKeyFromCert);
                }
            });
        }
示例#3
0
        public void SignCertigicateSignature()
        {
            byte[] data = GetRandomData();

            byte[] signature, certificateRawData;
            byte[] hash = Gost2001KeyContainer.ComputeHash(data);


            using (GostCryptFacade keyContainer = Gost2001KeyContainer.Open(ContainerSert, ContainerPassword))
            {
                signature          = keyContainer.SignHash(hash, KeyNumber.Signature);
                certificateRawData = keyContainer.ExportCertificateData();
            }

            bool result = Gost2001KeyContainer.VerifyCertificate(signature, data, certificateRawData);

            Assert.IsTrue(result);
        }