nsCryptoHash.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. *
  3. * This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6. #ifndef _nsCryptoHash_h_
  7. #define _nsCryptoHash_h_
  8. #include "nsICryptoHash.h"
  9. #include "nsICryptoHMAC.h"
  10. #include "nsNSSShutDown.h"
  11. #include "hasht.h"
  12. #include "secmodt.h"
  13. class nsIInputStream;
  14. #define NS_CRYPTO_HASH_CID {0x36a1d3b3, 0xd886, 0x4317, {0x96, 0xff, 0x87, 0xb0, 0x00, 0x5c, 0xfe, 0xf7}}
  15. #define NS_CRYPTO_HMAC_CID {0xa496d0a2, 0xdff7, 0x4e23, {0xbd, 0x65, 0x1c, 0xa7, 0x42, 0xfa, 0x17, 0x8a}}
  16. class nsCryptoHash final : public nsICryptoHash, public nsNSSShutDownObject
  17. {
  18. public:
  19. NS_DECL_ISUPPORTS
  20. NS_DECL_NSICRYPTOHASH
  21. nsCryptoHash();
  22. private:
  23. ~nsCryptoHash();
  24. HASHContext* mHashContext;
  25. bool mInitialized;
  26. virtual void virtualDestroyNSSReference() override;
  27. void destructorSafeDestroyNSSReference();
  28. };
  29. class nsCryptoHMAC : public nsICryptoHMAC, public nsNSSShutDownObject
  30. {
  31. public:
  32. NS_DECL_ISUPPORTS
  33. NS_DECL_NSICRYPTOHMAC
  34. nsCryptoHMAC();
  35. private:
  36. ~nsCryptoHMAC();
  37. PK11Context* mHMACContext;
  38. virtual void virtualDestroyNSSReference() override;
  39. void destructorSafeDestroyNSSReference();
  40. };
  41. #endif // _nsCryptoHash_h_