1*1dcdf01fSchristos=pod 2*1dcdf01fSchristos 3*1dcdf01fSchristos=head1 NAME 4*1dcdf01fSchristos 5*1dcdf01fSchristosSHA1, SHA1_Init, SHA1_Update, SHA1_Final, SHA224, SHA224_Init, SHA224_Update, 6*1dcdf01fSchristosSHA224_Final, SHA256, SHA256_Init, SHA256_Update, SHA256_Final, SHA384, 7*1dcdf01fSchristosSHA384_Init, SHA384_Update, SHA384_Final, SHA512, SHA512_Init, SHA512_Update, 8*1dcdf01fSchristosSHA512_Final - Secure Hash Algorithm 9*1dcdf01fSchristos 10*1dcdf01fSchristos=head1 SYNOPSIS 11*1dcdf01fSchristos 12*1dcdf01fSchristos #include <openssl/sha.h> 13*1dcdf01fSchristos 14*1dcdf01fSchristos int SHA1_Init(SHA_CTX *c); 15*1dcdf01fSchristos int SHA1_Update(SHA_CTX *c, const void *data, size_t len); 16*1dcdf01fSchristos int SHA1_Final(unsigned char *md, SHA_CTX *c); 17*1dcdf01fSchristos unsigned char *SHA1(const unsigned char *d, size_t n, 18*1dcdf01fSchristos unsigned char *md); 19*1dcdf01fSchristos 20*1dcdf01fSchristos int SHA224_Init(SHA256_CTX *c); 21*1dcdf01fSchristos int SHA224_Update(SHA256_CTX *c, const void *data, size_t len); 22*1dcdf01fSchristos int SHA224_Final(unsigned char *md, SHA256_CTX *c); 23*1dcdf01fSchristos unsigned char *SHA224(const unsigned char *d, size_t n, 24*1dcdf01fSchristos unsigned char *md); 25*1dcdf01fSchristos 26*1dcdf01fSchristos int SHA256_Init(SHA256_CTX *c); 27*1dcdf01fSchristos int SHA256_Update(SHA256_CTX *c, const void *data, size_t len); 28*1dcdf01fSchristos int SHA256_Final(unsigned char *md, SHA256_CTX *c); 29*1dcdf01fSchristos unsigned char *SHA256(const unsigned char *d, size_t n, 30*1dcdf01fSchristos unsigned char *md); 31*1dcdf01fSchristos 32*1dcdf01fSchristos int SHA384_Init(SHA512_CTX *c); 33*1dcdf01fSchristos int SHA384_Update(SHA512_CTX *c, const void *data, size_t len); 34*1dcdf01fSchristos int SHA384_Final(unsigned char *md, SHA512_CTX *c); 35*1dcdf01fSchristos unsigned char *SHA384(const unsigned char *d, size_t n, 36*1dcdf01fSchristos unsigned char *md); 37*1dcdf01fSchristos 38*1dcdf01fSchristos int SHA512_Init(SHA512_CTX *c); 39*1dcdf01fSchristos int SHA512_Update(SHA512_CTX *c, const void *data, size_t len); 40*1dcdf01fSchristos int SHA512_Final(unsigned char *md, SHA512_CTX *c); 41*1dcdf01fSchristos unsigned char *SHA512(const unsigned char *d, size_t n, 42*1dcdf01fSchristos unsigned char *md); 43*1dcdf01fSchristos 44*1dcdf01fSchristos=head1 DESCRIPTION 45*1dcdf01fSchristos 46*1dcdf01fSchristosApplications should use the higher level functions 47*1dcdf01fSchristosL<EVP_DigestInit(3)> etc. instead of calling the hash 48*1dcdf01fSchristosfunctions directly. 49*1dcdf01fSchristos 50*1dcdf01fSchristosSHA-1 (Secure Hash Algorithm) is a cryptographic hash function with a 51*1dcdf01fSchristos160 bit output. 52*1dcdf01fSchristos 53*1dcdf01fSchristosSHA1() computes the SHA-1 message digest of the B<n> 54*1dcdf01fSchristosbytes at B<d> and places it in B<md> (which must have space for 55*1dcdf01fSchristosSHA_DIGEST_LENGTH == 20 bytes of output). If B<md> is NULL, the digest 56*1dcdf01fSchristosis placed in a static array. Note: setting B<md> to NULL is B<not thread safe>. 57*1dcdf01fSchristos 58*1dcdf01fSchristosThe following functions may be used if the message is not completely 59*1dcdf01fSchristosstored in memory: 60*1dcdf01fSchristos 61*1dcdf01fSchristosSHA1_Init() initializes a B<SHA_CTX> structure. 62*1dcdf01fSchristos 63*1dcdf01fSchristosSHA1_Update() can be called repeatedly with chunks of the message to 64*1dcdf01fSchristosbe hashed (B<len> bytes at B<data>). 65*1dcdf01fSchristos 66*1dcdf01fSchristosSHA1_Final() places the message digest in B<md>, which must have space 67*1dcdf01fSchristosfor SHA_DIGEST_LENGTH == 20 bytes of output, and erases the B<SHA_CTX>. 68*1dcdf01fSchristos 69*1dcdf01fSchristosThe SHA224, SHA256, SHA384 and SHA512 families of functions operate in the 70*1dcdf01fSchristossame way as for the SHA1 functions. Note that SHA224 and SHA256 use a 71*1dcdf01fSchristosB<SHA256_CTX> object instead of B<SHA_CTX>. SHA384 and SHA512 use B<SHA512_CTX>. 72*1dcdf01fSchristosThe buffer B<md> must have space for the output from the SHA variant being used 73*1dcdf01fSchristos(defined by SHA224_DIGEST_LENGTH, SHA256_DIGEST_LENGTH, SHA384_DIGEST_LENGTH and 74*1dcdf01fSchristosSHA512_DIGEST_LENGTH). Also note that, as for the SHA1() function above, the 75*1dcdf01fSchristosSHA224(), SHA256(), SHA384() and SHA512() functions are not thread safe if 76*1dcdf01fSchristosB<md> is NULL. 77*1dcdf01fSchristos 78*1dcdf01fSchristos=head1 RETURN VALUES 79*1dcdf01fSchristos 80*1dcdf01fSchristosSHA1(), SHA224(), SHA256(), SHA384() and SHA512() return a pointer to the hash 81*1dcdf01fSchristosvalue. 82*1dcdf01fSchristos 83*1dcdf01fSchristosSHA1_Init(), SHA1_Update() and SHA1_Final() and equivalent SHA224, SHA256, 84*1dcdf01fSchristosSHA384 and SHA512 functions return 1 for success, 0 otherwise. 85*1dcdf01fSchristos 86*1dcdf01fSchristos=head1 CONFORMING TO 87*1dcdf01fSchristos 88*1dcdf01fSchristosUS Federal Information Processing Standard FIPS PUB 180-4 (Secure Hash 89*1dcdf01fSchristosStandard), 90*1dcdf01fSchristosANSI X9.30 91*1dcdf01fSchristos 92*1dcdf01fSchristos=head1 SEE ALSO 93*1dcdf01fSchristos 94*1dcdf01fSchristosL<EVP_DigestInit(3)> 95*1dcdf01fSchristos 96*1dcdf01fSchristos=head1 COPYRIGHT 97*1dcdf01fSchristos 98*1dcdf01fSchristosCopyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. 99*1dcdf01fSchristos 100*1dcdf01fSchristosLicensed under the OpenSSL license (the "License"). You may not use 101*1dcdf01fSchristosthis file except in compliance with the License. You can obtain a copy 102*1dcdf01fSchristosin the file LICENSE in the source distribution or at 103*1dcdf01fSchristosL<https://www.openssl.org/source/license.html>. 104*1dcdf01fSchristos 105*1dcdf01fSchristos=cut 106