esp8266ndn
NDN Arduino library for ESP8266 and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ec-uecc.hpp
Go to the documentation of this file.
1 #ifndef ESP8266NDN_PORT_EC_UECC_HPP
2 #define ESP8266NDN_PORT_EC_UECC_HPP
3 
4 #include "choose.h"
5 
6 #ifdef ESP8266NDN_PORT_EC_UECC
7 
8 #include "../vendor/uECC.h"
9 #include <sys/types.h>
10 #include <type_traits>
11 
12 namespace esp8266ndn {
13 namespace ndnph_port_uecc {
14 
16 class Ec {
17 public:
18  struct Curve {
19  using PvtLen = std::integral_constant<size_t, uECC_BYTES>;
20  using PubLen = std::integral_constant<size_t, 1 + uECC_BYTES * 2>;
21  using MaxSigLen = std::integral_constant<size_t, 9 + uECC_BYTES * 2>;
22  };
23 
24  class PrivateKey {
25  public:
26  bool import(const uint8_t key[Curve::PubLen::value]);
27 
28  ssize_t sign(const uint8_t digest[uECC_BYTES], uint8_t sig[Curve::MaxSigLen::value]) const;
29 
30  private:
31  uint8_t m_key[uECC_BYTES];
32  };
33 
34  class PublicKey {
35  public:
36  bool import(const uint8_t[Curve::PubLen::value]);
37 
38  bool verify(const uint8_t digest[uECC_BYTES], const uint8_t* sig, size_t sigLen) const;
39 
40  private:
41  uint8_t m_key[2 * uECC_BYTES];
42  };
43 
44  static bool generateKey(uint8_t pvt[Curve::PvtLen::value], uint8_t pub[Curve::PubLen::value]);
45 };
46 
47 } // namespace ndnph_port_uecc
48 } // namespace esp8266ndn
49 
50 namespace ndnph {
51 namespace port {
52 using Ec = esp8266ndn::ndnph_port_uecc::Ec;
53 } // namespace port
54 } // namespace ndnph
55 
56 #endif // ESP8266NDN_PORT_EC_UECC
57 #endif // ESP8266NDN_PORT_EC_UECC_HPP
Definition: autoconfig.hpp:24
port::Ec::Curve::PvtLen PvtLen
Definition: ec.hpp:14
port::Ec::Curve::PubLen PubLen
Definition: ec.hpp:15
Definition: fs.hpp:33