コード例 #1
0
        public String request_password(RopKey key, object context)
        {
            RopHandle hkey = (key != null? key.getHandle() : RopHandle.Null);
            int       ret  = (int)lib.rnp_request_password(sid, hkey, context, out RopHandle ps);
            RopHandle psw  = Util.PopHandle(lib, ps, ret);
            String    spsw = RopHandle.Str(psw);

            psw.ClearMemory();
            lib.rnp_buffer_destroy(psw);
            return(spsw);
        }
コード例 #2
0
ファイル: RopData.cs プロジェクト: joke325/Dotrop
 /**
  * @return string data
  */
 public string getString()
 {
     if (sdata != null)
     {
         return(sdata);
     }
     if (hnd != null && !hnd.IsNull())
     {
         string str = RopHandle.Str(hnd);
         return(str != null && 0 < dataLen && dataLen < str.Length? str.Substring(0, (int)dataLen) : str);
     }
     return(null);
 }
コード例 #3
0
ファイル: Util.cs プロジェクト: joke325/Dotrop
        public static string GetRopString(RopLib rop, int ret, RopHandle ropStr, bool freeBuf = true)
        {
            string sval = RopHandle.Str(ropStr);

            if (freeBuf)
            {
                rop.rnp_buffer_destroy(ropStr);
            }
            if (ret != ROPE.RNP_SUCCESS)
            {
                throw new RopError(ret);
            }
            return(sval);
        }
コード例 #4
0
ファイル: Util.cs プロジェクト: joke325/Dotrop
 public static string[] GetRopStrings(RopLib rop, int ret, RopHandle[] ropStrs, bool freeBuf = true)
 {
     string[] svals = new string[ropStrs.Length];
     for (int idx = 0; idx < ropStrs.Length; idx++)
     {
         svals[idx] = RopHandle.Str(ropStrs[idx]);
         if (freeBuf)
         {
             rop.rnp_buffer_destroy(ropStrs[idx]);
         }
     }
     if (ret != ROPE.RNP_SUCCESS)
     {
         throw new RopError(ret);
     }
     return(svals);
 }
コード例 #5
0
 // Implements RopKeyCallBack
 public void KeyCallBack(RopHandle ffi, object ctx, RopHandle identifierType, RopHandle identifier, bool secret)
 {
     if (keyProvider != null)
     {
         // create a new Session handler
         RopSession ropSes = null;
         try {
             if (own.TryGetTarget(out RopBind bind))
             {
                 ropSes = (!ffi.IsNull()? new RopSession(bind, ffi) : null);
                 keyProvider.KeyCallBack(ropSes, ctx, RopHandle.Str(identifierType), RopHandle.Str(identifier), secret);
             }
             throw new RopError(RopBind.ROP_ERROR_INTERNAL);
         } catch (RopError) {
         } finally {
             if (ropSes != null)
             {
                 ropSes.Detach();
             }
         }
     }
 }
コード例 #6
0
 // Implements RopPassCallBack
 public RopPassCallBack.Ret PassCallBack(RopHandle ffi, object ctx, RopHandle key, RopHandle pgpCtx, RopHandle buf, int bufLen)
 {
     if (passProvider != null)
     {
         // create new Session and Key handlers
         RopSession ropSes = null;
         RopKey     ropKey = null;
         try {
             if (own.TryGetTarget(out RopBind bind))
             {
                 ropSes = (!ffi.IsNull()? new RopSession(bind, ffi) : null);
                 ropKey = (!key.IsNull()? new RopKey(bind, key) : null);
                 SessionPassCallBack.Ret scbRet = passProvider.PassCallBack(ropSes, ctx, ropKey, RopHandle.Str(pgpCtx), bufLen);
                 return(new RopPassCallBack.Ret(scbRet.ret, scbRet.outBuf));
             }
             throw new RopError(RopBind.ROP_ERROR_INTERNAL);
         } catch (RopError) {
         } finally {
             if (ropSes != null)
             {
                 ropSes.Detach();
             }
             if (ropKey != null)
             {
                 ropKey.Detach();
             }
         }
     }
     return(new RopPassCallBack.Ret(false, null));
 }