Source code pulled from OpenBSD for OpenNTPD. The place to contribute to this code is via the OpenBSD CVS tree.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.9 KiB

  1. /* $OpenBSD: sha1.h,v 1.16 2004/01/22 21:48:02 espie Exp $ */
  2. /*
  3. * SHA-1 in C
  4. * By Steve Reid <steve@edmweb.com>
  5. * 100% Public Domain
  6. */
  7. #ifndef _SHA1_H
  8. #define _SHA1_H
  9. typedef struct {
  10. u_int32_t state[5];
  11. u_int32_t count[2];
  12. unsigned char buffer[64];
  13. } SHA1_CTX;
  14. #include <sys/cdefs.h>
  15. __BEGIN_DECLS
  16. void SHA1Transform(u_int32_t [5], const unsigned char [64])
  17. __attribute__((__bounded__(__minbytes__,1,5)))
  18. __attribute__((__bounded__(__minbytes__,2,64)));
  19. void SHA1Init(SHA1_CTX *);
  20. void SHA1Update(SHA1_CTX *, const unsigned char *, unsigned int)
  21. __attribute__((__bounded__(__string__,2,3)));
  22. void SHA1Final(unsigned char [20], SHA1_CTX *)
  23. __attribute__((__bounded__(__minbytes__,1,20)));
  24. char *SHA1End(SHA1_CTX *, char *)
  25. __attribute__((__bounded__(__minbytes__,2,41)));
  26. char *SHA1File(char *, char *)
  27. __attribute__((__bounded__(__minbytes__,2,41)));
  28. char *SHA1Data(const unsigned char *, size_t, char *)
  29. __attribute__((__bounded__(__string__,1,2)))
  30. __attribute__((__bounded__(__minbytes__,3,41)));
  31. __END_DECLS
  32. #define SHA1_DIGESTSIZE 20
  33. #define SHA1_BLOCKSIZE 64
  34. #define HTONDIGEST(x) do { \
  35. x[0] = htonl(x[0]); \
  36. x[1] = htonl(x[1]); \
  37. x[2] = htonl(x[2]); \
  38. x[3] = htonl(x[3]); \
  39. x[4] = htonl(x[4]); } while (0)
  40. #define NTOHDIGEST(x) do { \
  41. x[0] = ntohl(x[0]); \
  42. x[1] = ntohl(x[1]); \
  43. x[2] = ntohl(x[2]); \
  44. x[3] = ntohl(x[3]); \
  45. x[4] = ntohl(x[4]); } while (0)
  46. #endif /* _SHA1_H */