sha1.h 1.1 KB

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