On Tue, Feb 06, 2018 at 08:55:31PM +0000, Adam D. Ruppe via Digitalmars-d 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.

Yeah, porting crypto code is usually a bad idea unless you're a crypto
expert.  Careless porting of crypto code is often vulnerable especially
to side-channel attacks due to unexpected interactions with the target
language and/or subtle semantic differences.

D was designed especially to interface with C as painlessly as possible,
so if your chosen crypto library has a C API, the best approach is just
to call it directly.  Wrapping an idiomatic D interface around it is
nice, but I'd still leave the actual implementation to the C library.


Those who don't understand Unix are condemned to reinvent it, poorly.

Reply via email to