esp8266ndn
NDN Arduino library for ESP8266 and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
default.hpp
Go to the documentation of this file.
1#ifndef NDNPH_PORT_TIMINGSAFE_DEFAULT_HPP
2#define NDNPH_PORT_TIMINGSAFE_DEFAULT_HPP
3
4#include "../../core/common.hpp"
5
6namespace ndnph {
7namespace port_timingsafe_default {
8
14public:
15 bool operator()(const uint8_t* a, size_t aLen, const uint8_t* b, size_t bLen) const {
16 if (aLen != bLen) {
17 return false;
18 }
19 uint8_t result = 0;
20 for (size_t i = 0; i < aLen; ++i) {
21 result |= a[i] ^ b[i];
22 }
23 return result == 0;
24 }
25};
26
27} // namespace port_timingsafe_default
28
29#ifdef NDNPH_PORT_TIMINGSAFE_DEFAULT
30namespace port {
31using TimingSafeEqual = port_timingsafe_default::TimingSafeEqual;
32} // namespace port
33#endif
34
35} // namespace ndnph
36
37#endif // NDNPH_PORT_TIMINGSAFE_DEFAULT_HPP
Timing safe equality comparison.
Definition default.hpp:13
bool operator()(const uint8_t *a, size_t aLen, const uint8_t *b, size_t bLen) const
Definition default.hpp:15
Definition fs.hpp:33