diff options
author | Lauri Kasanen <curaga@operamail.com> | 2013-01-14 05:20:50 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-01-14 05:20:50 +0100 |
commit | b8173b603f57dcf918a67f1ec00763ab5f4e1cf8 (patch) | |
tree | 726549290ba408cf68561c4c1c2d591a80ded319 /coreutils | |
parent | b7841cf7b919b16d1bd4619154bf7cb4c22b4ccd (diff) | |
download | busybox-w32-b8173b603f57dcf918a67f1ec00763ab5f4e1cf8.tar.gz busybox-w32-b8173b603f57dcf918a67f1ec00763ab5f4e1cf8.tar.bz2 busybox-w32-b8173b603f57dcf918a67f1ec00763ab5f4e1cf8.zip |
sha3sum: new applet
function old new delta
KeccakF - 496 +496
KeccakF_RoundConstants - 192 +192
sha3_hash - 171 +171
sha3_end - 40 +40
hash_file 274 299 +25
KeccakF_RotationConstants - 25 +25
KeccakF_PiLane - 25 +25
packed_usage 29213 29232 +19
sha3_begin - 18 +18
KeccakF_Mod5 - 10 +10
applet_names 2445 2453 +8
applet_main 1420 1424 +4
applet_nameofs 710 712 +2
------------------------------------------------------------------------------
(add/remove: 8/0 grow/shrink: 9/7 up/down: 1049/-54) Total: ~995 bytes
Signed-off-by: Lauri Kasanen <curaga@operamail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/Config.src | 12 | ||||
-rw-r--r-- | coreutils/Kbuild.src | 1 | ||||
-rw-r--r-- | coreutils/md5_sha1_sum.c | 17 |
3 files changed, 27 insertions, 3 deletions
diff --git a/coreutils/Config.src b/coreutils/Config.src index a28449b11..0c44c4b51 100644 --- a/coreutils/Config.src +++ b/coreutils/Config.src | |||
@@ -514,6 +514,12 @@ config SHA512SUM | |||
514 | help | 514 | help |
515 | Compute and check SHA512 message digest | 515 | Compute and check SHA512 message digest |
516 | 516 | ||
517 | config SHA3SUM | ||
518 | bool "sha3sum" | ||
519 | default y | ||
520 | help | ||
521 | Compute and check SHA3 (512-bit) message digest | ||
522 | |||
517 | config SLEEP | 523 | config SLEEP |
518 | bool "sleep" | 524 | bool "sleep" |
519 | default y | 525 | default y |
@@ -766,13 +772,13 @@ config FEATURE_HUMAN_READABLE | |||
766 | help | 772 | help |
767 | Allow df, du, and ls to have human readable output. | 773 | Allow df, du, and ls to have human readable output. |
768 | 774 | ||
769 | comment "Common options for md5sum, sha1sum, sha256sum, sha512sum" | 775 | comment "Common options for md5sum, sha1sum, sha256sum, sha512sum, sha3sum" |
770 | depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM | 776 | depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM || SHA3SUM |
771 | 777 | ||
772 | config FEATURE_MD5_SHA1_SUM_CHECK | 778 | config FEATURE_MD5_SHA1_SUM_CHECK |
773 | bool "Enable -c, -s and -w options" | 779 | bool "Enable -c, -s and -w options" |
774 | default y | 780 | default y |
775 | depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM | 781 | depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM || SHA3SUM |
776 | help | 782 | help |
777 | Enabling the -c options allows files to be checked | 783 | Enabling the -c options allows files to be checked |
778 | against pre-calculated hash values. | 784 | against pre-calculated hash values. |
diff --git a/coreutils/Kbuild.src b/coreutils/Kbuild.src index d6453f014..b715b9c47 100644 --- a/coreutils/Kbuild.src +++ b/coreutils/Kbuild.src | |||
@@ -62,6 +62,7 @@ lib-$(CONFIG_SEQ) += seq.o | |||
62 | lib-$(CONFIG_SHA1SUM) += md5_sha1_sum.o | 62 | lib-$(CONFIG_SHA1SUM) += md5_sha1_sum.o |
63 | lib-$(CONFIG_SHA256SUM) += md5_sha1_sum.o | 63 | lib-$(CONFIG_SHA256SUM) += md5_sha1_sum.o |
64 | lib-$(CONFIG_SHA512SUM) += md5_sha1_sum.o | 64 | lib-$(CONFIG_SHA512SUM) += md5_sha1_sum.o |
65 | lib-$(CONFIG_SHA3SUM) += md5_sha1_sum.o | ||
65 | lib-$(CONFIG_SLEEP) += sleep.o | 66 | lib-$(CONFIG_SLEEP) += sleep.o |
66 | lib-$(CONFIG_SPLIT) += split.o | 67 | lib-$(CONFIG_SPLIT) += split.o |
67 | lib-$(CONFIG_SORT) += sort.o | 68 | lib-$(CONFIG_SORT) += sort.o |
diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c index 59b520fce..92a4d4462 100644 --- a/coreutils/md5_sha1_sum.c +++ b/coreutils/md5_sha1_sum.c | |||
@@ -55,6 +55,16 @@ | |||
55 | //usage: "\n -s Don't output anything, status code shows success" | 55 | //usage: "\n -s Don't output anything, status code shows success" |
56 | //usage: "\n -w Warn about improperly formatted checksum lines" | 56 | //usage: "\n -w Warn about improperly formatted checksum lines" |
57 | //usage: ) | 57 | //usage: ) |
58 | //usage: | ||
59 | //usage:#define sha3sum_trivial_usage | ||
60 | //usage: IF_FEATURE_MD5_SHA1_SUM_CHECK("[-c[sw]] ")"[FILE]..." | ||
61 | //usage:#define sha3sum_full_usage "\n\n" | ||
62 | //usage: "Print" IF_FEATURE_MD5_SHA1_SUM_CHECK(" or check") " SHA3-512 checksums" | ||
63 | //usage: IF_FEATURE_MD5_SHA1_SUM_CHECK( "\n" | ||
64 | //usage: "\n -c Check sums against list in FILEs" | ||
65 | //usage: "\n -s Don't output anything, status code shows success" | ||
66 | //usage: "\n -w Warn about improperly formatted checksum lines" | ||
67 | //usage: ) | ||
58 | 68 | ||
59 | #include "libbb.h" | 69 | #include "libbb.h" |
60 | 70 | ||
@@ -65,6 +75,7 @@ enum { | |||
65 | HASH_MD5 = 's', /* "md5>s<um" */ | 75 | HASH_MD5 = 's', /* "md5>s<um" */ |
66 | HASH_SHA1 = '1', | 76 | HASH_SHA1 = '1', |
67 | HASH_SHA256 = '2', | 77 | HASH_SHA256 = '2', |
78 | HASH_SHA3 = '3', | ||
68 | HASH_SHA512 = '5', | 79 | HASH_SHA512 = '5', |
69 | }; | 80 | }; |
70 | 81 | ||
@@ -86,6 +97,7 @@ static uint8_t *hash_file(const char *filename) | |||
86 | { | 97 | { |
87 | int src_fd, hash_len, count; | 98 | int src_fd, hash_len, count; |
88 | union _ctx_ { | 99 | union _ctx_ { |
100 | sha3_ctx_t sha3; | ||
89 | sha512_ctx_t sha512; | 101 | sha512_ctx_t sha512; |
90 | sha256_ctx_t sha256; | 102 | sha256_ctx_t sha256; |
91 | sha1_ctx_t sha1; | 103 | sha1_ctx_t sha1; |
@@ -124,6 +136,11 @@ static uint8_t *hash_file(const char *filename) | |||
124 | update = (void*)sha512_hash; | 136 | update = (void*)sha512_hash; |
125 | final = (void*)sha512_end; | 137 | final = (void*)sha512_end; |
126 | hash_len = 64; | 138 | hash_len = 64; |
139 | } else if (ENABLE_SHA3SUM && hash_algo == HASH_SHA3) { | ||
140 | sha3_begin(&context.sha3); | ||
141 | update = (void*)sha3_hash; | ||
142 | final = (void*)sha3_end; | ||
143 | hash_len = 64; | ||
127 | } else { | 144 | } else { |
128 | xfunc_die(); /* can't reach this */ | 145 | xfunc_die(); /* can't reach this */ |
129 | } | 146 | } |