private static SafeHashHandleImpl CreateHash_3411(SafeProvHandleImpl providerHandle, int hashAlgId) { var hashHandle = SafeHashHandleImpl.InvalidHandle; if (!CryptoApi.CryptCreateHash(providerHandle, (uint)hashAlgId, SafeKeyHandleImpl.InvalidHandle, 0, ref hashHandle)) { throw CreateWin32Error(); } return(hashHandle); }
public static SafeHashHandleImpl CreateHashImit(SafeProvHandleImpl providerHandle, SafeKeyHandleImpl symKeyHandle) { var hashImitHandle = SafeHashHandleImpl.InvalidHandle; if (!CryptoApi.CryptCreateHash(providerHandle, Constants.CALG_G28147_IMIT, symKeyHandle, 0, ref hashImitHandle)) { throw CreateWin32Error(); } return(hashImitHandle); }
private static SafeHashHandleImpl CreateHashHMAC(SafeProvHandleImpl providerHandle, SafeKeyHandleImpl symKeyHandle, int hmacAlgId) { var hashHmacHandle = SafeHashHandleImpl.InvalidHandle; if (!CryptoApi.CryptCreateHash(providerHandle, (uint)hmacAlgId, symKeyHandle, 0, ref hashHmacHandle)) { var errorCode = Marshal.GetLastWin32Error(); if (errorCode == Constants.NTE_BAD_ALGID) { throw ExceptionUtility.CryptographicException(Resources.AlgorithmNotAvailable); } throw ExceptionUtility.CryptographicException(errorCode); } return(hashHmacHandle); }
public static SafeHashHandleImpl CreateHashHmac(SafeProvHandleImpl providerHandle, SafeKeyHandleImpl symKeyHandle) { var hashHmacHandle = SafeHashHandleImpl.InvalidHandle; var hmacAlgId = (GostCryptoConfig.ProviderType == ProviderTypes.VipNet) ? Constants.CALG_GR3411_HMAC34 : Constants.CALG_GR3411_HMAC; if (!CryptoApi.CryptCreateHash(providerHandle, (uint)hmacAlgId, symKeyHandle, 0, ref hashHmacHandle)) { var errorCode = Marshal.GetLastWin32Error(); if (errorCode == Constants.NTE_BAD_ALGID) { throw ExceptionUtility.CryptographicException(Resources.AlgorithmNotAvailable); } throw ExceptionUtility.CryptographicException(errorCode); } return(hashHmacHandle); }