burgerdev/ocaml-rfc7748

add a key constructor accepting raw bytes

Closed this issue · 1 comments

The current API only accepts hex-encoded strings. Although this is what's specified, there are scenarios where a Bytes.t, Cstruct.t or similar might come in handy.

  • RFC 8422 seems to be using raw bytes:

    For the X25519 and X448 curves, the only valid representation is the
    one specified in [RFC7748], a 32- or 56-octet representation of the u
    value of the point.

Both HACL* and Zarith support Bytes.t, ocaml-tls operates on Cstruct.t [2]. Cstruct.t can be converted to Bigarray.t without copying, but not to Bytes.t. Thus, users that hold a Cstruct.t will always have to copy their data to feed it to the curve backend, so offering a Bytes.t interface should be sufficient.