]>
Commit | Line | Data |
---|---|---|
38e33cef UM |
1 | =pod |
2 | ||
3 | =head1 NAME | |
4 | ||
f7812493 MC |
5 | SHA1, SHA1_Init, SHA1_Update, SHA1_Final, SHA224, SHA224_Init, SHA224_Update, |
6 | SHA224_Final, SHA256, SHA256_Init, SHA256_Update, SHA256_Final, SHA384, | |
7 | SHA384_Init, SHA384_Update, SHA384_Final, SHA512, SHA512_Init, SHA512_Update, | |
8 | SHA512_Final - Secure Hash Algorithm | |
38e33cef UM |
9 | |
10 | =head1 SYNOPSIS | |
11 | ||
12 | #include <openssl/sha.h> | |
13 | ||
8a4af56f | 14 | int SHA1_Init(SHA_CTX *c); |
f7812493 | 15 | int SHA1_Update(SHA_CTX *c, const void *data, size_t len); |
8a4af56f | 16 | int SHA1_Final(unsigned char *md, SHA_CTX *c); |
f7812493 | 17 | unsigned char *SHA1(const unsigned char *d, size_t n, |
e9b77246 | 18 | unsigned char *md); |
f7812493 MC |
19 | |
20 | int SHA224_Init(SHA256_CTX *c); | |
21 | int SHA224_Update(SHA256_CTX *c, const void *data, size_t len); | |
22 | int SHA224_Final(unsigned char *md, SHA256_CTX *c); | |
23 | unsigned char *SHA224(const unsigned char *d, size_t n, | |
e9b77246 | 24 | unsigned char *md); |
f7812493 MC |
25 | |
26 | int SHA256_Init(SHA256_CTX *c); | |
27 | int SHA256_Update(SHA256_CTX *c, const void *data, size_t len); | |
28 | int SHA256_Final(unsigned char *md, SHA256_CTX *c); | |
29 | unsigned char *SHA256(const unsigned char *d, size_t n, | |
e9b77246 | 30 | unsigned char *md); |
f7812493 MC |
31 | |
32 | int SHA384_Init(SHA512_CTX *c); | |
33 | int SHA384_Update(SHA512_CTX *c, const void *data, size_t len); | |
34 | int SHA384_Final(unsigned char *md, SHA512_CTX *c); | |
35 | unsigned char *SHA384(const unsigned char *d, size_t n, | |
e9b77246 | 36 | unsigned char *md); |
f7812493 MC |
37 | |
38 | int SHA512_Init(SHA512_CTX *c); | |
39 | int SHA512_Update(SHA512_CTX *c, const void *data, size_t len); | |
40 | int SHA512_Final(unsigned char *md, SHA512_CTX *c); | |
41 | unsigned char *SHA512(const unsigned char *d, size_t n, | |
e9b77246 | 42 | unsigned char *md); |
38e33cef UM |
43 | |
44 | =head1 DESCRIPTION | |
45 | ||
f7812493 | 46 | Applications should use the higher level functions |
9b86974e | 47 | L<EVP_DigestInit(3)> etc. instead of calling the hash |
f7812493 MC |
48 | functions directly. |
49 | ||
38e33cef UM |
50 | SHA-1 (Secure Hash Algorithm) is a cryptographic hash function with a |
51 | 160 bit output. | |
52 | ||
74235cc9 UM |
53 | SHA1() computes the SHA-1 message digest of the B<n> |
54 | bytes at B<d> and places it in B<md> (which must have space for | |
55 | SHA_DIGEST_LENGTH == 20 bytes of output). If B<md> is NULL, the digest | |
f7812493 | 56 | is placed in a static array. Note: setting B<md> to NULL is B<not thread safe>. |
74235cc9 UM |
57 | |
58 | The following functions may be used if the message is not completely | |
59 | stored in memory: | |
60 | ||
61 | SHA1_Init() initializes a B<SHA_CTX> structure. | |
62 | ||
63 | SHA1_Update() can be called repeatedly with chunks of the message to | |
64 | be hashed (B<len> bytes at B<data>). | |
65 | ||
66 | SHA1_Final() places the message digest in B<md>, which must have space | |
67 | for SHA_DIGEST_LENGTH == 20 bytes of output, and erases the B<SHA_CTX>. | |
68 | ||
f7812493 MC |
69 | The SHA224, SHA256, SHA384 and SHA512 families of functions operate in the |
70 | same way as for the SHA1 functions. Note that SHA224 and SHA256 use a | |
71 | B<SHA256_CTX> object instead of B<SHA_CTX>. SHA384 and SHA512 use B<SHA512_CTX>. | |
72 | The buffer B<md> must have space for the output from the SHA variant being used | |
73 | (defined by SHA224_DIGEST_LENGTH, SHA256_DIGEST_LENGTH, SHA384_DIGEST_LENGTH and | |
74 | SHA512_DIGEST_LENGTH). Also note that, as for the SHA1() function above, the | |
75 | SHA224(), SHA256(), SHA384() and SHA512() functions are not thread safe if | |
76 | B<md> is NULL. | |
4facdbb5 | 77 | |
38e33cef UM |
78 | The predecessor of SHA-1, SHA, is also implemented, but it should be |
79 | used only when backward compatibility is required. | |
80 | ||
74235cc9 UM |
81 | =head1 RETURN VALUES |
82 | ||
f7812493 | 83 | SHA1(), SHA224(), SHA256(), SHA384() and SHA512() return a pointer to the hash |
1bc74519 | 84 | value. |
74235cc9 | 85 | |
f7812493 MC |
86 | SHA1_Init(), SHA1_Update() and SHA1_Final() and equivalent SHA224, SHA256, |
87 | SHA384 and SHA512 functions return 1 for success, 0 otherwise. | |
74235cc9 | 88 | |
38e33cef UM |
89 | =head1 CONFORMING TO |
90 | ||
f7812493 | 91 | US Federal Information Processing Standard FIPS PUB 180-4 (Secure Hash |
6671fe16 BM |
92 | Standard), |
93 | ANSI X9.30 | |
38e33cef UM |
94 | |
95 | =head1 SEE ALSO | |
96 | ||
9b86974e | 97 | L<EVP_DigestInit(3)> |
38e33cef | 98 | |
e2f92610 RS |
99 | =head1 COPYRIGHT |
100 | ||
101 | Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. | |
102 | ||
4746f25a | 103 | Licensed under the Apache License 2.0 (the "License"). You may not use |
e2f92610 RS |
104 | this file except in compliance with the License. You can obtain a copy |
105 | in the file LICENSE in the source distribution or at | |
106 | L<https://www.openssl.org/source/license.html>. | |
107 | ||
108 | =cut |