SHA256_Init.pod 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. =pod
  2. =head1 NAME
  3. SHA1, SHA1_Init, SHA1_Update, SHA1_Final, SHA224, SHA224_Init, SHA224_Update,
  4. SHA224_Final, SHA256, SHA256_Init, SHA256_Update, SHA256_Final, SHA384,
  5. SHA384_Init, SHA384_Update, SHA384_Final, SHA512, SHA512_Init, SHA512_Update,
  6. SHA512_Final - Secure Hash Algorithm
  7. =head1 SYNOPSIS
  8. #include <openssl/sha.h>
  9. unsigned char *SHA1(const unsigned char *data, size_t count, unsigned char *md_buf);
  10. unsigned char *SHA224(const unsigned char *data, size_t count, unsigned char *md_buf);
  11. unsigned char *SHA256(const unsigned char *data, size_t count, unsigned char *md_buf);
  12. unsigned char *SHA384(const unsigned char *data, size_t count, unsigned char *md_buf);
  13. unsigned char *SHA512(const unsigned char *data, size_t count, unsigned char *md_buf);
  14. The following functions have been deprecated since OpenSSL 3.0, and can be
  15. hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
  16. see L<openssl_user_macros(7)>:
  17. int SHA1_Init(SHA_CTX *c);
  18. int SHA1_Update(SHA_CTX *c, const void *data, size_t len);
  19. int SHA1_Final(unsigned char *md, SHA_CTX *c);
  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. int SHA256_Init(SHA256_CTX *c);
  24. int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
  25. int SHA256_Final(unsigned char *md, SHA256_CTX *c);
  26. int SHA384_Init(SHA512_CTX *c);
  27. int SHA384_Update(SHA512_CTX *c, const void *data, size_t len);
  28. int SHA384_Final(unsigned char *md, SHA512_CTX *c);
  29. int SHA512_Init(SHA512_CTX *c);
  30. int SHA512_Update(SHA512_CTX *c, const void *data, size_t len);
  31. int SHA512_Final(unsigned char *md, SHA512_CTX *c);
  32. =head1 DESCRIPTION
  33. All of the functions described on this page
  34. except for SHA1(), SHA224(), SHA256(), SHA384() and SHA512() are deprecated.
  35. Applications should instead use L<EVP_DigestInit_ex(3)>, L<EVP_DigestUpdate(3)>
  36. and L<EVP_DigestFinal_ex(3)>, or the quick one-shot function L<EVP_Q_digest(3)>.
  37. SHA1(), SHA224(), SHA256(), SHA384(), and SHA256()
  38. can continue to be used. They can also be replaced by, e.g.,
  39. (EVP_Q_digest(d, n, md, NULL, NULL, "SHA256", NULL) ? md : NULL)
  40. SHA-1 (Secure Hash Algorithm) is a cryptographic hash function with a
  41. 160 bit output.
  42. SHA1() computes the SHA-1 message digest of the B<n>
  43. bytes at B<d> and places it in B<md> (which must have space for
  44. SHA_DIGEST_LENGTH == 20 bytes of output). If B<md> is NULL, the digest
  45. is placed in a static array. Note: setting B<md> to NULL is B<not thread safe>.
  46. The following functions may be used if the message is not completely
  47. stored in memory:
  48. SHA1_Init() initializes a B<SHA_CTX> structure.
  49. SHA1_Update() can be called repeatedly with chunks of the message to
  50. be hashed (B<len> bytes at B<data>).
  51. SHA1_Final() places the message digest in B<md>, which must have space
  52. for SHA_DIGEST_LENGTH == 20 bytes of output, and erases the B<SHA_CTX>.
  53. The SHA224, SHA256, SHA384 and SHA512 families of functions operate in the
  54. same way as for the SHA1 functions. Note that SHA224 and SHA256 use a
  55. B<SHA256_CTX> object instead of B<SHA_CTX>. SHA384 and SHA512 use B<SHA512_CTX>.
  56. The buffer B<md> must have space for the output from the SHA variant being used
  57. (defined by SHA224_DIGEST_LENGTH, SHA256_DIGEST_LENGTH, SHA384_DIGEST_LENGTH and
  58. SHA512_DIGEST_LENGTH). Also note that, as for the SHA1() function above, the
  59. SHA224(), SHA256(), SHA384() and SHA512() functions are not thread safe if
  60. B<md> is NULL.
  61. =head1 RETURN VALUES
  62. SHA1(), SHA224(), SHA256(), SHA384() and SHA512() return a pointer to the hash
  63. value.
  64. SHA1_Init(), SHA1_Update() and SHA1_Final() and equivalent SHA224, SHA256,
  65. SHA384 and SHA512 functions return 1 for success, 0 otherwise.
  66. =head1 CONFORMING TO
  67. US Federal Information Processing Standard FIPS PUB 180-4 (Secure Hash
  68. Standard),
  69. ANSI X9.30
  70. =head1 SEE ALSO
  71. L<EVP_Q_digest(3)>,
  72. L<EVP_DigestInit(3)>
  73. =head1 HISTORY
  74. All of these functions except SHA*() were deprecated in OpenSSL 3.0.
  75. =head1 COPYRIGHT
  76. Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
  77. Licensed under the Apache License 2.0 (the "License"). You may not use
  78. this file except in compliance with the License. You can obtain a copy
  79. in the file LICENSE in the source distribution or at
  80. L<https://www.openssl.org/source/license.html>.
  81. =cut