public static void SetKeyParameter(SafeKeyHandleImpl keyHandle, int keyParamId, byte[] keyParamValue) { if (!CryptoApi.CryptSetKeyParam(keyHandle, (uint)keyParamId, keyParamValue, 0)) { throw CreateWin32Error(); } }
private static void SetKeyParameterString(SafeKeyHandleImpl keyHandle, int keyParamId, string keyParamValue) { var stringDataBytes = Encoding.GetEncoding(0).GetBytes(keyParamValue); if (!CryptoApi.CryptSetKeyParam(keyHandle, (uint)keyParamId, stringDataBytes, 0)) { throw CreateWin32Error(); } }
public static void SetKeyParameterInt32(SafeKeyHandleImpl keyHandle, int keyParamId, int keyParamValue) { var dwDataBytes = BitConverter.GetBytes(keyParamValue); if (!CryptoApi.CryptSetKeyParam(keyHandle, (uint)keyParamId, dwDataBytes, 0)) { throw CreateWin32Error(); } }