Early std.crypto

Piotr Szturmaj bncrbme at jadamspam.pl
Tue Oct 25 15:40:07 PDT 2011


Walter Bright wrote:
> On 10/24/2011 5:10 PM, Piotr Szturmaj 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 for championing this.
>
> The input to the functions should be a range, not an array (although an
> array is a range).
>
> In general, for Phobos, all arbitrary input data should be in the form
> of ranges, and all arbitrary output data should present itself as a
> range. This facilitates the idea of:
>
> range => algorithm => range
>
> So, for example, I want to encrypt and then zip a file and send the
> output to a socket:
>
> file => encrypt => compress => socket
>
> All the components here will just "snap" together. With the existing
> design of crypto, I'd have to read the file into an array, then pass the
> array to encrypt, etc.
>
> Think of it like the filter concept in Unix that has been so successful.
>

I share your opinion. I was thinking about such filter concept for 
std.crypto.cipher (TBD), but I will also try to convert current hash 
function code to ranges.

Thanks for pointing that out.


More information about the Digitalmars-d mailing list