// 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 RopOpSign op_sign_create(RopInput input, RopOutput output, bool cleartext = false, bool detached = false, int tag = 0) { int ret = ROPE.RNP_SUCCESS; RopHandle inp = (input != null? input.getHandle() : RopHandle.Null); RopHandle outp = (output != null? output.getHandle() : RopHandle.Null); RopHandle op = null; if (cleartext) { ret = (int)lib.rnp_op_sign_cleartext_create(out op, sid, inp, outp); } else if (detached) { ret = (int)lib.rnp_op_sign_detached_create(out op, sid, inp, outp); } else { ret = (int)lib.rnp_op_sign_create(out op, sid, inp, outp); } if (own.TryGetTarget(out RopBind bind)) { RopOpSign sign = new RopOpSign(bind, Util.PopHandle(lib, op, ret)); bind.PutObj(sign, tag); return(sign); } throw new RopError(RopBind.ROP_ERROR_INTERNAL); }
public void export_revocation(RopOutput output, string hash, string code, string reason) { RopHandle outp = (output != null? output.getHandle() : RopHandle.Null); int ret = (int)lib.rnp_key_export_revocation(kid, outp, 0, hash, code, reason); Util.Return(ret); }
public static RopHandle PopHandle(RopLib rop, RopHandle val, int err) { if (err != ROPE.RNP_SUCCESS) { throw new RopError(err); } return(val); }
public void decrypt(RopInput input, RopOutput output) { RopHandle inp = (input != null? input.getHandle() : RopHandle.Null); RopHandle outp = (output != null? output.getHandle() : RopHandle.Null); int ret = (int)lib.rnp_decrypt(sid, inp, outp); Util.Return(ret); }
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); }
internal RopData(RopBind own, RopHandle hnd, long dataLen) { this.lib = own.getLib(); this.hnd = hnd; this.dataLen = dataLen; this.sdata = null; this.bdata = null; }
internal void Attach(RopHandle iid) { if (iid.IsNull()) { throw new RopError(RopBind.ROP_ERROR_NULL_HANDLE); } this.iid = iid; }
internal RopIdIterator(RopBind own, RopHandle iiid) { if (iiid.IsNull()) { throw new RopError(RopBind.ROP_ERROR_NULL_HANDLE); } this.lib = own.getLib(); this.iiid = iiid; }
public RopSignSignature(RopBind own, RopHandle sgid) { if (sgid.IsNull()) { throw new RopError(RopBind.ROP_ERROR_NULL_HANDLE); } this.lib = own.getLib(); this.sgid = sgid; }
internal RopSymEnc(RopBind own, RopHandle seid) { if (seid.IsNull()) { throw new RopError(RopBind.ROP_ERROR_NULL_HANDLE); } this.own = new WeakReference <RopBind>(own); this.lib = own.getLib(); this.seid = seid; }
public void load_keys(string format, RopInput input, bool pub = true, bool sec = true) { RopHandle inp = (input != null? input.getHandle() : RopHandle.Null); int flags = (pub? ROPD.RNP_LOAD_SAVE_PUBLIC_KEYS : 0); flags |= (sec? ROPD.RNP_LOAD_SAVE_SECRET_KEYS : 0); int ret = (int)lib.rnp_load_keys(sid, format, inp, (uint)flags); Util.Return(ret); }
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 RopVeriSignature(RopBind own, RopHandle sgid) { if (sgid.IsNull()) { throw new RopError(RopBind.ROP_ERROR_NULL_HANDLE); } this.own = new WeakReference <RopBind>(own); this.lib = own.getLib(); this.sgid = sgid; }
internal RopOpEncrypt(RopBind own, RopHandle opid) { if (opid.IsNull()) { throw new RopError(RopBind.ROP_ERROR_NULL_HANDLE); } this.own = new WeakReference <RopBind>(own); this.lib = own.getLib(); this.opid = opid; }
internal RopRecipient(RopBind own, RopHandle rid) { if (rid.IsNull()) { throw new RopError(RopBind.ROP_ERROR_NULL_HANDLE); } this.own = new WeakReference <RopBind>(own); this.lib = own.getLib(); this.rid = rid; }
public void save_keys(string format, RopOutput output, bool pub = true, bool sec = true) { RopHandle outp = (output != null? output.getHandle() : RopHandle.Null); int flags = (pub? ROPD.RNP_LOAD_SAVE_PUBLIC_KEYS : 0); flags |= (sec? ROPD.RNP_LOAD_SAVE_SECRET_KEYS : 0); int ret = (int)lib.rnp_save_keys(sid, format, outp, (uint)flags); Util.Return(ret); }
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); }
internal RopInput(RopBind own, RopHandle iid) { if (iid.IsNull()) { throw new RopError(RopBind.ROP_ERROR_NULL_HANDLE); } this.own = new WeakReference <RopBind>(own); this.lib = own.getLib(); this.iid = iid; this.inputCB = null; }
public bool OutputWriteCallBack(object ctx, RopHandle buf, long len) { if (outputCB != null && buf != null && len > 0) { if (own.TryGetTarget(out RopBind bind)) { return(outputCB.WriteCallBack(ctx, new RopData(bind, buf, len))); } throw new RopError(RopBind.ROP_ERROR_INTERNAL); } return(false); }
public void export(RopOutput output, bool pub = true, bool sec = true, bool subkey = false, bool armored = false) { RopHandle outp = (output != null? output.getHandle() : RopHandle.Null); int flags = (pub? ROPD.RNP_KEY_EXPORT_PUBLIC : 0); flags |= (sec? ROPD.RNP_KEY_EXPORT_SECRET : 0); flags |= (subkey? ROPD.RNP_KEY_EXPORT_SUBKEYS : 0); flags |= (armored? ROPD.RNP_KEY_EXPORT_ARMORED : 0); int ret = (int)lib.rnp_key_export(kid, outp, (uint)flags); Util.Return(ret); }
internal RopSession(RopBind own, RopHandle sid) { if (sid.IsNull()) { throw new RopError(RopBind.ROP_ERROR_NULL_HANDLE); } this.own = new WeakReference <RopBind>(own); this.lib = own.getLib(); this.sid = sid; this.passProvider = null; this.keyProvider = null; }
public RopData import_signatures(RopInput input) { RopHandle inp = (input != null? input.getHandle() : RopHandle.Null); int ret = (int)lib.rnp_import_signatures(sid, inp, 0, out RopHandle hnd); if (own.TryGetTarget(out RopBind bind)) { RopData data = new RopData(bind, Util.PopHandle(lib, hnd, ret), 0); bind.PutObj(data, 0); return(data); } throw new RopError(RopBind.ROP_ERROR_INTERNAL); }
/** * @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); }
public RopOpEncrypt op_encrypt_create(RopInput input, RopOutput output, int tag = 0) { RopHandle inp = (input != null? input.getHandle() : RopHandle.Null); RopHandle outp = (output != null? output.getHandle() : RopHandle.Null); int ret = (int)lib.rnp_op_encrypt_create(out RopHandle op, sid, inp, outp); if (own.TryGetTarget(out RopBind bind)) { RopOpEncrypt ope = new RopOpEncrypt(bind, Util.PopHandle(lib, op, ret)); bind.PutObj(ope, tag); return(ope); } throw new RopError(RopBind.ROP_ERROR_INTERNAL); }
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); }
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); }
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); }
// 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(); } } } }
public RopData import_keys(RopInput input, bool pub = true, bool sec = true, bool perm = false, bool sngl = false) { RopHandle inp = (input != null? input.getHandle() : RopHandle.Null); int flags = (pub? ROPD.RNP_LOAD_SAVE_PUBLIC_KEYS : 0); flags |= (sec? ROPD.RNP_LOAD_SAVE_SECRET_KEYS : 0); flags |= (perm? ROPD.RNP_LOAD_SAVE_PERMISSIVE : 0); flags |= (sngl? ROPD.RNP_LOAD_SAVE_SINGLE : 0); int ret = (int)lib.rnp_import_keys(sid, inp, (uint)flags, out RopHandle hnd); if (own.TryGetTarget(out RopBind bind)) { hnd = Util.PopHandle(lib, hnd, ret != ROPE.RNP_ERROR_EOF? ret : ROPE.RNP_SUCCESS); if (ret != ROPE.RNP_ERROR_EOF) { RopData data = new RopData(bind, hnd, 0); bind.PutObj(data, 0); return(data); } return(null); } throw new RopError(RopBind.ROP_ERROR_INTERNAL); }