On Tuesday, 6 February 2018 at 20:55:31 UTC, Adam D. Ruppe wrote:
On Tuesday, 6 February 2018 at 20:25:22 UTC, Ralph Doncaster wrote:
The opencl package in dub is a crude wrapper around the original C API. I couldn't find any sha lib, so I've started porting a reference sha3 implementation from C.

Don't port libraries like that, just call them directly. Porting crypto stuff is just asking for bugs and there's fairly little benefit over just calling them.

Is there an automatic way to make D wrappers for all the C function calls?

There's also the problem that the test code for the C/C++ libraries would have to be wrapped up into the library or ported to D.

Although I'm new to D, I do know crypto quite well, and especially sha3/keccak. One reason I considered porting was to see if dmd outputs better code than gcc. On x86_64 with the xmm registers there is enough room for 1600 bits of the keccak state to be stored in registers, but gcc 5.4 will still use RAM for the state. It stays in L1, but storing all the state in registers should be much faster as it would avoid a lot of mov instructions loading parts of the state into registers.

Reply via email to