sha512.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Declaration of functions and data types used for SHA512 sum computing
  2. library functions.
  3. Copyright (C) 2007 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #ifndef _SHA512_H
  17. #define _SHA512_H 1
  18. #include <limits.h>
  19. #include <stdint.h>
  20. #include <stdio.h>
  21. /* Structure to save state of computation between the single steps. */
  22. struct sha512_ctx
  23. {
  24. uint64_t H[8];
  25. uint64_t total[2];
  26. uint64_t buflen;
  27. char buffer[256] __attribute__ ((__aligned__ (__alignof__ (uint64_t))));
  28. };
  29. /* Initialize structure containing state of computation.
  30. (FIPS 180-2: 5.3.3) */
  31. extern void __sha512_init_ctx (struct sha512_ctx *ctx) attribute_hidden;
  32. /* Starting with the result of former calls of this function (or the
  33. initialization function update the context for the next LEN bytes
  34. starting at BUFFER.
  35. It is NOT required that LEN is a multiple of 128. */
  36. extern void __sha512_process_bytes (const void *buffer, size_t len,
  37. struct sha512_ctx *ctx) attribute_hidden;
  38. /* Process the remaining bytes in the buffer and put result from CTX
  39. in first 64 bytes following RESBUF.
  40. IMPORTANT: On some systems it is required that RESBUF is correctly
  41. aligned for a 64 bits value. */
  42. extern void *__sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf)
  43. attribute_hidden;
  44. #endif /* sha512.h */