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); } }
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); } }); }
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); }