Exemplo n.º 1
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));
 }
Exemplo n.º 2
0
        public void export_autocrypt(RopKey subkey, string uid, RopOutput output)
        {
            RopHandle subk = (subkey != null? subkey.getHandle() : RopHandle.Null);
            RopHandle outp = (output != null? output.getHandle() : RopHandle.Null);
            int       ret  = (int)lib.rnp_key_export_autocrypt(kid, subk, uid, outp, 0);

            Util.Return(ret);
        }
Exemplo n.º 3
0
        public RopSignSignature add_signature(RopKey key)
        {
            int ret = (int)lib.rnp_op_encrypt_add_signature(opid, key != null? key.getHandle() : null, out RopHandle hnd);

            if (own.TryGetTarget(out RopBind bind))
            {
                return(new RopSignSignature(bind, Util.PopHandle(lib, hnd, ret)));
            }
            throw new RopError(RopBind.ROP_ERROR_INTERNAL);
        }
Exemplo n.º 4
0
 private RopKey PutKey(RopHandle keyHnd, int tag = 0)
 {
     if (own.TryGetTarget(out RopBind bind))
     {
         RopKey key = new RopKey(bind, keyHnd);
         bind.PutObj(key, tag);
         return(key);
     }
     throw new RopError(RopBind.ROP_ERROR_INTERNAL);
 }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public RopKey get_key(int tag = 0)
        {
            int ret = (int)lib.rnp_op_generate_get_key(opid, out RopHandle hnd);

            if (own.TryGetTarget(out RopBind bind))
            {
                RopKey uid = new RopKey(bind, Util.PopHandle(lib, hnd, ret));
                bind.PutObj(uid, tag);
                return(uid);
            }
            throw new RopError(RopBind.ROP_ERROR_INTERNAL);
        }
Exemplo n.º 7
0
        public RopKey get_subkey_at(int idx, int tag = 0)
        {
            int ret = (int)lib.rnp_key_get_subkey_at(kid, (uint)idx, out RopHandle hnd);

            if (own.TryGetTarget(out RopBind bind))
            {
                RopKey key = new RopKey(bind, Util.PopHandle(lib, hnd, ret));
                bind.PutObj(key, tag);
                return(key);
            }
            throw new RopError(RopBind.ROP_ERROR_INTERNAL);
        }
Exemplo n.º 8
0
        public RopKey get_key(int tag = 0)
        {
            int ret = (int)lib.rnp_op_verify_signature_get_key(sgid, out RopHandle hnd);

            if (own.TryGetTarget(out RopBind bind))
            {
                RopKey key = new RopKey(bind, Util.PopHandle(lib, hnd, ret));
                bind.PutObj(key, tag);
                return(key);
            }
            throw new RopError(RopBind.ROP_ERROR_INTERNAL);
        }
Exemplo n.º 9
0
        public RopOpGenerate op_generate_create(string keyAlg, RopKey primary = null, int tag = 0)
        {
            int       ret;
            RopHandle op = null;

            if (primary == null)
            {
                ret = (int)lib.rnp_op_generate_create(out op, sid, keyAlg);
            }
            else
            {
                ret = (int)lib.rnp_op_generate_subkey_create(out op, sid, primary != null? primary.getHandle() : RopHandle.Null, keyAlg);
            }
            if (own.TryGetTarget(out RopBind bind))
            {
                RopOpGenerate opg = new RopOpGenerate(bind, Util.PopHandle(lib, op, ret));
                bind.PutObj(opg, tag);
                return(opg);
            }
            throw new RopError(RopBind.ROP_ERROR_INTERNAL);
        }
Exemplo n.º 10
0
        // API

        public void add_recipient(RopKey key)
        {
            int ret = (int)lib.rnp_op_encrypt_add_recipient(opid, key != null? key.getHandle() : null);

            Util.Return(ret);
        }