After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 602715 - [GChecksum] Please add support for SHA512
[GChecksum] Please add support for SHA512
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.22.x
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2009-11-23 11:35 UTC by Julian Andres Klode
Modified: 2012-11-22 03:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add SHA512 support in GChecksum (36.65 KB, patch)
2012-11-16 17:31 UTC, Eduardo Lima Mitev
reviewed Details | Review
Adds SHA512 and SHA384 support in GChecksum (57.48 KB, patch)
2012-11-16 19:07 UTC, Eduardo Lima Mitev
reviewed Details | Review

Description Julian Andres Klode 2009-11-23 11:35:44 UTC
I would like to see support for SHA512 in GLib. The beecrypt project has a LGPL-2.1+ version which could probably be used as the base:

http://beecrypt.cvs.sourceforge.net/viewvc/beecrypt/beecrypt/sha512.c?view=markup
Comment 1 Eduardo Lima Mitev 2012-11-16 17:31:09 UTC
Created attachment 229172 [details] [review]
Add SHA512 support in GChecksum

This patch implements SHA512 in GChecksum, following FIPS-180-2 standard <http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf>. Proper unit tests included.

Better late than never :)

I think we should also add SHA384 support after landing this. It shares a lot of code with the SHA512 implmentation.
Comment 2 Emmanuele Bassi (:ebassi) 2012-11-16 17:45:46 UTC
Review of attachment 229172 [details] [review]:

looks generally okay to me. if you want to add SHA-384, you probably want to do so within this cycle, to keep the GChecksumType ordered (a minor nitpick, I know). I am not entirely sure it's worth adding it, though: I am not aware of anything using the truncated versions of SHA-2.
Comment 3 Eduardo Lima Mitev 2012-11-16 18:01:06 UTC
Thanks for reviewing so quickly.

I'm not aware either of anything using SHA384, but I thought it could be added for the sake of completeness and, as you said, maintaining GChecksumType order.

I don't particularly need SHA384 but I'm willing to implement it now if it helps landing SHA512 (which I do need).
Comment 4 Dan Winship 2012-11-16 18:18:38 UTC
you could just leave a hole in the enum so it could be filled in later if someone needed it
Comment 5 Eduardo Lima Mitev 2012-11-16 19:07:47 UTC
Created attachment 229177 [details] [review]
Adds SHA512 and SHA384 support in GChecksum

This is a new patch adding both SHA-512 and SHA384. It is basically the previous patch with a few lines of SHA-384 specific bits, and the corresponding SHA-384 test cases.

I didn't mark previous patch as obsolete because I'm ok with merging any of the two. I do think though, that we should take the opportunity and include SHA-384 now that it is done, and being so few code on top of SHA-512. I prefer this to adding a placeholder in the enum.

BTW, if you are curious, I used sha512sum <http://linux.die.net/man/1/sha512sum> and sha384sum <http://linux.die.net/man/1/sha384sum> commands to generate the expected results of tests.
Comment 6 Eduardo Lima Mitev 2012-11-20 18:07:27 UTC
Does somebody think is worth reviewing my second patch, or should I go ahead and merge the first one (maybe adding the placeholder in the enum as Dan suggested) ?
Comment 7 Emmanuele Bassi (:ebassi) 2012-11-20 18:42:43 UTC
Review of attachment 229177 [details] [review]:

yeah, I don't think SHA-384 is worth the aggravation, even if the patch looks simple enough. we don't have the SHA-224 short form either, and it has never been raised as an issue.

if you really, *really* want all the spectrum of crypto-level hashing, then I have a copy of NSS to sell you anyway.

I'd say to go with SHA-512, i.e. your first patch - but before committing it let's wait for another opinion at least.
Comment 8 Dan Winship 2012-11-20 19:06:34 UTC
I don't have a strong opinion, other than the standard "well, are there any glib-using apps using SHA-384?"
Comment 9 Eduardo Lima Mitev 2012-11-20 19:44:32 UTC
I doubt there is, otherwise I would expect to see a bug similar to this one requesting SHA-384 support.

I can merge the first patch then (SHA-512 only). Emmanuele, what about the enum, shall we make room for an eventual SHA-384? I guess not. There is no placeholder for SHA-224 either, so...

Thanks for your help guys.
Comment 10 Eduardo Lima Mitev 2012-11-21 19:21:48 UTC
I tried to merge but don't have commit access to glib module. Can someone with right permissions help me merge patch from comment 1?

Thanks
Comment 11 Julian Andres Klode 2012-11-21 21:00:12 UTC
Pushed as 6e2046207a2fe1c013bbf348b87d54a1375dea7a

commit 6e2046207a2fe1c013bbf348b87d54a1375dea7a
Author: Eduardo Lima Mitev <elima@igalia.com>
Date:   Fri Nov 16 18:20:09 2012 +0100

    gchecksum: Adds SHA512 support
    
    https://bugzilla.gnome.org/show_bug.cgi?id=602715
Comment 12 Mathias Hasselmann (IRC: tbf) 2012-11-22 03:26:30 UTC
why you should use sha-384 instead of 512 or 256:
https://plus.google.com/114471118004229223857/posts/hzoUxXhhkBf