sha1.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: sha1.h,v 1.3 2001/05/07 05:05:47 jgg Exp $
  4. /* ######################################################################
  5. SHA1SumValue - Storage for a SHA-1 hash.
  6. SHA1Summation - SHA-1 Secure Hash Algorithm.
  7. This is a C++ interface to a set of SHA1Sum functions, that mirrors
  8. the equivalent MD5 classes.
  9. ##################################################################### */
  10. /*}}}*/
  11. #ifndef APTPKG_SHA1_H
  12. #define APTPKG_SHA1_H
  13. #include "hashsum_template.h"
  14. #ifndef APT_10_CLEANER_HEADERS
  15. #include <string>
  16. #include <cstring>
  17. #include <algorithm>
  18. #endif
  19. #ifndef APT_8_CLEANER_HEADERS
  20. using std::string;
  21. using std::min;
  22. #endif
  23. typedef HashSumValue<160> SHA1SumValue;
  24. class SHA1Summation : public SummationImplementation
  25. {
  26. /* assumes 64-bit alignment just in case */
  27. unsigned char Buffer[64] __attribute__((aligned(8)));
  28. unsigned char State[5*4] __attribute__((aligned(8)));
  29. unsigned char Count[2*4] __attribute__((aligned(8)));
  30. bool Done;
  31. public:
  32. bool Add(const unsigned char *inbuf, unsigned long long inlen) APT_OVERRIDE APT_NONNULL(2);
  33. using SummationImplementation::Add;
  34. SHA1SumValue Result();
  35. SHA1Summation();
  36. };
  37. #endif