Debian Codegraph @

sha1-hashcash.pod

raw
1 =head1 NAME
2
3 sha1 - Secure Hash Algorithm (version 1) hash function
4
5 =head1 SYNOPSIS
6
7 =head2 hash files:
8
9 B<sha1> [ I<files> ]
10
11 =head1 DESCRIPTION
12
13 This is an implementation of the Secure Hash Algorithm version 1 as
14 defined in US Federal Information Processing Standard "FIPS 180-1".
15
16 This was shipped for convenience with the hashcash tool, but also functions
17 similarly to the widely distributed md5sum utility but using SHA1 instead of
18 MD5 so you may find other uses for it. (Some have argued that MD5 is too
19 small a hash to use for checking files if the attacker can insert chosen
20 files into your distribution as then a birthday attack becomes possible for
21 the master md5sum with work factor of about 2^64, which is a fairly high
22 cost but not infeasible.)
23
24 =head1 OTHER IMPLEMENTATIONS
25
26 This program is fairly compatible with B<openssl sha1> (sha1(1)) and
27 B<sha1sum> (sha1sum(1)) installed on some unix systems and included with
28 hashcash package so that a sha1 implementation is available for testing and
29 scripting if those packages are missing.
30
31 =head1 USAGE NOTES
32
33 The sha1 program will hash the files given on the command line, or if no
34 files are given it will hash the input fed to it on standard input. The
35 output format is a list of SHA1 hashes in hex followed by the corresponding
36 filenames, one per line.
37
38 =head1 EXAMPLES
39
40 =head2 Hashing files
41
42 =over 4
43
44 =item C<sha1 file1 file2 [...]>
45
46 Hashes the files listed on the command line and outputs their SHA1
47 message digests as 40 hexadecimal digits, followed by the filename,
48 one per line.
49
50 =item C<echo -n abc | sha1>
51
52 When no files are given, hashes from standard in. The example command
53 hashes the string "abc" from standard input. This string is
54 coincidentally one of the test vectors specified in FIPS 180-1 and
55 should output: I<a9993e364706816aba3e25717850c26c9cd0d89d>.
56
57 =item C<echo -n abc | sha1 ->
58
59 Equivalent to above. The filename of I<-> means read from standard input.
60
61 =item C<echo -n abc | sha1 test.txt ->
62
63 You can also mix filenames and reading from standard input with the I<->
64 pseudo file. The above command first hashes file C<test.txt> then reads the
65 string abc from standard in.
66
67 =back
68
69 =head1 Verifying Hashcash
70
71 The SHA1 hash function is used by hashcash. You can use this sha1
72 utility to write shell scripts to verify hashcash tokens without using
73 the hashcash command line tool, or just to verify visually. Say you
74 received the following email:
75
76 From: Someone <[email protected]>
77 To: Adam Back <[email protected]>
78 Subject: test hashcash
79 Date: Thu, 15 Aug 2002 11:12:02 +0000
80 X-Hashcash: 0:030626:[email protected]:6470e06d773e05a8
81
82 Then the following command would show visually the size of the
83 preimage:
84
85 =over 4
86
87 =item C<echo -n 0:030626:[email protected]:6470e06d773e05a8 | sha1>
88
89 00000000c70db7389f241b8f441fcf068aead3f0
90
91 =back
92
93 and you can see the leading hex 0s.
94
95 =head1 LIMITATIONS
96
97 Doesn't have the check option that md5sum has. Perhaps I'll add that in a
98 future version. Also doesn't have the binary / text distinction that md5sum
99 introduced for DOS/Windows benefit, nor the output convention signifying
100 text (* after hash). Can't say I've ever seen anyone use that feature
101 though.
102
103 =head1 EXIT STATUS
104
105 C<sha1> returns success (exit code 0) normally.
106
107 If it can't read any of the files you give it on the comamnd line, it
108 instead returns failure (exit code 1).
109
110 =head1 AUTHOR
111
112 Written by Adam Back E<lt>[email protected]<gt>
113
114 =head1 SEE ALSO
115
116 md5sum(1), sha1(1), sha1sum(1), hashcash(1), http://www.hashcash.org/,
117 http://www.itl.nist.gov/fipspubs/fip180-1.htm