Credential.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #include "TriviallyCopyable.hpp"
  24. namespace ZeroTier {
  25. class Capability;
  26. class Revocation;
  27. class Tag;
  28. class CertificateOfMembership;
  29. class CertificateOfOwnership;
  30. class RuntimeEnvironment;
  31. /**
  32. * Base class for credentials
  33. */
  34. class Credential : public TriviallyCopyable
  35. {
  36. public:
  37. /**
  38. * Result of verify() operations
  39. */
  40. enum VerifyResult
  41. {
  42. VERIFY_OK = 0,
  43. VERIFY_BAD_SIGNATURE = 1,
  44. VERIFY_NEED_IDENTITY = 2
  45. };
  46. protected:
  47. VerifyResult _verify(const RuntimeEnvironment *RR,void *tPtr,const CertificateOfMembership &credential) const;
  48. VerifyResult _verify(const RuntimeEnvironment *RR,void *tPtr,const Revocation &credential) const;
  49. VerifyResult _verify(const RuntimeEnvironment *RR,void *tPtr,const Tag &credential) const;
  50. VerifyResult _verify(const RuntimeEnvironment *RR,void *tPtr,const CertificateOfOwnership &credential) const;
  51. VerifyResult _verify(const RuntimeEnvironment *RR,void *tPtr,const Capability &credential) const;
  52. };
  53. } // namespace ZeroTier
  54. #endif