// 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)); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
// 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); }