Exemple #1
0
 public void ExportPublicKey()
 {
     using (KeyContainer keyContainer = KeyContainer.Open(Container, ContainerPassword))
     {
         byte[] key = keyContainer.ExportPublicKey();
         CollectionAssert.IsNotEmpty(key);
     }
 }
Exemple #2
0
        public void GetCertificatePublicKey()
        {
            using (KeyContainer keyContainer = KeyContainer.Open(ContainerSert, ContainerPassword))
            {
                var certificateRawData = keyContainer.ExportCertificateData();
                var publicKeyFromCert  = KeyContainer.GetCertificatePublicKey(certificateRawData);

                var containerKey = keyContainer.ExportPublicKey();

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

            byte[] signature;
            byte[] hash = KeyContainer.ComputeHash(data);

            using (KeyContainer keyContainer = KeyContainer.Open(Container, ContainerPassword))
            {
                signature = keyContainer.SignHash(hash, KeyNumber.Signature);
            }

            byte[] publicKey = KeyContainer.ExportPublicKey(Container);
            bool   result    = KeyContainer.VerifySignature(signature, data, publicKey);

            Assert.IsTrue(result);
        }
 /// <summary>
 ///     Экспорт открытого ключа.
 /// </summary>
 /// <returns>Открытый ключ.</returns>
 public string ExportPublicKey()
 {
     log.Debug("ExportPublicKey: keyContainerName: {0}", Container);
     return(Convert.ToBase64String(KeyContainer.ExportPublicKey(Container)));
 }