]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/SHA256_Init.pod
Clarify the deprecation warnings in the docs
[thirdparty/openssl.git] / doc / man3 / SHA256_Init.pod
CommitLineData
38e33cef
UM
1=pod
2
3=head1 NAME
4
f7812493
MC
5SHA1, SHA1_Init, SHA1_Update, SHA1_Final, SHA224, SHA224_Init, SHA224_Update,
6SHA224_Final, SHA256, SHA256_Init, SHA256_Update, SHA256_Final, SHA384,
7SHA384_Init, SHA384_Update, SHA384_Final, SHA512, SHA512_Init, SHA512_Update,
8SHA512_Final - Secure Hash Algorithm
38e33cef
UM
9
10=head1 SYNOPSIS
11
12 #include <openssl/sha.h>
13
7b2bde50
PH
14 unsigned char *SHA1(const unsigned char *data, size_t count, unsigned char *md_buf);
15 unsigned char *SHA224(const unsigned char *data, size_t count, unsigned char *md_buf);
16 unsigned char *SHA256(const unsigned char *data, size_t count, unsigned char *md_buf);
17 unsigned char *SHA384(const unsigned char *data, size_t count, unsigned char *md_buf);
18 unsigned char *SHA512(const unsigned char *data, size_t count, unsigned char *md_buf);
4d49b685 19
3dbf8243
MC
20The following functions have been deprecated since OpenSSL 3.0, and can be
21hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
22see L<openssl_user_macros(7)>:
85d843c8 23
8a4af56f 24 int SHA1_Init(SHA_CTX *c);
f7812493 25 int SHA1_Update(SHA_CTX *c, const void *data, size_t len);
8a4af56f 26 int SHA1_Final(unsigned char *md, SHA_CTX *c);
f7812493
MC
27
28 int SHA224_Init(SHA256_CTX *c);
29 int SHA224_Update(SHA256_CTX *c, const void *data, size_t len);
30 int SHA224_Final(unsigned char *md, SHA256_CTX *c);
f7812493
MC
31
32 int SHA256_Init(SHA256_CTX *c);
33 int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
34 int SHA256_Final(unsigned char *md, SHA256_CTX *c);
f7812493
MC
35
36 int SHA384_Init(SHA512_CTX *c);
37 int SHA384_Update(SHA512_CTX *c, const void *data, size_t len);
38 int SHA384_Final(unsigned char *md, SHA512_CTX *c);
f7812493
MC
39
40 int SHA512_Init(SHA512_CTX *c);
41 int SHA512_Update(SHA512_CTX *c, const void *data, size_t len);
42 int SHA512_Final(unsigned char *md, SHA512_CTX *c);
38e33cef
UM
43
44=head1 DESCRIPTION
45
4d49b685
DDO
46All of the functions described on this page
47except for SHA1(), SHA224(), SHA256(), SHA384() and SHA512() are deprecated.
85d843c8 48Applications should instead use L<EVP_DigestInit_ex(3)>, L<EVP_DigestUpdate(3)>
4d49b685
DDO
49and L<EVP_DigestFinal_ex(3)>, or the quick one-shot function L<EVP_Q_digest(3)>.
50SHA1(), SHA224(), SHA256(), SHA384(), and SHA256()
51can continue to be used. They can also be replaced by, e.g.,
52
53 (EVP_Q_digest(d, n, md, NULL, NULL, "SHA256", NULL) ? md : NULL)
f7812493 54
38e33cef
UM
55SHA-1 (Secure Hash Algorithm) is a cryptographic hash function with a
56160 bit output.
57
74235cc9
UM
58SHA1() computes the SHA-1 message digest of the B<n>
59bytes at B<d> and places it in B<md> (which must have space for
60SHA_DIGEST_LENGTH == 20 bytes of output). If B<md> is NULL, the digest
f7812493 61is placed in a static array. Note: setting B<md> to NULL is B<not thread safe>.
74235cc9
UM
62
63The following functions may be used if the message is not completely
64stored in memory:
65
66SHA1_Init() initializes a B<SHA_CTX> structure.
67
68SHA1_Update() can be called repeatedly with chunks of the message to
69be hashed (B<len> bytes at B<data>).
70
71SHA1_Final() places the message digest in B<md>, which must have space
72for SHA_DIGEST_LENGTH == 20 bytes of output, and erases the B<SHA_CTX>.
73
f7812493
MC
74The SHA224, SHA256, SHA384 and SHA512 families of functions operate in the
75same way as for the SHA1 functions. Note that SHA224 and SHA256 use a
76B<SHA256_CTX> object instead of B<SHA_CTX>. SHA384 and SHA512 use B<SHA512_CTX>.
77The buffer B<md> must have space for the output from the SHA variant being used
78(defined by SHA224_DIGEST_LENGTH, SHA256_DIGEST_LENGTH, SHA384_DIGEST_LENGTH and
79SHA512_DIGEST_LENGTH). Also note that, as for the SHA1() function above, the
80SHA224(), SHA256(), SHA384() and SHA512() functions are not thread safe if
81B<md> is NULL.
4facdbb5 82
74235cc9
UM
83=head1 RETURN VALUES
84
f7812493 85SHA1(), SHA224(), SHA256(), SHA384() and SHA512() return a pointer to the hash
1bc74519 86value.
74235cc9 87
f7812493
MC
88SHA1_Init(), SHA1_Update() and SHA1_Final() and equivalent SHA224, SHA256,
89SHA384 and SHA512 functions return 1 for success, 0 otherwise.
74235cc9 90
38e33cef
UM
91=head1 CONFORMING TO
92
f7812493 93US Federal Information Processing Standard FIPS PUB 180-4 (Secure Hash
6671fe16
BM
94Standard),
95ANSI X9.30
38e33cef
UM
96
97=head1 SEE ALSO
98
4d49b685 99L<EVP_Q_digest(3)>,
9b86974e 100L<EVP_DigestInit(3)>
38e33cef 101
85d843c8
P
102=head1 HISTORY
103
4d49b685 104All of these functions except SHA*() were deprecated in OpenSSL 3.0.
85d843c8 105
e2f92610
RS
106=head1 COPYRIGHT
107
0789c7d8 108Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
e2f92610 109
4746f25a 110Licensed under the Apache License 2.0 (the "License"). You may not use
e2f92610
RS
111this file except in compliance with the License. You can obtain a copy
112in the file LICENSE in the source distribution or at
113L<https://www.openssl.org/source/license.html>.
114
115=cut