Exemplo n.º 1
0
 public byte[] ExportCertificateData(string keyContainerName)
 {
     using (var facade = new GostCryptFacade(ProviderParams))
     {
         facade.AcquireContext(keyContainerName, 0);
         return(facade.ExportCertificateData());
     }
 }
Exemplo n.º 2
0
        public GostCryptFacade Open(string keyContainerName, string keycontainerPassword)
        {
            var facade = new GostCryptFacade(ProviderParams);

            facade.AcquireContext(keyContainerName, 0);
            facade.SetPassword(keycontainerPassword);
            return(facade);
        }
Exemplo n.º 3
0
        public GostCryptFacade Create(string keyContainerName, KeyNumber keyNumber)
        {
            var facade = new GostCryptFacade(ProviderParams);

            facade.AcquireContext(keyContainerName, Constants.NewKeySet);
            facade.GenerateRandomKey(keyNumber);
            return(facade);
        }
Exemplo n.º 4
0
 public void Remove(string keyContainerName)
 {
     try
     {
         var facade = new GostCryptFacade(ProviderParams);
         facade.AcquireContext(keyContainerName, Constants.DeleteKeySet);
     }
     catch (Win32Exception)
     {
     }
 }
Exemplo n.º 5
0
 public byte[] GetCertificatePublicKey(byte[] certificateData)
 {
     using (var facade = new GostCryptFacade(ProviderParams))
     {
         facade.AcquireContext(null, Constants.CryptVerifycontext);
         using (KeyContext keyContext = facade.ImportSertificate(certificateData))
         {
             return(keyContext.ExportPublicKey());
         }
     }
 }
Exemplo n.º 6
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.º 7
0
 public bool Exist(string keyContainerName)
 {
     try
     {
         using (var facade = new GostCryptFacade(ProviderParams))
         {
             facade.AcquireContext(keyContainerName, Constants.SilentMode);
             facade.GetUserKey();
             return(true);
         }
     }
     catch (Win32Exception)
     {
         return(false);
     }
 }
Exemplo n.º 8
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));
             }
         }
     }
 }