Ejemplo n.º 1
0
 /// <summary>
 ///     Проверка подписи.
 /// </summary>
 /// <param name="request">Данные.</param>
 /// <returns>True - провека прошла успешно, иначе False.</returns>
 public bool VerifySignature(VerifySignatureRequest request)
 {
     log.Debug("VerifySignature: {0}", request);
     byte[] signatureValue = Convert.FromBase64String(request.Signature);
     byte[] dataValue      = Encoding.UTF8.GetBytes(request.Data);
     byte[] publicKeyValue = Convert.FromBase64String(request.PublicKey);
     return(Gost2001KeyContainer.VerifySignature(signatureValue, dataValue, publicKeyValue));
 }
Ejemplo n.º 2
0
        public void SignHash()
        {
            byte[] data = GetRandomData();

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

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

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

            Assert.IsTrue(result);
        }