sha.h 921 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * @file re_sha.h Interface to SHA (Secure Hash Standard) functions
  3. *
  4. * Copyright (C) 2010 Creytiv.com
  5. */
  6. #ifndef SHA_H_
  7. #define SHA_H_ (1)
  8. #ifdef USE_OPENSSL
  9. #include <openssl/sha.h>
  10. #else
  11. /* public api for steve reid's public domain SHA-1 implementation */
  12. /* this file is in the public domain */
  13. /** SHA-1 Context */
  14. typedef struct {
  15. uint32_t state[5];
  16. /**< Context state */
  17. uint32_t count[2];
  18. /**< Counter */
  19. uint8_t buffer[64]; /**< SHA-1 buffer */
  20. } SHA1_CTX;
  21. /** SHA-1 Context (OpenSSL compat) */
  22. typedef SHA1_CTX SHA_CTX;
  23. /** SHA-1 Digest size in bytes */
  24. #define SHA1_DIGEST_SIZE 20
  25. /** SHA-1 Digest size in bytes (OpenSSL compat) */
  26. #define SHA_DIGEST_LENGTH SHA1_DIGEST_SIZE
  27. void SHA1_Init(SHA1_CTX *context);
  28. void SHA1_Update(SHA1_CTX *context, const void *p, size_t len);
  29. void SHA1_Final(uint8_t digest[SHA1_DIGEST_SIZE], SHA1_CTX *context);
  30. #endif
  31. #endif // SHA_H_