Source code of Windows XP (NT5)
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.

87 lines
3.0 KiB

  1. // HashSHA1.cpp -- definition of CHashSHA1
  2. // (c) Copyright Schlumberger Technology Corp., unpublished work, created
  3. // 1998. This computer program includes Confidential, Proprietary
  4. // Information and is a Trade Secret of Schlumberger Technology Corp. All
  5. // use, disclosure, and/or reproduction is prohibited unless authorized
  6. // in writing. All Rights Reserved.
  7. #include "stdafx.h" // because handles.h uses the ASSERT macro
  8. #include <memory> // for auto_ptr
  9. #include "HashSHA1.h"
  10. using namespace std;
  11. /////////////////////////// LOCAL/HELPER /////////////////////////////////
  12. /////////////////////////// PUBLIC /////////////////////////////////
  13. // Types
  14. // C'tors/D'tors
  15. CHashSHA1::CHashSHA1(CryptContext const &rcryptctx)
  16. : CHashContext(rcryptctx, CALG_SHA)
  17. {}
  18. CHashSHA1::~CHashSHA1() throw()
  19. {}
  20. // Operators
  21. // Operations
  22. auto_ptr<CHashContext>
  23. CHashSHA1::Clone(DWORD const *pdwReserved,
  24. DWORD dwFlags) const
  25. {
  26. return auto_ptr<CHashContext>(new CHashSHA1(*this, pdwReserved,
  27. dwFlags));
  28. }
  29. // Access
  30. // Predicates
  31. // Static Variables
  32. /////////////////////////// PROTECTED /////////////////////////////////
  33. // C'tors/D'tors
  34. // Duplicate the hash and its state
  35. CHashSHA1::CHashSHA1(CHashSHA1 const &rhs,
  36. DWORD const *pdwReserved,
  37. DWORD dwFlags)
  38. : CHashContext(rhs, pdwReserved, dwFlags)
  39. {}
  40. // Operators
  41. // Operations
  42. // Access
  43. Blob
  44. CHashSHA1::EncodedAlgorithmOid()
  45. {
  46. // SHA1 Algorithm Object IDentifier (OID) in ASN.1 format (little endian)
  47. static unsigned char const sSha1AlgOid[] =
  48. {
  49. '\x30', '\x21', '\x30', '\x09', '\x06',
  50. '\x05', '\x2b', '\x0e', '\x03', '\x02',
  51. '\x1a', '\x05', '\x00', '\x04', '\x14'
  52. };
  53. return Blob(sSha1AlgOid, sizeof sSha1AlgOid / sizeof *sSha1AlgOid);
  54. }
  55. // Predicates
  56. // Static Variables
  57. /////////////////////////// PRIVATE /////////////////////////////////
  58. // C'tors/D'tors
  59. // Operators
  60. // Operations
  61. // Access
  62. // Predicates
  63. // Static Variables