aboutsummaryrefslogtreecommitdiff
path: root/toys/lsb/md5sum.c
AgeCommit message (Collapse)Author
2020-04-08md5sum: don't initialize a table we don't use.Elliott Hughes
If you configure toybox with libcrypto, you don't need toybox to initialize its own table statically _or_ dynamically.
2020-04-07Minor cleanup.Rob Landley
2020-04-07Calculate table when float enabled, and rely on LP64 types.Rob Landley
2020-03-02Work around gcc trying to be "helpful" again.Rob Landley
2019-09-07md5sum: don't allow broken sha-3 sums.Elliott Hughes
If you accidentally configure the sha-3 sums on, but don't enable libcrypto, you'll get toys that just output md5 sums instead. This patch doesn't cause a build-time error (my original plan), but does at least ensure that toybox refuses to include incorrect sha-3 sum implementations.
2019-08-13Return md5sum/sha1sum to the slightly slower but more explicit versionRob Landley
(revert afe951b19c0f with the table of magic constants). If you want speed, there's already a config option to use the libssl version instead.
2018-12-19md5sum/sha1sum: add --status and --check, fix --check with multiple files.Elliott Hughes
Annoyingly coreutils and busybox both have the --status functionality, but coreutils only accepts --status and busybox only accepts -s. Although all extant users known to me use --status I've supported both (a) for maximum compatibility and (b) because Rob hates longopts :-) Also, -c/--check don't take argument(s): they alter the interpretation of all the FILE... arguments. I removed a bunch of dead code here, but I couldn't switch us over to loopfiles_lines because I didn't want to regress on the "warn if any check file contains no hashes", and loopfiles_lines doesn't give you any way to recognize that you've moved on to the next file.
2018-12-04Clean up some --help formatting.Elliott Hughes
Be consistent about upper versus lower case. (Upper seems to have the majority, so I went with that, though I'm happy to provide the opposite patch as long as we're consistent!) Be consistent about using \t. (Though saving a few bytes seems like it might be better done in the code that generates help.h rather than directly in the source, since tabs make careful ASCII art layout hard enough that we regularly have things misaligned.) Remove trailing periods (most of which seem to have been added by me). Always use the US "human readable" rather than my British "human-readable", and be more consistent about declaring whether we're showing multiples of 1000 or 1024. Just say "verbose" rather than adding a useless "mode" or "output".
2017-05-26Be more consistent about periods in help text.Elliott Hughes
2016-07-15Fix non-library md5sum build. (Oops.)Rob Landley
2016-07-15Add optional openssl accelerated versions of hash functions, loosely based onRob Landley
a patch from Elliott Hughes, who said: [PATCH] Add support for libcrypto for MD5/SHA. Orders of magnitude faster (for architectures where OpenSSL/BoringSSL has optimized assembler). Also adds sha224sum, sha256sum, sha384sum, and sha512sum for folks building with libcrypto. The fallback portable C implementations could easily be refactored to be API-compatible, but I don't know whether they'd stay here or move to lib/ so I've left that part alone for now.
2016-07-14Add -c to md5sum and sha1sum.Rob Landley
2014-11-19Make md5sum and sha1sum work on big endian systems.0.5.1Rob Landley
2014-09-26Separate more commands so single.sh can build them standalone.Rob Landley
2014-06-07Make md5sum/sha1sum -b flag be "brief" output (just the hash).Rob Landley
(It's not like systems implementing -b binary and -t text still matter.)
2014-05-15Here's a quick cleanup of md5sum. Executive summary: smaller and faster.Daniel Verkamp
On my machine, for a 2.2 GB file of random bytes, the timings with warm cache are: toybox before: 11.4 seconds toybox after: 8.3 seconds GNU md5sum: 3.9 seconds openssl dgst -md5: 3.5 seconds This is clearly better than before (3x openssl), but still slow (2x openssl). I suspect there is more low-hanging fruit to be had by eliminating the memcpy in hash_update (maybe not too much - hash_update accounts for about 4% of total runtime versus 92% for md5_transform according to perf - but this would also help sha1sum). make bloatcheck on x86_64 gcc 4.8.2 -Os: name old new delta ----------------------------------------------------------------------- md5rot 0 64 64 md5_transform 365 223 -142 ----------------------------------------------------------------------- -78 total Rationale for the changes: Move definition of 'rol' up so it can be used in md5_transform. This is purely cosmetic; it expands to exactly the same code. Put rotation counts in a lookup table instead of calculating them on the fly. This is mostly a wash size-wise, +5 bytes total, but worthwhile for readability and speed. Instead of accessing the state array using a rotating index (the variable formerly known as 'a'), access the state with constant offsets and rotate the contents of the array instead. This is the big win - it eliminates all the crazy memory addressing math inside the loop.
2012-11-13Reindent to two spaces per level. Remove vi: directives that haven't worked ↵Rob Landley
right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style. The actual code should be the same afterward, this is just cosmetic refactoring.
2012-11-03Make sha1sum and md5sum default to y.Rob Landley
2012-10-23Add md5sum in lsb, combine sha1sum (mostly shared infrastructure). Downside: ↵Rob Landley
current infrastructure can't give them different help text. Hmmm...