sha1.h 1.1 KB

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