Files

41 lines
977 B
C++
Raw Permalink Normal View History

2025-08-06 12:10:18 -04:00
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
2025-08-06 12:10:18 -04:00
* (c) ZeroTier, Inc.
* https://www.zerotier.com/
*/
#include "Revocation.hpp"
2025-07-03 11:26:23 -04:00
#include "Identity.hpp"
#include "Network.hpp"
2017-08-23 16:42:17 -07:00
#include "Node.hpp"
2025-07-03 11:26:23 -04:00
#include "RuntimeEnvironment.hpp"
#include "Switch.hpp"
#include "Topology.hpp"
namespace ZeroTier {
2025-07-03 11:26:23 -04:00
int Revocation::verify(const RuntimeEnvironment* RR, void* tPtr) const
{
2025-07-03 11:26:23 -04:00
if ((! _signedBy) || (_signedBy != Network::controllerFor(_networkId))) {
return -1;
2023-05-01 14:48:16 -04:00
}
2025-07-03 11:26:23 -04:00
const Identity id(RR->topology->getIdentity(tPtr, _signedBy));
if (! id) {
RR->sw->requestWhois(tPtr, RR->node->now(), _signedBy);
return 1;
}
try {
Buffer<sizeof(Revocation) + 64> tmp;
2025-07-03 11:26:23 -04:00
this->serialize(tmp, true);
return (id.verify(tmp.data(), tmp.size(), _signature) ? 0 : -1);
}
catch (...) {
return -1;
}
}
2025-07-03 11:26:23 -04:00
} // namespace ZeroTier