sha1.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 <string>
  14. #include <cstring>
  15. #include <algorithm>
  16. #include "hashsum_template.h"
  17. #ifndef APT_8_CLEANER_HEADERS
  18. using std::string;
  19. using std::min;
  20. #endif
  21. typedef HashSumValue<160> SHA1SumValue;
  22. class SHA1Summation : public SummationImplementation
  23. {
  24. /* assumes 64-bit alignment just in case */
  25. unsigned char Buffer[64] __attribute__((aligned(8)));
  26. unsigned char State[5*4] __attribute__((aligned(8)));
  27. unsigned char Count[2*4] __attribute__((aligned(8)));
  28. bool Done;
  29. public:
  30. bool Add(const unsigned char *inbuf, unsigned long long inlen);
  31. using SummationImplementation::Add;
  32. SHA1SumValue Result();
  33. SHA1Summation();
  34. };
  35. #endif