From: Dongsun Lee Date: Mon, 4 Sep 2017 01:56:22 +0000 (+0900) Subject: [Tizen::Security::TEEC] Deliver UUID value to native API X-Git-Tag: preview1-00258~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F96%2F147296%2F2;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Tizen::Security::TEEC] Deliver UUID value to native API Change-Id: I28ff2087d089b40e5756bc8e435ffd27c486dd6e Signed-off-by: Dongsun Lee --- diff --git a/src/Tizen.Security.TEEC/Interop/Interop.Libteec.cs b/src/Tizen.Security.TEEC/Interop/Interop.Libteec.cs index 9680956..3700b90 100644 --- a/src/Tizen.Security.TEEC/Interop/Interop.Libteec.cs +++ b/src/Tizen.Security.TEEC/Interop/Interop.Libteec.cs @@ -91,7 +91,7 @@ internal static partial class Interop /// //TEEC_Result TEEC_OpenSession(TEEC_Context *context, TEEC_Session *session, const TEEC_UUID *destination, uint connectionMethod, const void *connectionData, TEEC_Operation *operation, uint *returnOrigin); [DllImport(Libraries.Libteec, EntryPoint = "TEEC_OpenSession", CallingConvention = CallingConvention.Cdecl)] - static public extern int OpenSession(ref TEEC_Context context, ref TEEC_Session session, TEEC_UUID destination, uint connectionMethod, byte[] connectionData, ref TEEC_Operation operation, out uint returnOrigin); + static public extern int OpenSession(ref TEEC_Context context, ref TEEC_Session session, ref TEEC_UUID destination, uint connectionMethod, byte[] connectionData, ref TEEC_Operation operation, out uint returnOrigin); /// /// This function closes a session which has been opened with a trusted application. diff --git a/src/Tizen.Security.TEEC/Interop/Interop.Types.cs b/src/Tizen.Security.TEEC/Interop/Interop.Types.cs index 75955d1..86432d3 100644 --- a/src/Tizen.Security.TEEC/Interop/Interop.Types.cs +++ b/src/Tizen.Security.TEEC/Interop/Interop.Types.cs @@ -16,6 +16,8 @@ using System; +using System.IO; +using System.Text; using System.Runtime.InteropServices; internal static partial class Interop @@ -40,6 +42,18 @@ internal static partial class Interop public UInt16 timeHiAndVersion; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] clockSeqAndNode; + + internal static TEEC_UUID ToTeecUuid(Guid guid) + { + TEEC_UUID uuid = new TEEC_UUID(); + byte[] bin = guid.ToByteArray(); + uuid.timeLow = BitConverter.ToUInt32(bin, 0); + uuid.timeMid = BitConverter.ToUInt16(bin, 4); + uuid.timeHiAndVersion = BitConverter.ToUInt16(bin, 6); + uuid.clockSeqAndNode = new byte[8]; + Array.Copy(bin, 8, uuid.clockSeqAndNode, 0, 8); + return uuid; + } } [StructLayout(LayoutKind.Sequential)] diff --git a/src/Tizen.Security.TEEC/Tizen.Security.TEEC/Libteec.cs b/src/Tizen.Security.TEEC/Tizen.Security.TEEC/Libteec.cs index 91030d4..8b39e79 100644 --- a/src/Tizen.Security.TEEC/Tizen.Security.TEEC/Libteec.cs +++ b/src/Tizen.Security.TEEC/Tizen.Security.TEEC/Libteec.cs @@ -311,11 +311,11 @@ namespace Tizen.Security.TEEC internal void Open(Guid destination, uint loginMethod, byte[] connectionData, Parameter[] paramlist) { - Interop.TEEC_UUID uuid = new Interop.TEEC_UUID(); + Interop.TEEC_UUID uuid = Interop.TEEC_UUID.ToTeecUuid(destination); Interop.TEEC_Operation op = new Interop.TEEC_Operation(); uint ro; - int ret = Interop.Libteec.OpenSession(ref context, ref session, uuid, loginMethod, connectionData, ref op, out ro); + int ret = Interop.Libteec.OpenSession(ref context, ref session, ref uuid, loginMethod, connectionData, ref op, out ro); //MAYBE map origin of return code to specyfic Exception Interop.CheckNThrowException(ret, string.Format("OpenSession('{0}')", destination)); }