Debian Codegraph @

upstream/debian-unstable/man3/SHA256_Init.3ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "SHA256_INIT 3SSL"
58 .TH SHA256_INIT 3SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 SHA1, SHA1_Init, SHA1_Update, SHA1_Final, SHA224, SHA224_Init, SHA224_Update,
65 SHA224_Final, SHA256, SHA256_Init, SHA256_Update, SHA256_Final, SHA384,
66 SHA384_Init, SHA384_Update, SHA384_Final, SHA512, SHA512_Init, SHA512_Update,
67 SHA512_Final \- Secure Hash Algorithm
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 .Vb 1
71 \& #include <openssl/sha.h>
72 \&
73 \& unsigned char *SHA1(const unsigned char *data, size_t count, unsigned char *md_buf);
74 \& unsigned char *SHA224(const unsigned char *data, size_t count, unsigned char *md_buf);
75 \& unsigned char *SHA256(const unsigned char *data, size_t count, unsigned char *md_buf);
76 \& unsigned char *SHA384(const unsigned char *data, size_t count, unsigned char *md_buf);
77 \& unsigned char *SHA512(const unsigned char *data, size_t count, unsigned char *md_buf);
78 .Ve
79 .PP
80 The following functions have been deprecated since OpenSSL 3.0, and can be
81 hidden entirely by defining \fBOPENSSL_API_COMPAT\fR with a suitable version value,
82 see \fBopenssl_user_macros\fR\|(7):
83 .PP
84 .Vb 3
85 \& int SHA1_Init(SHA_CTX *c);
86 \& int SHA1_Update(SHA_CTX *c, const void *data, size_t len);
87 \& int SHA1_Final(unsigned char *md, SHA_CTX *c);
88 \&
89 \& int SHA224_Init(SHA256_CTX *c);
90 \& int SHA224_Update(SHA256_CTX *c, const void *data, size_t len);
91 \& int SHA224_Final(unsigned char *md, SHA256_CTX *c);
92 \&
93 \& int SHA256_Init(SHA256_CTX *c);
94 \& int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
95 \& int SHA256_Final(unsigned char *md, SHA256_CTX *c);
96 \&
97 \& int SHA384_Init(SHA512_CTX *c);
98 \& int SHA384_Update(SHA512_CTX *c, const void *data, size_t len);
99 \& int SHA384_Final(unsigned char *md, SHA512_CTX *c);
100 \&
101 \& int SHA512_Init(SHA512_CTX *c);
102 \& int SHA512_Update(SHA512_CTX *c, const void *data, size_t len);
103 \& int SHA512_Final(unsigned char *md, SHA512_CTX *c);
104 .Ve
105 .SH DESCRIPTION
106 .IX Header "DESCRIPTION"
107 All of the functions described on this page
108 except for \fBSHA1()\fR, \fBSHA224()\fR, \fBSHA256()\fR, \fBSHA384()\fR and \fBSHA512()\fR are deprecated.
109 Applications should instead use \fBEVP_DigestInit_ex\fR\|(3), \fBEVP_DigestUpdate\fR\|(3)
110 and \fBEVP_DigestFinal_ex\fR\|(3), or the quick one-shot function \fBEVP_Q_digest\fR\|(3).
111 \&\fBSHA1()\fR, \fBSHA224()\fR, \fBSHA256()\fR, \fBSHA384()\fR, and \fBSHA256()\fR
112 can continue to be used. They can also be replaced by, e.g.,
113 .PP
114 .Vb 1
115 \& (EVP_Q_digest(d, n, md, NULL, NULL, "SHA256", NULL) ? md : NULL)
116 .Ve
117 .PP
118 SHA\-1 (Secure Hash Algorithm) is a cryptographic hash function with a
119 160 bit output.
120 .PP
121 \&\fBSHA1()\fR computes the SHA\-1 message digest of the \fBn\fR
122 bytes at \fBd\fR and places it in \fBmd\fR (which must have space for
123 SHA_DIGEST_LENGTH == 20 bytes of output). If \fBmd\fR is NULL, the digest
124 is placed in a static array. Note: setting \fBmd\fR to NULL is \fBnot thread safe\fR.
125 .PP
126 The following functions may be used if the message is not completely
127 stored in memory:
128 .PP
129 \&\fBSHA1_Init()\fR initializes a \fBSHA_CTX\fR structure.
130 .PP
131 \&\fBSHA1_Update()\fR can be called repeatedly with chunks of the message to
132 be hashed (\fBlen\fR bytes at \fBdata\fR).
133 .PP
134 \&\fBSHA1_Final()\fR places the message digest in \fBmd\fR, which must have space
135 for SHA_DIGEST_LENGTH == 20 bytes of output, and erases the \fBSHA_CTX\fR.
136 .PP
137 The SHA224, SHA256, SHA384 and SHA512 families of functions operate in the
138 same way as for the SHA1 functions. Note that SHA224 and SHA256 use a
139 \&\fBSHA256_CTX\fR object instead of \fBSHA_CTX\fR. SHA384 and SHA512 use \fBSHA512_CTX\fR.
140 The buffer \fBmd\fR must have space for the output from the SHA variant being used
141 (defined by SHA224_DIGEST_LENGTH, SHA256_DIGEST_LENGTH, SHA384_DIGEST_LENGTH and
142 SHA512_DIGEST_LENGTH). Also note that, as for the \fBSHA1()\fR function above, the
143 \&\fBSHA224()\fR, \fBSHA256()\fR, \fBSHA384()\fR and \fBSHA512()\fR functions are not thread safe if
144 \&\fBmd\fR is NULL.
145 .SH "RETURN VALUES"
146 .IX Header "RETURN VALUES"
147 \&\fBSHA1()\fR, \fBSHA224()\fR, \fBSHA256()\fR, \fBSHA384()\fR and \fBSHA512()\fR return a pointer to the hash
148 value.
149 .PP
150 \&\fBSHA1_Init()\fR, \fBSHA1_Update()\fR and \fBSHA1_Final()\fR and equivalent SHA224, SHA256,
151 SHA384 and SHA512 functions return 1 for success, 0 otherwise.
152 .SH "CONFORMING TO"
153 .IX Header "CONFORMING TO"
154 US Federal Information Processing Standard FIPS PUB 180\-4 (Secure Hash
155 Standard),
156 ANSI X9.30
157 .SH "SEE ALSO"
158 .IX Header "SEE ALSO"
159 \&\fBEVP_Q_digest\fR\|(3),
160 \&\fBEVP_DigestInit\fR\|(3)
161 .SH HISTORY
162 .IX Header "HISTORY"
163 All of these functions except SHA*() were deprecated in OpenSSL 3.0.
164 .SH COPYRIGHT
165 .IX Header "COPYRIGHT"
166 Copyright 2000\-2021 The OpenSSL Project Authors. All Rights Reserved.
167 .PP
168 Licensed under the Apache License 2.0 (the "License"). You may not use
169 this file except in compliance with the License. You can obtain a copy
170 in the file LICENSE in the source distribution or at
171 <https://www.openssl.org/source/license.html>.