diff options
Diffstat (limited to 'Runtime/Export/SecurityPublic.txt')
-rw-r--r-- | Runtime/Export/SecurityPublic.txt | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Runtime/Export/SecurityPublic.txt b/Runtime/Export/SecurityPublic.txt new file mode 100644 index 0000000..a130ca4 --- /dev/null +++ b/Runtime/Export/SecurityPublic.txt @@ -0,0 +1,61 @@ +C++RAW + +#include "UnityPrefix.h" +#include "Configuration/UnityConfigure.h" +#include "Runtime/Scripting/ScriptingManager.h" +#include "Runtime/Scripting/ScriptingExportUtility.h" + +#if UNITY_WEBPLAYER +#include "PlatformDependent/CommonWebPlayer/ChainOfTrust.h" +#endif + +CSRAW +using System; +using System.Security; + +namespace UnityEngine +{ +CSRAW #if !UNITY_WINRT + // Webplayer security related class. + CLASS Security + + // Prefetch the webplayer socket security policy from a non-default port number. + CSRAW static public bool PrefetchSocketPolicy(string ip, int atPort, int timeout=3000) + { + #if UNITY_EDITOR || UNITY_WEBPLAYER + var method = GetUnityCrossDomainHelperMethod("PrefetchSocketPolicy"); + var result = method.Invoke(null, new object[] { ip, atPort, timeout}); + return (bool)result; + #else + return true; + #endif + } + + CONDITIONAL UNITY_WEBPLAYER || UNITY_EDITOR + CSRAW + [System.Security.SecuritySafeCritical] + public static string GetChainOfTrustValue (string name) + { + var callingAssembly = System.Reflection.Assembly.GetCallingAssembly (); + if (!_verifiedAssemblies.Contains(callingAssembly)) + throw new ArgumentException("Calling assembly needs to be verified by Security.LoadAndVerifyAssembly"); + + var token = callingAssembly.GetName ().GetPublicKeyToken (); + + return GetChainOfTrustValueInternal (name, UnityEngine.Security.TokenToHex (token)); + } + + CONDITIONAL UNITY_WEBPLAYER || UNITY_EDITOR + CUSTOM private static string GetChainOfTrustValueInternal (string name, string publicKeyToken) + { + #if UNITY_WEBPLAYER + std::string token = publicKeyToken.AsUTF8 (); + std::string result = ChainOfTrust::GetValue(name,token); + return scripting_string_new(result); + #else + return scripting_string_new(string()); + #endif + } + END +CSRAW #endif +} |