|
Boost : |
Subject: Re: [boost] Message Hashing Interface (SHA-1/256/384/512, MD4/5)
From: Rob Riggs (rob_at_[hidden])
Date: 2010-04-06 23:32:42
On 04/06/2010 10:55 AM, Scott McMurray wrote:
> On 6 April 2010 10:55, Rob Riggs<rob_at_[hidden]> wrote:
>
>> This is also the scheme used by crypto++ (C++), the Perl API, PyCrypto
>> (Python) and openssl (C). I think the Boost crypto hash API should more
>> closely mimic the existing de facto standard interfaces as much as possible.
>>
>>
> Thanks for the references. They're not completely consistent, though.
>
> I do like the idea that digest() be const, since conceptually it's
> just inspecting the result of the previous updates.
>
> Here's a hybrid idea, with definitions to show equivalences:
>
> class hash {
> public:
> void update(byte);
> void reset() { *this = hash(); }
> digest_type digest() const {
> return hash(*this).end_of_message();
> }
> digest_type end_message() {
> digest_type h = digest();
> reset();
> return h;
> }
> };
>
> That way it provides for rolling or message-oriented digests, and
> adapts for the other as best it can if needed.
>
> Is that a reasonable compromise?
>
I like it!
Rob
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk