/**************************************************************************** * * Copyright (c) 2018 CRI Middleware Co., Ltd. * ****************************************************************************/ using System; using System.Runtime.InteropServices; /** * \addtogroup CRIWARE_COMMON_CLASS * @{ */ namespace CriWare { /** * A class which provides the function for setting encrypted data playback. * * Provides the function to set the decryption when playing encrypted data.
* The decryption function can be initialized by calling the functions provided by this class.
*
*/ public static class CriWareDecrypter { /** * Initialization (config specified) * Initialization config * Whether the initialization succeeded * * Initializes the Decrytper.
* This function is called automatically when CriWareInitializer is set.
* Call this function after initializing the FileSystem library. *
*/ public static bool Initialize(CriWareDecrypterConfig config) { return Initialize(config.key, config.authenticationFile, config.enableAtomDecryption, config.enableManaDecryption); } /** * Initialization (parameter specified) * Encryption key * Authentication file path (absolute path or relative path from SreamingAssets) * Whether to decode the sound data * Whether to decrypt the movie data * Whether the initialization succeeded * * Initializes the Decrytper.
* This function is called automatically when CriWareInitializer is set.
* Call this function after initializing the FileSystem library. *
*/ public static bool Initialize(string key, string authenticationFile, bool enableAtomDecryption, bool enableManaDecryption) { if (!CriFsPlugin.IsLibraryInitialized()) { return false; } /* バージョン番号が不正なライブラリには暗号キーを伝えない */ /* 備考)不正に差し替えられたsoファイルを使用している可能性あり。 */ bool isCorrectVersion = CriWare.Common.CheckBinaryVersionCompatibility(); if (isCorrectVersion == false) { return false; } ulong decryptionKey = (key.Length == 0) ? 0 : System.Convert.ToUInt64(key); string authenticationPath = authenticationFile; if (CriWare.Common.IsStreamingAssetsPath(authenticationPath)) { authenticationPath = System.IO.Path.Combine(CriWare.Common.streamingAssetsPath, authenticationPath); } temporalStorage = decryptionKey ^ 0x00D47EB533AEF7E5UL; CRIWAREB9DA24BC(enableAtomDecryption, enableManaDecryption, CallbackFromNative, IntPtr.Zero); temporalStorage = 0; return true; } /* 変数の一時的な格納場所 */ private static ulong temporalStorage = 0; #region Private Methods [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate ulong CallbackFromNativeDelegate(System.IntPtr ptr1); [AOT.MonoPInvokeCallback(typeof(CallbackFromNativeDelegate))] private static ulong CallbackFromNative(System.IntPtr ptr1) { return temporalStorage; } #endregion #region DLL Import #if !CRIWARE_ENABLE_HEADLESS_MODE [DllImport(CriWare.Common.pluginName, CallingConvention = CriWare.Common.pluginCallingConvention)] public static extern int CRIWAREB9DA24BC( bool enable_atom_decryption, bool enable_mana_decryption, CallbackFromNativeDelegate func, IntPtr obj ); #else public static int CRIWAREB9DA24BC( bool enable_atom_decryption, bool enable_mana_decryption, CallbackFromNativeDelegate func, IntPtr obj ) { return 0; } #endif #endregion } // end of class } //namespace CriWare /** @} */ /* --- end of file --- */