Early std.crypto
Martin Nowak
dawg at dawgfoto.de
Mon Oct 24 20:46:43 PDT 2011
On Tue, 25 Oct 2011 02:10:49 +0200, Piotr Szturmaj <bncrbme at jadamspam.pl>
wrote:
> https://github.com/pszturmaj/phobos/tree/master/std/crypto
>
> This is some early work on std.crypto proposal. Currently only MD5, HMAC
> and all SHA family functions (excluding SHA0 which is very old, broken
> and no longer in use). I plan to add other crypto primitives later.
>
> I know about one SHA1 pull request optimized for SSSE3. I think native
> code must be there to support other non x86 CPUs and SIMD optimization
> may be added at any time later.
>
> Any opinions are welcome. Especially if such design is good or bad, and
> what needs to be changed.
>
> Thanks :)
Great to push this a little.
I have to say though that I like the current struct based interface
much better.
struct Hash
{
// enhanced by some compile time traits
enum hashLength = 16;
enum blockLength = 0;
// three interface functions
void start();
void update(const(ubyte)[] data);
void finish(ref ubyte[hashLength] digest);
}
You wouldn't need the save, restore functions.
Some unnecessary allocations could go away.
Most important instances would have less mutable state.
You could probably parameterize a Merkle Damgård base with free
functions for the transformation.
A dynamic interface can be obtaines by templated instances similar to what
std.range does.
More information about the Digitalmars-d
mailing list