SHA256.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * An implementation of the SHA-256 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 SHA256
  30. #define DIGEST_SIZE (256/8)
  31. #define WORD_SIZE 4
  32. #include "common.h"
  33. /* Initial Values H */
  34. static const uint32_t H[8] = {
  35. 0x6a09e667,
  36. 0xbb67ae85,
  37. 0x3c6ef372,
  38. 0xa54ff53a,
  39. 0x510e527f,
  40. 0x9b05688c,
  41. 0x1f83d9ab,
  42. 0x5be0cd19
  43. };
  44. #include "hash_SHA2_template.c"