summaryrefslogtreecommitdiff
path: root/lib/libcrypto/man/SHA1.3
blob: 48292c1e31dee41ee7c7b37cf1a2dcdd2d080dc1 (plain)
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
.\"	$OpenBSD: SHA1.3,v 1.2 2016/11/06 15:52:50 jmc Exp $
.\"
.Dd $Mdocdate: November 6 2016 $
.Dt SHA1 3
.Os
.Sh NAME
.Nm SHA1 ,
.Nm SHA1_Init ,
.Nm SHA1_Update ,
.Nm SHA1_Final
.Nd Secure Hash Algorithm
.Sh SYNOPSIS
.In openssl/sha.h
.Ft unsigned char *
.Fo SHA1
.Fa "const unsigned char *d"
.Fa "unsigned long n"
.Fa "unsigned char *md"
.Fc
.Ft int
.Fo SHA1_Init
.Fa "SHA_CTX *c"
.Fc
.Ft int
.Fo SHA1_Update
.Fa "SHA_CTX *c"
.Fa "const void *data"
.Fa "unsigned long len"
.Fc
.Ft int
.Fo SHA1_Final
.Fa "unsigned char *md"
.Fa "SHA_CTX *c"
.Fc
.Sh DESCRIPTION
SHA-1 (Secure Hash Algorithm) is a cryptographic hash function with a
160 bit output.
.Pp
.Fn SHA1
computes the SHA-1 message digest of the
.Fa n
bytes at
.Fa d
and places it in
.Fa md ,
which must have space for
.Dv SHA_DIGEST_LENGTH
== 20 bytes of output.
If
.Fa md
is
.Dv NULL ,
the digest is placed in a static array.
.Pp
The following functions may be used if the message is not completely
stored in memory:
.Pp
.Fn SHA1_Init
initializes a
.Vt SHA_CTX
structure.
.Pp
.Fn SHA1_Update
can be called repeatedly with chunks of the message to be hashed
.Pq Fa len No bytes at Fa data .
.Pp
.Fn SHA1_Final
places the message digest in
.Fa md ,
which must have space for
.Dv SHA_DIGEST_LENGTH
== 20 bytes of output, and erases the
.Vt SHA_CTX .
.Pp
Applications should use the higher level functions
.Xr EVP_DigestInit 3
etc.  instead of calling the hash functions directly.
.Pp
The predecessor of SHA-1, SHA, is also implemented, but it should be
used only when backward compatibility is required.
.Sh RETURN VALUES
.Fn SHA1
returns a pointer to the hash value.
.Pp
.Fn SHA1_Init ,
.Fn SHA1_Update ,
and
.Fn SHA1_Final
return 1 for success or 0 otherwise.
.Sh SEE ALSO
.Xr EVP_DigestInit 3 ,
.Xr HMAC 3 ,
.Xr RIPEMD160 3
.Sh STANDARDS
SHA: US Federal Information Processing Standard FIPS PUB 180 (Secure
Hash Standard), SHA-1: US Federal Information Processing Standard FIPS
PUB 180-1 (Secure Hash Standard), ANSI X9.30
.Sh HISTORY
.Fn SHA1 ,
.Fn SHA1_Init ,
.Fn SHA1_Update ,
and
.Fn SHA1_Final
are available in all versions of SSLeay and OpenSSL.