esp8266ndn
NDN Arduino library for ESP8266 and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
keychain.hpp
Go to the documentation of this file.
1#ifndef NDNPH_KEYCHAIN_KEYCHAIN_HPP
2#define NDNPH_KEYCHAIN_KEYCHAIN_HPP
3
4#include "../packet/data.hpp"
5#include "../port/fs/port.hpp"
6#include "../store/packet.hpp"
7
8namespace ndnph {
9
16class KeyChainKeys : public KvStore {
17public:
18 using KvStore::KvStore;
19};
20
22class KeyChainCerts : public PacketStore<Data> {
23public:
24 using PacketStore::PacketStore;
25
26 Data get(const char* id, Region& region) {
27 Data data = PacketStore::get(id, region);
28 if (!data || !certificate::isCertificate(data)) {
29 return Data();
30 }
31 return data;
32 }
33};
34
36class KeyChain {
37public:
38 explicit KeyChain() = default;
39
41 : keys(fs)
42 , certs(fs) {}
43
45 template<typename... Arg>
46 bool open(Arg&&... arg) {
47 return keys.open(std::forward<Arg>(arg)...) && certs.open(std::forward<Arg>(arg)...);
48 }
49
50public:
53};
54
55} // namespace ndnph
56
57#endif // NDNPH_KEYCHAIN_KEYCHAIN_HPP
File storage on microcontroller filesystem.
Definition fs.hpp:11
Data packet.
Definition data.hpp:136
File based certificate store.
Definition keychain.hpp:22
Data get(const char *id, Region &region)
Definition keychain.hpp:26
File based key pair store.
Definition keychain.hpp:16
File based key and certificate store.
Definition keychain.hpp:36
bool open(Arg &&... arg)
Open the FileStore backend in both key store and certificate store.
Definition keychain.hpp:46
KeyChain(port::FileStore &fs)
Definition keychain.hpp:40
KeyChain()=default
KeyChainCerts certs
Definition keychain.hpp:52
KeyChainKeys keys
Definition keychain.hpp:51
File based key-value store.
Definition kv.hpp:10
bool open(Arg &&... arg)
Open the FileStore backend.
Definition kv.hpp:24
KvStore()=default
Constructor to use internal FileStore instance.
File based packet store.
Definition packet.hpp:13
T get(const char *key, Region &region)
Retrieve a packet.
Definition packet.hpp:23
Region-based memory allocator thats owns memory of NDNph objects.
Definition region.hpp:9
bool isCertificate(const Data &data)
Determine if the Data packet is a certificate.
Definition certificate.hpp:170
Definition fs.hpp:33