caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Gerd Stolpmann" <info@gerd-stolpmann.de>
To: <oliver@first.in-berlin.de>
Cc: <caml-list@inria.fr>
Subject: Re: [Caml-list] Safe marshall?
Date: Fri, 18 Feb 2005 10:41:11 +0100 (CET)	[thread overview]
Message-ID: <24793.192.168.0.1.1108719671.squirrel@gps.dynxs.de> (raw)
In-Reply-To: <20050218052911.GC425@first.in-berlin.de>


Oliver Bandel said:
> On Thu, Feb 17, 2005 at 03:14:30PM -0800, Eric Stokes wrote:
>> I have to agree with Gerd, if at all possible use a protocol compiler
>> such as XDR, or ASN.1, even signing might not be secure if your
>
> Yes, XDR seems to be a good idea.
>
>
>> attacker can get ahold of the keys you are using. I can attest to the
>> robustness of Gerd's XDR implementation, I have used it in several
>> projects.
>
> Well.. is there already an XDR-binding for OCaml?

Yes, as already pointed out, it is part of my SunRPC implementation:
http://ocaml-programming.de/programming/rpc.html. It is not a binding,
however, but a pure O'Caml implementation.

It is quite easy and obvious how to use the XDR part alone without
the rest of RPC. For example, to define a record with an integer
and a string of maximum 20 characters:

open Xdr
open Rtypes
let my_type_term =
  X_struct [ "my_int", X_int;
             "my_string", (X_string (uint4_of_int 20)) ]
let my_type = validate_xdt_type_term my_type_term

Now, to encode a value:

let my_val =
  XV_struct [ "my_int", (XV_int (int4_of_int 42));
              "my_string", (XV_string "Sample") ]
let my_val_as_wire_string =
  pack_xdr_value_as_string my_val my_type []

my_val_as_wire_string can now be sent over the network. For
decoding, use:

let my_val_again =
  unpack_xdr_value my_val_as_wire_string my_type []

If the string is illegal (e.g. my_string is longer than
20 characters), exceptions will be thrown.

One can also use ocamlrpcgen to generate parts of the above
code, including automatic conversion between XDR and the
corresponding O'Caml types (e.g. an XDR struct is converted
to an O'Caml record type). For complex protocols, the overhead
of learning ocamlrpcgen is worth the effort.

One should also consider using RPC directly rather than to invent
a new networking layer.

Gerd

> Where to find it?!
>
> Ciao,
>   Oliver
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs


------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
------------------------------------------------------------




  reply	other threads:[~2005-02-18  9:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-16 22:07 Mike Hamburg
2005-02-16 22:55 ` [Caml-list] " Oliver Bandel
2005-02-17  0:11   ` Mike Hamburg
2005-02-18  5:26     ` Oliver Bandel
2005-02-17  9:39 ` Gerd Stolpmann
2005-02-17 23:14   ` Eric Stokes
2005-02-18  5:29     ` Oliver Bandel
2005-02-18  9:41       ` Gerd Stolpmann [this message]
2005-02-18 10:10         ` Gerd Stolpmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=24793.192.168.0.1.1108719671.squirrel@gps.dynxs.de \
    --to=info@gerd-stolpmann.de \
    --cc=caml-list@inria.fr \
    --cc=oliver@first.in-berlin.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).