Пример #1
0
        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
        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();
             }
         }
     }
 }