public Gost3411Hmac() { HashName = DefaultHashName; HashSizeValue = DefaultHashSize; _keyAlgorithm = new Gost28147SymmetricAlgorithm(); _hashHandle = CryptoApiHelper.CreateHashHmac(CryptoApiHelper.ProviderHandle, _keyAlgorithm.InternalKeyHandle); }
public Gost3411Hmac(Gost28147SymmetricAlgorithmBase keyAlgorithm) { if (keyAlgorithm == null) { throw ExceptionUtility.ArgumentNull("keyAlgorithm"); } HashName = DefaultHashName; HashSizeValue = DefaultHashSize; _keyAlgorithm = DuplicateKeyAlg(keyAlgorithm); _hashHandle = CryptoApiHelper.CreateHashHmac(CryptoApiHelper.ProviderHandle, _keyAlgorithm.InternalKeyHandle); }
public Gost3411Hmac(byte[] key) { if (key == null) { throw ExceptionUtility.ArgumentNull("key"); } HashName = DefaultHashName; HashSizeValue = DefaultHashSize; _keyAlgorithm = new Gost28147SymmetricAlgorithm { Key = key }; _hashHandle = CryptoApiHelper.CreateHashHmac(CryptoApiHelper.ProviderHandle, _keyAlgorithm.InternalKeyHandle); }
public Gost3411Prf(Gost28147SymmetricAlgorithmBase key, byte[] label, byte[] seed) : this(label, seed) { if (key == null) { throw ExceptionUtility.ArgumentNull("key"); } _hashHmacHandle = SafeHashHandleImpl.InvalidHandle; _buffer = new byte[_labelAndSeed.Length + 32]; var gostSymmetricAlgorithm = key as Gost28147SymmetricAlgorithm; _key = (gostSymmetricAlgorithm != null) ? new Gost28147SymmetricAlgorithm(gostSymmetricAlgorithm.InternalProvHandle, gostSymmetricAlgorithm.InternalKeyHandle) : new Gost28147SymmetricAlgorithm { Key = key.Key }; }
private void InitializeHmac() { var hashHmacHandle = CryptoApiHelper.CreateHashHmac(CryptoApiHelper.ProviderHandle, _key.InternalKeyHandle); _hashHmacHandle.TryDispose(); _hashHmacHandle = hashHmacHandle; }
public override void Initialize() { var hashHmacHandle = CryptoApiHelper.CreateHashHmac(CryptoApiHelper.ProviderHandle, _keyAlgorithm.InternalKeyHandle); _hashHandle.TryDispose(); _hashHandle = hashHmacHandle; }
public static extern bool CryptGetHashParam([In] SafeHashHandleImpl hHash, [In] uint dwParam, [In][Out] byte[] pbData, ref uint pdwDataLen, [In] uint dwFlags);
public override void Initialize() { _hashHandle.TryDispose(); _hashHandle = null; }
public static extern bool CryptVerifySignature([In] SafeHashHandleImpl hHash, [In][Out] byte[] pbSignature, uint pdwSigLen, [In] SafeKeyHandleImpl hPubKey, [MarshalAs(UnmanagedType.LPStr)] StringBuilder sDescription, [In] uint dwFlags);
public static extern bool CryptSignHash([In] SafeHashHandleImpl hHash, [In] uint dwKeySpec, [MarshalAs(UnmanagedType.LPStr)] StringBuilder sDescription, [In] uint dwFlags, [In][Out] byte[] pbSignature, ref uint pdwSigLen);
public static extern bool CryptDeriveKey([In] SafeProvHandleImpl hProv, [In] uint Algid, [In] SafeHashHandleImpl hBaseData, [In] uint dwFlags, [In][Out] ref SafeKeyHandleImpl phKey);
public static SafeKeyHandleImpl DeriveSymKey(SafeProvHandleImpl providerHandle, SafeHashHandleImpl hashHandle) { var symKeyHandle = SafeKeyHandleImpl.InvalidHandle; if (!CryptoApi.CryptDeriveKey(providerHandle, Constants.CALG_G28147, hashHandle, Constants.CRYPT_EXPORTABLE, ref symKeyHandle)) { throw CreateWin32Error(); } return(symKeyHandle); }
public override void Initialize() { _hashHandle.TryDispose(); _hashHandle = CryptoApiHelper.CreateHash(CryptoApiHelper.ProviderHandle); }
public Gost3411HashAlgorithm() { _hashHandle = CryptoApiHelper.CreateHash(CryptoApiHelper.ProviderHandle); }
private void InitHash() { var hProv = CryptoApiHelper.ProviderHandle; var hHash = CryptoApiHelper.CreateHashImit(hProv, _keyAlgorithm.InternalKeyHandle); _hashHandle = hHash; }
public static extern bool CryptCreateHash([In] SafeProvHandleImpl hProv, [In] uint Algid, [In] SafeKeyHandleImpl hKey, [In] uint dwFlags, [In][Out] ref SafeHashHandleImpl phHash);
public Gost3411Prf(byte[] key, byte[] label, byte[] seed) : this(label, seed) { if (key == null) { throw ExceptionUtility.ArgumentNull("key"); } if (key.Length != 32) { throw ExceptionUtility.Argument("key", Resources.InvalidHashSize); } _hashHmacHandle = SafeHashHandleImpl.InvalidHandle; _buffer = new byte[_labelAndSeed.Length + 32]; using (var keyHandle = CryptoApiHelper.ImportBulkSessionKey(CryptoApiHelper.ProviderHandle, key, CryptoApiHelper.RandomNumberGenerator)) { _key = new Gost28147SymmetricAlgorithm(CryptoApiHelper.ProviderHandle, keyHandle); } }
public static bool VerifySign(SafeProvHandleImpl providerHandle, SafeHashHandleImpl hashHandle, SafeKeyHandleImpl keyHandle, byte[] hashValue, byte[] signatureValue) { SetHashValue(hashHandle, hashValue); return(CryptoApi.CryptVerifySignature(hashHandle, signatureValue, (uint)signatureValue.Length, keyHandle, null, 0)); }