Revocation.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c)2019 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: 2026-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. #include "Revocation.hpp"
  14. #include "Identity.hpp"
  15. #include "Network.hpp"
  16. #include "Node.hpp"
  17. #include "RuntimeEnvironment.hpp"
  18. #include "Switch.hpp"
  19. #include "Topology.hpp"
  20. namespace ZeroTier {
  21. int Revocation::verify(const RuntimeEnvironment* RR, void* tPtr) const
  22. {
  23. if ((! _signedBy) || (_signedBy != Network::controllerFor(_networkId))) {
  24. return -1;
  25. }
  26. const Identity id(RR->topology->getIdentity(tPtr, _signedBy));
  27. if (! id) {
  28. RR->sw->requestWhois(tPtr, RR->node->now(), _signedBy);
  29. return 1;
  30. }
  31. try {
  32. Buffer<sizeof(Revocation) + 64> tmp;
  33. this->serialize(tmp, true);
  34. return (id.verify(tmp.data(), tmp.size(), _signature) ? 0 : -1);
  35. }
  36. catch (...) {
  37. return -1;
  38. }
  39. }
  40. } // namespace ZeroTier