Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public RopInput create_input(RopData buf, bool doCopy, int tag = 0)
        {
            int      ret = (int)lib.rnp_input_from_memory(out RopHandle hnd, buf.getDataObj(), (uint)buf.getDataLen(), doCopy);
            RopInput inp = new RopInput(this, Util.PopHandle(lib, hnd, ret));

            PutObj(inp, tag);
            return(inp);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public RopInput create_input(String path, int tag = 0)
        {
            int      ret = (int)lib.rnp_input_from_path(out RopHandle hnd, path);
            RopInput inp = new RopInput(this, Util.PopHandle(lib, hnd, ret));

            PutObj(inp, tag);
            return(inp);
        }
Exemplo n.º 5
0
        public RopInput create_input(InputCallBack inputCB, object app_ctx, int tag = 0)
        {
            RopInput inp = new RopInput(this, inputCB);
            int      ret = (int)lib.rnp_input_from_callback(out RopHandle hnd, inp, app_ctx);

            inp.Attach(Util.PopHandle(lib, hnd, ret));
            PutObj(inp, tag);
            return(inp);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        public RopOpVerify op_verify_create(RopInput input, RopOutput output, RopInput signature = null, int tag = 0)
        {
            RopHandle inp = (input != null? input.getHandle() : RopHandle.Null);
            int       ret;
            RopHandle op = null;

            if (signature == null)
            {
                RopHandle outp = (output != null? output.getHandle() : RopHandle.Null);
                ret = (int)lib.rnp_op_verify_create(out op, sid, inp, outp);
            }
            else
            {
                RopHandle sig = (signature != null? signature.getHandle() : RopHandle.Null);
                ret = (int)lib.rnp_op_verify_detached_create(out op, sid, inp, sig);
            }
            if (own.TryGetTarget(out RopBind bind))
            {
                RopOpVerify opv = new RopOpVerify(bind, Util.PopHandle(lib, op, ret));
                bind.PutObj(opv, tag);
                return(opv);
            }
            throw new RopError(RopBind.ROP_ERROR_INTERNAL);
        }
Exemplo n.º 11
0
 public RopData import_keys_single(RopInput input, bool pub = true, bool sec = true, bool perm = false)
 {
     return(import_keys(input, pub, sec, perm, true));
 }
Exemplo n.º 12
0
 public RopData import_keys_secret(RopInput input, bool perm = false, bool sngl = false)
 {
     return(import_keys(input, false, true, perm, sngl));
 }
Exemplo n.º 13
0
 public void load_keys_secret(String format, RopInput input)
 {
     load_keys(format, input, false, true);
 }
Exemplo n.º 14
0
 public void load_keys_public(String format, RopInput input)
 {
     load_keys(format, input, true, false);
 }
Exemplo n.º 15
0
 public RopOpVerify op_verify_create(RopInput input, RopInput signature)
 {
     return(op_verify_create(input, null, signature));
 }
Exemplo n.º 16
0
 public RopOpSign op_sign_create_detached(RopInput input, RopOutput output)
 {
     return(op_sign_create(input, output, false, true));
 }
Exemplo n.º 17
0
 public RopOpSign op_sign_create_cleartext(RopInput input, RopOutput output)
 {
     return(op_sign_create(input, output, true, false));
 }