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

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

            facade.AcquireContext(keyContainerName, Constants.NewKeySet);
            facade.GenerateRandomKey(keyNumber);
            return(facade);
        }
示例#4
0
 public void Remove(string keyContainerName)
 {
     try
     {
         var facade = new GostCryptFacade(ProviderParams);
         facade.AcquireContext(keyContainerName, Constants.DeleteKeySet);
     }
     catch (Win32Exception)
     {
     }
 }
示例#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());
         }
     }
 }
示例#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());
         }
     }
 }
示例#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);
     }
 }
示例#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));
             }
         }
     }
 }