diff options
Diffstat (limited to 'coreutils/md5_sha1_sum.c')
-rw-r--r-- | coreutils/md5_sha1_sum.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c index 2cb6dd43c..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 | } |
@@ -223,7 +240,7 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv) | |||
223 | } | 240 | } |
224 | if (count_failed && !(flags & FLAG_SILENT)) { | 241 | if (count_failed && !(flags & FLAG_SILENT)) { |
225 | bb_error_msg("WARNING: %d of %d computed checksums did NOT match", | 242 | bb_error_msg("WARNING: %d of %d computed checksums did NOT match", |
226 | count_failed, count_total); | 243 | count_failed, count_total); |
227 | } | 244 | } |
228 | fclose_if_not_stdin(pre_computed_stream); | 245 | fclose_if_not_stdin(pre_computed_stream); |
229 | } else { | 246 | } else { |