コード例 #1
0
ファイル: RopBind.cs プロジェクト: joke325/Dotrop
        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);
        }
コード例 #2
0
        public RopData generate_key_json(RopData json)
        {
            int ret = (int)lib.rnp_generate_key_json(sid, json.getDataObj(), 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);
        }
コード例 #3
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);
        }
コード例 #4
0
        public RopData get_data()
        {
            int  ret = (int)lib.rnp_uid_get_data(huid, out RopHandle hnd, out long size);
            long len = Util.PopLong(lib, size, ret);

            if (own.TryGetTarget(out RopBind bind))
            {
                RopData data = new RopData(bind, Util.PopHandle(lib, hnd, ret), len);
                bind.PutObj(data, 0);
                return(data);
            }
            throw new RopError(RopBind.ROP_ERROR_INTERNAL);
        }
コード例 #5
0
        public RopData secret_key_data()
        {
            int  ret = (int)lib.rnp_get_secret_key_data(kid, out RopHandle hnd, out uint bl);
            long len = Util.PopLong(lib, (long)bl, ret);

            if (own.TryGetTarget(out RopBind bind))
            {
                RopData data = new RopData(bind, Util.PopHandle(lib, hnd, ret), len);
                bind.PutObj(data, 0);
                return(data);
            }
            throw new RopError(RopBind.ROP_ERROR_INTERNAL);
        }
コード例 #6
0
ファイル: RopIO.cs プロジェクト: joke325/Dotrop
        public RopData memory_get_buf(bool doCopy)
        {
            int  ret = (int)lib.rnp_output_memory_get_buf(oid, out RopHandle hnd, out long ln, doCopy);
            long len = Util.PopLong(lib, ln, ret);

            if (own.TryGetTarget(out RopBind bind))
            {
                RopData data = new RopData(bind, Util.PopHandle(lib, hnd, ret), len);
                if (doCopy)
                {
                    bind.PutObj(data, 0);
                }
                return(data);
            }
            throw new RopError(RopBind.ROP_ERROR_INTERNAL);
        }
コード例 #7
0
ファイル: RopIO.cs プロジェクト: joke325/Dotrop
        // API

        public RopData dump_packets_to_json(bool mpi = false, bool raw = false, bool grip = false)
        {
            int flags = (mpi? ROPD.RNP_JSON_DUMP_MPI : 0);

            flags |= (raw? ROPD.RNP_JSON_DUMP_RAW : 0);
            flags |= (grip? ROPD.RNP_JSON_DUMP_GRIP : 0);
            int ret = (int)lib.rnp_dump_packets_to_json(iid, (uint)flags, 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);
        }
コード例 #8
0
        public RopData to_json(bool publicMpis = true, bool secretMpis = true, bool signatures = true, bool signMpis = true)
        {
            int flags = (publicMpis? ROPD.RNP_JSON_PUBLIC_MPIS : 0);

            flags |= (secretMpis? ROPD.RNP_JSON_SECRET_MPIS : 0);
            flags |= (signatures? ROPD.RNP_JSON_SIGNATURES : 0);
            flags |= (signMpis? ROPD.RNP_JSON_SIGNATURE_MPIS : 0);
            int ret = (int)lib.rnp_key_to_json(kid, (uint)flags, out RopHandle js);

            if (own.TryGetTarget(out RopBind bind))
            {
                RopData data = new RopData(bind, Util.PopHandle(lib, js, ret), 0);
                bind.PutObj(data, 0);
                return(data);
            }
            throw new RopError(RopBind.ROP_ERROR_INTERNAL);
        }
コード例 #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);
        }
コード例 #10
0
ファイル: RopIO.cs プロジェクト: joke325/Dotrop
        public long write(RopData data)
        {
            int ret = (int)lib.rnp_output_write(oid, data.getDataObj(), data.getDataLen(), out long wr);

            return(Util.PopLong(lib, wr, ret));
        }
コード例 #11
0
ファイル: RopBind.cs プロジェクト: joke325/Dotrop
        public string detect_key_format(RopData buf)
        {
            int ret = (int)lib.rnp_detect_key_format(buf.getDataObj(), buf.getDataLen(), out RopHandle hnd);

            return(Util.GetRopString(lib, ret, hnd));
        }