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 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.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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);
        }