thoughtpolice / salt

Fast cryptographic networking for Haskell
http://thoughtpolice.github.com/salt
MIT License
24 stars 1 forks source link

Eliminate glue #11

Open thoughtpolice opened 13 years ago

thoughtpolice commented 13 years ago

It'd be nice if the glue code in cbits could go away. Most of the typical definitions for NaCl functions unfortunately are hidden behind the C preprocessor though, and GHC does not parse .h files, so it depends on you specifying the function's symbol name in the library you're linking to. But we don't know that, because the functions name incorporates build-time settings, i.e. crypto_box_curve25519xsalsa20poly1305 may actually be crypto_box_curve25519xsalsa20poly1305_ref or some other arbitrary string based on CPU identifiers.

It would be awesome if there was a way to extract the #define from the header and use that in the foreign declaration.

thoughtpolice commented 12 years ago

GHC 7.4.1 apparently has some experimental support for something like this, via its (undocumented) CApiFFI extension. I'd rather be able to build it on older compilers for now, though.