Exemplo n.º 1
0
 public byte[] ComputeHash(byte[] data)
 {
     using (var facade = new GostCryptFacade(ProviderParams))
     {
         facade.AcquireContext(null, Constants.CryptVerifycontext);
         using (HashContext hashContext = facade.CreateHash(null, 0))
         {
             hashContext.AddData(data, 0);
             return(hashContext.GetValue());
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 ///     Подсчет хэша.
 /// </summary>
 /// <param name="data">Данные.</param>
 /// <returns>Хэш.</returns>
 public static byte[] ComputeHash(byte[] data)
 {
     using (var container = new KeyContainer())
     {
         container.AcquireContext(null, ProviderName, ProviderType, Constants.CryptVerifycontext);
         using (HashContext hashContext = container.CreateHash(null, Constants.CpcspHashId, 0))
         {
             hashContext.AddData(data, 0);
             return(hashContext.GetValue());
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 ///     Проверка подписи.
 /// </summary>
 /// <param name="signature">Подпись.</param>
 /// <param name="data">Данные.</param>
 /// <param name="certificateData">Сертификат.</param>
 /// <returns>True - провека прошла успешно, иначе False.</returns>
 public static bool VerifyCertificate(byte[] signature, byte[] data, byte[] certificateData)
 {
     using (var container = new KeyContainer())
     {
         container.AcquireContext(null, ProviderName, ProviderType, Constants.CryptVerifycontext);
         using (KeyContext keyContext = container.ImportSertificate(certificateData))
         {
             using (HashContext hashContext =
                        container.CreateHash(null, Constants.CpcspHashId, 0))
             {
                 hashContext.AddData(data, 0);
                 return(keyContext.VerifySignature(signature, hashContext, 0));
             }
         }
     }
 }
Exemplo n.º 4
0
 public bool VerifyCertificate(
     byte[] signature,
     byte[] data,
     byte[] certificateData)
 {
     using (var facade = new GostCryptFacade(ProviderParams))
     {
         facade.AcquireContext(null, Constants.CryptVerifycontext);
         using (KeyContext keyContext = facade.ImportSertificate(certificateData))
         {
             using (HashContext hashContext = facade.CreateHash(null, 0))
             {
                 hashContext.AddData(data, 0);
                 return(keyContext.VerifySignature(signature, hashContext, 0));
             }
         }
     }
 }
Exemplo n.º 5
0
 public bool VerifySignature(
     byte[] signature,
     byte[] data,
     byte[] publicKey)
 {
     using (var facade = new InfotecsFacade(ProviderParams))
     {
         facade.AcquireContext(null, Constants.CryptVerifycontext);
         using (KeyContext keyContext = facade.ImportKey(null, publicKey, 0))
         {
             using (HashContext hashContext = facade.CreateHash(null, 0))
             {
                 hashContext.AddData(data, 0);
                 return(keyContext.VerifySignature(signature, hashContext, 0));
             }
         }
     }
 }