SHA512.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * An implementation of the SHA-512 hash function.
  3. *
  4. * The Federal Information Processing Standards (FIPS) Specification
  5. * can be found here (FIPS 180-3):
  6. * http://csrc.nist.gov/publications/PubsFIPS.html
  7. *
  8. * Written in 2010 by Lorenz Quack <don@amberfisharts.com>
  9. *
  10. * ===================================================================
  11. * The contents of this file are dedicated to the public domain. To
  12. * the extent that dedication to the public domain is not available,
  13. * everyone is granted a worldwide, perpetual, royalty-free,
  14. * non-exclusive license to exercise all rights associated with the
  15. * contents of this file for any purpose whatsoever.
  16. * No rights are reserved.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  21. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  22. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  23. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  24. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  25. * SOFTWARE.
  26. * ===================================================================
  27. *
  28. */
  29. #define MODULE_NAME SHA512
  30. #define DIGEST_SIZE (512/8)
  31. #define WORD_SIZE 8
  32. #include "common.h"
  33. /* Initial Values H for SHA-512, SHA-512/224 and SHA-512/256 */
  34. static const uint64_t H_SHA_512[3][8] = {
  35. {
  36. 0x6a09e667f3bcc908ULL,
  37. 0xbb67ae8584caa73bULL,
  38. 0x3c6ef372fe94f82bULL,
  39. 0xa54ff53a5f1d36f1ULL,
  40. 0x510e527fade682d1ULL,
  41. 0x9b05688c2b3e6c1fULL,
  42. 0x1f83d9abfb41bd6bULL,
  43. 0x5be0cd19137e2179ULL
  44. },
  45. {
  46. 0x8C3D37C819544DA2ULL,
  47. 0x73E1996689DCD4D6ULL,
  48. 0x1DFAB7AE32FF9C82ULL,
  49. 0x679DD514582F9FCFULL,
  50. 0x0F6D2B697BD44DA8ULL,
  51. 0x77E36F7304C48942ULL,
  52. 0x3F9D85A86A1D36C8ULL,
  53. 0x1112E6AD91D692A1ULL
  54. },
  55. {
  56. 0x22312194FC2BF72CULL,
  57. 0x9F555FA3C84C64C2ULL,
  58. 0x2393B86B6F53B151ULL,
  59. 0x963877195940EABDULL,
  60. 0x96283EE2A88EFFE3ULL,
  61. 0xBE5E1E2553863992ULL,
  62. 0x2B0199FC2C85B8AAULL,
  63. 0x0EB72DDC81C52CA2ULL
  64. }
  65. };
  66. #include "hash_SHA2_template.c"