public byte[] ExportCertificateData(string keyContainerName) { using (var facade = new GostCryptFacade(ProviderParams)) { facade.AcquireContext(keyContainerName, 0); return(facade.ExportCertificateData()); } }
public GostCryptFacade Open(string keyContainerName, string keycontainerPassword) { var facade = new GostCryptFacade(ProviderParams); facade.AcquireContext(keyContainerName, 0); facade.SetPassword(keycontainerPassword); return(facade); }
public GostCryptFacade Create(string keyContainerName, KeyNumber keyNumber) { var facade = new GostCryptFacade(ProviderParams); facade.AcquireContext(keyContainerName, Constants.NewKeySet); facade.GenerateRandomKey(keyNumber); return(facade); }
public void Remove(string keyContainerName) { try { var facade = new GostCryptFacade(ProviderParams); facade.AcquireContext(keyContainerName, Constants.DeleteKeySet); } catch (Win32Exception) { } }
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()); } } }
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()); } } }
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); } }
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)); } } } }