Credential.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c)2013-2020 ZeroTier, Inc.
  3. *
  4. * Use of this software is governed by the Business Source License included
  5. * in the LICENSE.TXT file in the project's root directory.
  6. *
  7. * Change Date: 2024-01-01
  8. *
  9. * On the date above, in accordance with the Business Source License, use
  10. * of this software will be governed by version 2.0 of the Apache License.
  11. */
  12. /****/
  13. #ifndef ZT_CREDENTIAL_HPP
  14. #define ZT_CREDENTIAL_HPP
  15. #include <string>
  16. #include <memory>
  17. #include <stdexcept>
  18. #include <cstdio>
  19. #include <cstdlib>
  20. #include <cstdint>
  21. #include <cstring>
  22. #include "Constants.hpp"
  23. namespace ZeroTier {
  24. class Capability;
  25. class Revocation;
  26. class Tag;
  27. class CertificateOfMembership;
  28. class CertificateOfOwnership;
  29. class RuntimeEnvironment;
  30. /**
  31. * Base class for credentials
  32. */
  33. class Credential
  34. {
  35. public:
  36. /**
  37. * Result of verify() operations
  38. */
  39. enum VerifyResult
  40. {
  41. VERIFY_OK = 0,
  42. VERIFY_BAD_SIGNATURE = 1,
  43. VERIFY_NEED_IDENTITY = 2
  44. };
  45. protected:
  46. VerifyResult _verify(const RuntimeEnvironment *RR,void *tPtr,const CertificateOfMembership &credential) const;
  47. VerifyResult _verify(const RuntimeEnvironment *RR,void *tPtr,const Revocation &credential) const;
  48. VerifyResult _verify(const RuntimeEnvironment *RR,void *tPtr,const Tag &credential) const;
  49. VerifyResult _verify(const RuntimeEnvironment *RR,void *tPtr,const CertificateOfOwnership &credential) const;
  50. VerifyResult _verify(const RuntimeEnvironment *RR,void *tPtr,const Capability &credential) const;
  51. };
  52. } // namespace ZeroTier
  53. #endif