|
|
Subscribe / Log in / New account

Van de Ven: Deprecating old crypto

Van de Ven: Deprecating old crypto

Posted Mar 25, 2015 21:46 UTC (Wed) by mathstuf (subscriber, #69389)
In reply to: Van de Ven: Deprecating old crypto by epa
Parent article: Van de Ven: Deprecating old crypto

> Similarly if hashes like MD5 provided two interfaces: make_hash(data) and check_hash(data, expected_hash)

Well, if the interfaces were that easy, maybe people wouldn't have thought they needed to reimplement them in their own projects. Really, the code to get hashes of data out of these things is absurd.


to post comments

Van de Ven: Deprecating old crypto

Posted Mar 25, 2015 23:41 UTC (Wed) by cesarb (subscriber, #6266) [Link] (2 responses)

A "make_hash(data)" interface is useless for streaming data, since it needs the whole data in memory. Good luck trying to hash a 5 GiB file on a 32-bit machine!

The traditional hashing API is pretty simple: an "init" function, an "update" function to be called repeatedly as data arrived, and a "finish" function to be called at the end to finish the computations and return the hash. The code to get a hash out of this API is not "absurd"; in fact, if you have all the data already in memory, it's three straight calls (init, update passing all the data at once, finish).

I can see, however, the value in providing two variants of the "finish" call: one which simply returns the hash, and one which does a constant-time compare with a passed hash. A lot of people forget the "constant-time" part, and it's important!

Van de Ven: Deprecating old crypto

Posted Mar 30, 2015 13:47 UTC (Mon) by mathstuf (subscriber, #69389) [Link] (1 responses)

So the problem isn't just that. The problem is all the crap you have to go through to prep the *library*. NSPR_Init() and that zoo of functions. And then find a way to shut it down properly. If hash_ctx_init(), hash_ctx_update(), and hash_ctx_destroy() were *all* that were necessary, that'd be great. But AFAIK, it isn't (though I admit I haven't looked at OpenSSL *too* much because I'd rather not deal with GPL-incompatibilities).

Van de Ven: Deprecating old crypto

Posted Mar 30, 2015 19:24 UTC (Mon) by dkg (subscriber, #55359) [Link]

If you just want a simple hashing interface without a lot of unnecessary library initialization and shutdown overhead, i recommend looking at nettle. The nettle manual's example code even shows that workflow explicitly.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds