private byte[] EncodeKeyExchangeInternal(Gost_28147_89_SymmetricAlgorithm keyExchangeAlgorithm, int keyExchangeExportAlgId) { Gost_28147_89_KeyExchangeInfo keyExchangeInfo; SafeKeyHandleImpl keyExchangeHandle = null; try { var importedKeyBytes = CryptoApiHelper.EncodePublicBlob(_keyExchangeParameters, _keySize, _signatureAlgId); CryptoApiHelper.ImportCspBlob(importedKeyBytes, _provHandle, _keyHandle, out keyExchangeHandle); CryptoApiHelper.SetKeyExchangeExportAlgId(ProviderType, keyExchangeHandle, keyExchangeExportAlgId); var symKeyHandle = keyExchangeAlgorithm.GetSafeHandle(); keyExchangeInfo = CryptoApiHelper.ExportKeyExchange(symKeyHandle, keyExchangeHandle); } finally { keyExchangeHandle.TryDispose(); } return(keyExchangeInfo.Encode()); }
private void InitDefaults(Gost_28147_89_SymmetricAlgorithm keyAlgorithm) { HashName = typeof(THash).Name; _keyAlgorithm = keyAlgorithm; _hmacHandle = CreateHashHMAC(keyAlgorithm.ProviderType, CryptoApiHelper.GetProviderHandle(keyAlgorithm.ProviderType), keyAlgorithm.GetSafeHandle()); }
public override void Initialize() { var hmacHandle = CreateHashHMAC(ProviderType, CryptoApiHelper.GetProviderHandle(ProviderType), _keyAlgorithm.GetSafeHandle()); _hmacHandle.TryDispose(); _hmacHandle = hmacHandle; }