示例#1
0
 public static extern void MDataInfoDecryptNative(
     IntPtr appPtr,
     ulong mDataInfoH,
     IntPtr cipherText,
     IntPtr cipherLen,
     IntPtr self,
     MDataInfoDecryptCb callback);
示例#2
0
        public static Task <List <byte> > MDataInfoDecryptAsync(ulong mDataInfoH, List <byte> cipherText)
        {
            var tcs       = new TaskCompletionSource <List <byte> >();
            var cipherPtr = cipherText.ToIntPtr();
            var cipherLen = (IntPtr)cipherText.Count;

            MDataInfoDecryptCb callback = null;

            callback = (pVoid, result, plainText, len) => {
                if (result.ErrorCode != 0)
                {
                    tcs.SetException(result.ToException());
                    CallbackManager.Unregister(callback);
                    return;
                }

                var byteList = plainText.ToList <byte>(len);
                tcs.SetResult(byteList);
                CallbackManager.Unregister(callback);
            };

            CallbackManager.Register(callback);
            NativeBindings.MDataInfoDecrypt(Session.AppPtr, mDataInfoH, cipherPtr, cipherLen, Session.UserData, callback);
            Marshal.FreeHGlobal(cipherPtr);

            return(tcs.Task);
        }
示例#3
0
 public void MDataInfoDecrypt(
     IntPtr appPtr,
     ulong mDataInfoH,
     IntPtr cipherText,
     IntPtr cipherLen,
     IntPtr self,
     MDataInfoDecryptCb callback)
 {
     MDataInfoDecryptNative(appPtr, mDataInfoH, cipherText, cipherLen, self, callback);
 }