예제 #1
0
파일: RopBind.cs 프로젝트: joke325/Dotrop
        public static void Main(string[] args)
        {
            // A trivial test
            try {
                throw new RopError(0);
            } catch (RopError) {
                Console.WriteLine("Starting:");
            }
            RopBind rop = null;

            try {
                rop = new RopBind();
                Console.WriteLine(rop.version_string_full());
                RopSession ses = rop.create_session("GPG", "GPG");
                Console.WriteLine("Session: " + ses.ToString());
                Console.WriteLine("Done.");
            } catch (RopError ex) {
                Console.WriteLine(ex);
            } finally {
                if (rop != null)
                {
                    rop.Close();
                }
            }
        }
예제 #2
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));
 }
예제 #3
0
파일: RopBind.cs 프로젝트: joke325/Dotrop
        public RopSession create_session(string pubFormat, string secFormat, int tag = 0)
        {
            int        ret = (int)lib.rnp_ffi_create(out RopHandle hnd, pubFormat, secFormat);
            RopSession ses = new RopSession(this, Util.PopHandle(lib, hnd, ret));

            PutObj(ses, tag);
            return(ses);
        }
예제 #4
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();
             }
         }
     }
 }