This file is indexed.

/usr/bin/sha3sum is in libdigest-sha3-perl 0.24-2build1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
#!/usr/bin/perl -w

	## sha3sum: filter for computing SHA-3 digests (ref. shasum)
	##
	## Copyright (C) 2012-2015 Mark Shelor, All Rights Reserved
	##
	## Version: 0.24
	## Sat Jan 10 00:45:34 MST 2015

	## sha3sum SYNOPSIS adapted from GNU Coreutils sha1sum. Add
	## "-a" option for algorithm selection,
	## "-U" option for Universal Newlines support,
	## "-0" option for reading bit strings, and
	## "-p" option for portable digests (to be deprecated).

use strict;
use warnings;
use Fcntl;
use Getopt::Long;

my $POD = <<'END_OF_POD';

=head1 NAME

sha3sum - Print or Check SHA-3 Checksums

=head1 SYNOPSIS

 Usage: sha3sum [OPTION]... [FILE]...
 Print or check SHA-3 checksums.
 With no FILE, or when FILE is -, read standard input.

   -a, --algorithm   224 (default), 256, 384, 512, 128000, 256000
   -b, --binary      read in binary mode
   -c, --check       read SHA-3 sums from the FILEs and check them
   -t, --text        read in text mode (default)
   -U, --UNIVERSAL   read in Universal Newlines mode
                         produces same digest on Windows/Unix/Mac
   -0, --01          read in BITS mode
                         ASCII '0' interpreted as 0-bit,
                         ASCII '1' interpreted as 1-bit,
                         all other characters ignored
   -p, --portable    read in portable mode (to be deprecated)

 The following two options are useful only when verifying checksums:
   -s, --status      don't output anything, status code shows success
   -w, --warn        warn about improperly formatted checksum lines

   -h, --help        display this help and exit
   -v, --version     output version information and exit

 The sums are computed as described in the FIPS 202 SHA-3 submission.
 When checking, the input should be a former output of this program.
 The default mode is to print a line with checksum, a character
 indicating type (`*' for binary, ` ' for text, `U' for UNIVERSAL,
 `^' for BITS, `?' for portable), and name for each FILE.

 Report sha3sum bugs to mshelor@cpan.org

=head1 DESCRIPTION

Running I<sha3sum> is often the quickest way to compute SHA-3 message
digests.  The user simply feeds data to the script through files or
standard input, and then collects the results from standard output.

The following command shows how to compute digests for typical inputs
such as the NIST test vector "abc":

	perl -e "print qq(abc)" | sha3sum

Or, if you want to use SHA3-256 instead of the default SHA3-224,
simply say:

	perl -e "print qq(abc)" | sha3sum -a 256

Unlike many other digest computation programs, I<sha3sum> implements
the full SHA-3 standard by allowing partial-byte inputs, which can
be recognized through the BITS option (I<-0>).  The following example
computes the SHA3-384 digest of the 7-bit message I<0001100>:

	perl -e "print qq(0001100)" | sha3sum -0 -a 384

=head1 AUTHOR

Copyright (c) 2012-2015 Mark Shelor <mshelor@cpan.org>.

=head1 SEE ALSO

I<sha3sum> is implemented using the Perl module L<Digest::SHA3>.

=cut

END_OF_POD

my $VERSION = "0.24";


	## Try to use Digest::SHA3.  If not installed, use the slower
	## but functionally equivalent Digest::SHA3::PurePerl instead.

my $MOD_PREFER = "Digest::SHA3";
my $MOD_SECOND = "Digest::SHA3::PurePerl";	# Not yet implemented

my $module = $MOD_PREFER;
eval "require $module";
if ($@) {
	# $module = $MOD_SECOND;
	# eval "require $module";
	# die "Unable to find $MOD_PREFER or $MOD_SECOND\n" if $@;
	die "Unable to find $MOD_PREFER\n" if $@;
}


sub usage {
	my($err, $msg) = @_;

	$msg = "" unless defined $msg;
	if ($err) {
		warn($msg . "Type sha3sum -h for help\n");
		exit($err);
	}
	my($USAGE) = $POD =~ /SYNOPSIS\n\n(.+)\n=head1 DESCRIPTION\n/sm;
	$USAGE =~ s/^ //gm;
	print $USAGE;
	exit($err);
}


	## Sync stdout and stderr by forcing a flush after every write

select((select(STDOUT), $| = 1)[0]);
select((select(STDERR), $| = 1)[0]);


	## Collect options from command line

my ($alg, $binary, $check, $text, $status, $warn, $help, $version);
my ($portable, $BITS, $UNIVERSAL);

eval { Getopt::Long::Configure ("bundling") };
GetOptions(
	'b|binary' => \$binary, 'c|check' => \$check,
	't|text' => \$text, 'a|algorithm=i' => \$alg,
	's|status' => \$status, 'w|warn' => \$warn,
	'h|help' => \$help, 'v|version' => \$version,
	'U|UNIVERSAL' => \$UNIVERSAL,
	'0|01' => \$BITS,
	'p|portable' => \$portable,
) or usage(1, "");


	## Deal with help requests and incorrect uses

usage(0)
	if $help;
usage(1, "sha3sum: Ambiguous file mode\n")
	if scalar(grep {defined $_}
		($binary, $portable, $text, $BITS, $UNIVERSAL)) > 1;
usage(1, "sha3sum: --warn option used only when verifying checksums\n")
	if $warn && !$check;
usage(1, "sha3sum: --status option used only when verifying checksums\n")
	if $status && !$check;


	## Default to SHA3-224 unless overridden by command line option

$alg = 224 unless defined $alg;
grep { $_ == $alg } (224, 256, 384, 512, 128000, 256000)
	or usage(1, "sha3sum: Unrecognized algorithm\n");


	## Display version information if requested

if ($version) {
	print "$VERSION\n";
	exit(0);
}


	## Try to figure out if the OS is DOS-like.  If it is,
	## default to binary mode when reading files, unless
	## explicitly overridden by command line "--text" or
	## "--UNIVERSAL" or "--portable" options.

my $isDOSish = ($^O =~ /^(MSWin\d\d|os2|dos|mint|cygwin)$/);
if ($isDOSish) { $binary = 1 unless $text || $UNIVERSAL || $portable }

my $modesym = $binary ? '*' : ($UNIVERSAL ? 'U' :
		($BITS ? '^' : ($portable ? '?' : ' ')));


	## Read from STDIN (-) if no files listed on command line

@ARGV = ("-") unless @ARGV;


	## sumfile($file): computes SHA-3 digest of $file

sub sumfile {
	my $file = shift;

	my $mode = $binary ? 'b' : ($UNIVERSAL ? 'U' :
			($BITS ? '0' : ($portable ? 'p' : '')));
	my $digest = eval { $module->new($alg)->addfile($file, $mode) };
	if ($@) { warn "sha3sum: $file: $!\n"; return }
	$digest->hexdigest;
}


	## %len2alg: maps hex digest length to SHA-3 algorithm

my %len2alg = (56 => 224, 64 => 256, 96 => 384, 128 => 512,
		336 => 128000, 272 => 256000);


	## unescape: convert backslashed filename to plain filename

sub unescape {
	$_ = shift;
	s/\\\\/\0/g;
	s/\\n/\n/g;
	return if /\\/;
	s/\0/\\/g;
	return $_;
}


	## verify: confirm the digest values in a checksum file

sub verify {
	my $checkfile = shift;
	my ($err, $fmt_errs, $read_errs, $match_errs) = (0, 0, 0, 0);
	my ($num_lines, $num_files) = (0, 0);
	my ($bslash, $sum, $fname, $rsp, $digest);

	local *FH;
	$checkfile eq '-' and open(FH, '< -')
		and $checkfile = 'standard input'
	or sysopen(FH, $checkfile, O_RDONLY)
		or die "sha3sum: $checkfile: $!\n";
	while (<FH>) {
		next if /^#/; s/\n$//; s/^[ \t]+//; $num_lines++;
		$bslash = s/^\\//;
		($sum, $modesym, $fname) =
			/^([\da-fA-F]+)[ \t]([ *?^U])([^\0]*)/;
		$alg = defined $sum ? $len2alg{length($sum)} : undef;
		$fname = unescape($fname) if defined $fname && $bslash;
		if (grep { ! defined $_ } ($alg, $sum, $modesym, $fname)) {
			$alg = 1 unless defined $alg;
			warn("sha3sum: $checkfile: $.: improperly formatted" .
				" SHA3-$alg checksum line\n") if $warn;
			$fmt_errs++;
			next;
		}
		$fname =~ s/\r$// unless -e $fname;
		$rsp = "$fname: "; $num_files++;
		($binary, $text, $UNIVERSAL, $BITS, $portable) =
			map { $_ eq $modesym } ('*', ' ', 'U', '^', 'p');
		unless ($digest = sumfile($fname)) {
			$rsp .= "FAILED open or read\n";
			$err = 1; $read_errs++;
		}
		else {
			if (lc($sum) eq $digest) { $rsp .= "OK\n" }
			else { $rsp .= "FAILED\n"; $err = 1; $match_errs++ }
		}
		print $rsp unless $status;
	}
	close(FH);
	unless ($num_files) {
		$alg = 1 unless defined $alg;
		warn("sha3sum: $checkfile: no properly formatted " .
			"SHA3-$alg checksum lines found\n");
		$err = 1;
	}
	elsif (! $status) {
		warn("sha3sum: WARNING: $fmt_errs line" . ($fmt_errs>1?
		's are':' is') . " improperly formatted\n") if $fmt_errs;
		warn("sha3sum: WARNING: $read_errs listed file" .
		($read_errs>1?'s':'') . " could not be read\n") if $read_errs;
		warn("sha3sum: WARNING: $match_errs computed checksum" .
		($match_errs>1?'s':'') . " did NOT match\n") if $match_errs;
	}
	return($err == 0);
}


	## Verify or compute SHA-3 checksums of requested files

my($file, $digest);

my $STATUS = 0;
for $file (@ARGV) {
	if ($check) { $STATUS = 1 unless verify($file) }
	elsif ($digest = sumfile($file)) {
		if ($file =~ /[\n\\]/) {
			$file =~ s/\\/\\\\/g; $file =~ s/\n/\\n/g;
			$digest = "\\$digest";
		}
		print "$digest $modesym", "$file\n";
	}
	else { $STATUS = 1 }
}
exit($STATUS)