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.

86 lines
3.0 KiB

  1. // HashMD5.cpp -- definition of MD5Hash
  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 "HashMD5.h"
  10. using namespace std;
  11. /////////////////////////// LOCAL/HELPER /////////////////////////////////
  12. /////////////////////////// PUBLIC /////////////////////////////////
  13. // Types
  14. // C'tors/D'tors
  15. CHashMD5::CHashMD5(CryptContext const &rcryptctx)
  16. : CHashContext(rcryptctx, CALG_MD5)
  17. {}
  18. CHashMD5::~CHashMD5() throw()
  19. {}
  20. // Operators
  21. // Operations
  22. auto_ptr<CHashContext>
  23. CHashMD5::Clone(DWORD const *pdwReserved,
  24. DWORD dwFlags) const
  25. {
  26. return auto_ptr<CHashContext>(new CHashMD5(*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. CHashMD5::CHashMD5(CHashMD5 const &rhs,
  36. DWORD const *pdwReserved,
  37. DWORD dwFlags)
  38. : CHashContext(rhs, pdwReserved, dwFlags)
  39. {}
  40. // Operators
  41. // Operations
  42. // Access
  43. Blob
  44. CHashMD5::EncodedAlgorithmOid()
  45. {
  46. // MD5 Algorithm Object IDentifier (OID) in ASN.1 format (little endian)
  47. static unsigned char const sMd5Oid[] =
  48. {
  49. '\x30', '\x20', '\x30', '\x0c', '\x06', '\x08',
  50. '\x2a', '\x86', '\x48', '\x86', '\xf7', '\x0d',
  51. '\x02', '\x05', '\x05', '\x00', '\x04', '\x10'
  52. };
  53. return Blob(sMd5Oid, sizeof sMd5Oid / sizeof *sMd5Oid);
  54. }
  55. // Predicates
  56. // Static Variables
  57. /////////////////////////// PRIVATE /////////////////////////////////
  58. // C'tors/D'tors
  59. // Operators
  60. // Operations
  61. // Access
  62. // Predicates
  63. // Static Variables