Revocation.cpp 977 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
  4. *
  5. * (c) ZeroTier, Inc.
  6. * https://www.zerotier.com/
  7. */
  8. #include "Revocation.hpp"
  9. #include "Identity.hpp"
  10. #include "Network.hpp"
  11. #include "Node.hpp"
  12. #include "RuntimeEnvironment.hpp"
  13. #include "Switch.hpp"
  14. #include "Topology.hpp"
  15. namespace ZeroTier {
  16. int Revocation::verify(const RuntimeEnvironment* RR, void* tPtr) const
  17. {
  18. if ((! _signedBy) || (_signedBy != Network::controllerFor(_networkId))) {
  19. return -1;
  20. }
  21. const Identity id(RR->topology->getIdentity(tPtr, _signedBy));
  22. if (! id) {
  23. RR->sw->requestWhois(tPtr, RR->node->now(), _signedBy);
  24. return 1;
  25. }
  26. try {
  27. Buffer<sizeof(Revocation) + 64> tmp;
  28. this->serialize(tmp, true);
  29. return (id.verify(tmp.data(), tmp.size(), _signature) ? 0 : -1);
  30. }
  31. catch (...) {
  32. return -1;
  33. }
  34. }
  35. } // namespace ZeroTier