Crypto, deimos, and ares

kris foo at bar.com
Thu Mar 23 16:20:02 PST 2006


Regan Heath wrote:
> On Thu, 23 Mar 2006 15:15:03 -0800, kris <foo at bar.com> wrote:
> 
>> Sean Kelly wrote:
>>
>>> Regan Heath wrote:
>>>
>>>> You might be interested in some existing crypto work I've done:
>>>>   http://svn.dsource.org/projects/deimos/trunk/etc/crypto/hash/
>>>>
>>>> The library "deimos" never really got off the ground, I think it 
>>>> may  be tome to salvage what can be salvaged from deimos and put it  
>>>> somewhere else, perhaps in "Ares", Shaun? If the crypto stuff is  
>>>> unsuitable for any reason let me know and I can re-work it.
>>>
>>>   That's a bit past the level of what I've been focusing on, but 
>>> it's  certainly a candidate for eventual inclusion.
>>>   Sean
>>
>>
>> I've seriously considered adding a crypto package to Mango; 
>> particularly  in support of network-oriented apps (MD4, MD5, SHA1, 
>> some SSL support,  and so on). Perhaps that might be a reasonable home 
>> for the time being?
>>
>> Should only need support for void[], right?
> 
> 
> (this is essentially a reply to everyone on this thread)
> 
> Yes, I believe so.
> 
> Kris you're welcome to place the crypto code I wrote into Mango. I 
> believe  I put a BSD stlye license on it, let me know if that is a problem.
> 
> The interface I used is essentially the same as the std.md5 one in phobos.
> 
> It's all done with structs and mixins (which essentially emulates class  
> inheritance). The reason I used structs was to make it easy to 
> copy/store  a hash state i.e. you just assign one MD5 to another and it 
> copies the  context data. Not sure if that is a good enough reason now, 
> perhaps  classes with dup methods would be better.
> 
> Essentially there are some basic methods:
> 
>   void start();
>   void update(void[] input);
>   void finish(T digest);
>   void sum(T digest, void[] input);
> 
> which are mixed into the real implementation.
> 
> The idea behind these methods is that you can call "sum" if you have 
> all  the data at once (sum calls the other 3, meaning you cannot mix it 
> with  calls to the other), or you can call start, then update any number 
> of  times, and finally finish. The latter 3 methods make it easy to 
> integrate  with a stream, for example.
> 
> Each real implementation defines a trasform method in the form:
> 
>   void transform(ubyte[] input);
> 
> which is called by the mixed methods to process the data, in addition 
> the  following methods:
> 
>   void padMessage(ubyte[] at);
>   void padLength(ubyte[] at, ulong length);
> 
> are called to perform the padding, and:
> 
>   void extend();
> 
> was required to handle MD2 being a little different to the others.
> 
> This design pattern and interface works for: MD2, MD4, MD5, SHA0, SHA1,  
> SHA256, SHA512, and Tiger. Does it work for blowfish as well? What does  
> the .NET API look like?
> 
> Regan

That all sounds great (though I'll admit to being more than a bit leery 
of D mixins). I'll take a look at the license, and get back to you via 
the Deimos forum?

- Kris



More information about the Digitalmars-d-announce mailing list