esp8266ndn
NDN Arduino library for ESP8266 and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
server.hpp
Go to the documentation of this file.
1#ifndef NDNPH_APP_NDNCERT_SERVER_HPP
2#define NDNPH_APP_NDNCERT_SERVER_HPP
3#ifdef NDNPH_HAVE_MBED
4
5#include "../../face/packet-handler.hpp"
6#include "an.hpp"
7#include "common.hpp"
8
9namespace ndnph {
10namespace ndncert {
11namespace server {
12
15
17 bool success = false;
18 bool decrementRetry = false;
19 const char* challengeStatus = "";
20 packet_struct::ParameterKV params;
21};
22
29class Challenge {
30public:
31 virtual ~Challenge() = default;
32
33 virtual tlv::Value getId() const = 0;
34 virtual int getTimeLimit() const = 0;
35 virtual int getRetryLimit() const = 0;
36
38 virtual void clear() = 0;
39
46 virtual ChallengeResult process(Region& region, const ChallengeRequest& request) = 0;
47};
48
49using ChallengeList = std::array<Challenge*, detail::MaxChallenges::value>;
50
52class CaProfile : public packet_struct::CaProfile {
53public:
59 Data::Signed toData(Region& region, const EcPrivateKey& signer) const {
60 Encoder encoder(region);
61 encoder.prepend([this](Encoder& encoder) { encoder.prependTlv(TT::CaPrefix, prefix); },
62 [](Encoder& encoder) { encoder.prependTlv(TT::CaInfo); },
63 [this](Encoder& encoder) {
64 encoder.prependTlv(TT::MaxValidityPeriod, tlv::NNI(maxValidityPeriod));
65 },
66 [this](Encoder& encoder) { encoder.prependTlv(TT::CaCertificate, cert); });
67 encoder.trim();
68
71
72 Data data = region.create<Data>();
73 if (!encoder || !name || !data) {
74 return Data::Signed();
75 }
76 data.setName(name);
77 data.setFreshnessPeriod(30000);
78 data.setIsFinalBlock(true);
79 data.setContent(tlv::Value(encoder));
80 return data.sign(signer);
81 }
82};
83
85class NewRequest : public packet_struct::NewRequest {
86public:
88 static bool isName(const CaProfile& profile, const Name& name) {
89 return name.size() == profile.prefix.size() + 3 && profile.prefix.isPrefixOf(name) &&
90 name[-3] == getCaComponent() && name[-2] == getNewComponent() &&
91 name[-1].is<convention::ParamsDigest>();
92 }
93
99 bool fromInterest(Region& region, const Interest& interest, const CaProfile& profile,
100 detail::ISigPolicy& signingPolicy) {
101 return isName(profile, interest.getName()) &&
103 EvDecoder::def<TT::EcdhPub>(&ecdhPub),
104 EvDecoder::def<TT::CertRequest>([&](const Decoder::Tlv& d) {
105 certRequest = region.create<Data>();
106 return !!certRequest && d.vd().decode(certRequest) &&
107 pub.import(region, certRequest);
108 })) &&
109 interest.verify(pub) && signingPolicy.check(*interest.getSigInfo());
110 }
111
112public:
115};
116
118class NewResponse : public packet_struct::NewResponse {
119public:
127 Data::Signed toData(Region& region, const Interest& newRequest, const ChallengeList& challenges,
128 const EcPrivateKey& signer) const {
129 Encoder encoder(region);
130 encoder.prepend(
131 [this](Encoder& encoder) { encoder.prependTlv(TT::EcdhPub, ecdhPub); },
132 [this](Encoder& encoder) { encoder.prependTlv(TT::Salt, tlv::Value(salt, sizeof(salt))); },
133 [this](Encoder& encoder) {
134 encoder.prependTlv(TT::RequestId, tlv::Value(requestId, sizeof(requestId)));
135 },
136 [&challenges](Encoder& encoder) {
137 for (auto it = challenges.rbegin(); it != challenges.rend(); ++it) {
138 const Challenge* ch = *it;
139 if (ch != nullptr) {
140 encoder.prependTlv(TT::Challenge, ch->getId());
141 }
142 }
143 });
144 encoder.trim();
145
146 Data data = region.create<Data>();
147 if (!encoder || !data || !newRequest) {
148 return Data::Signed();
149 }
150 data.setName(newRequest.getName());
151 data.setFreshnessPeriod(4000);
152 data.setContent(tlv::Value(encoder));
153 return data.sign(signer);
154 }
155};
156
158class ChallengeRequest : public packet_struct::ChallengeRequest<Challenge> {
159public:
161 static bool isName(const CaProfile& profile, const Name& name) {
162 return name.size() == profile.prefix.size() + 4 && profile.prefix.isPrefixOf(name) &&
163 name[-4] == getCaComponent() && name[-3] == getChallengeComponent() &&
164 name[-2].type() == TT::GenericNameComponent &&
165 name[-2].length() == detail::RequestIdLen::value &&
166 name[-1].is<convention::ParamsDigest>();
167 }
168
173 static const uint8_t* parseName(const CaProfile& profile, const Name& name) {
174 return isName(profile, name) ? name[-2].value() : nullptr;
175 }
176
182 bool fromInterest(Region& region, const Interest& interest, const CaProfile& profile,
183 const uint8_t* requestId, detail::SessionKey& sessionKey,
184 const EcPublicKey& verifier, const ChallengeList& challenges,
185 detail::ISigPolicy& signingPolicy) {
186 const uint8_t* actualRequestId = parseName(profile, interest.getName());
187 if (actualRequestId == nullptr ||
188 !std::equal(requestId, requestId + detail::RequestIdLen::value, actualRequestId) ||
189 !interest.verify(verifier) || !signingPolicy.check(*interest.getSigInfo())) {
190 return false;
191 }
192
193 auto decrypted = sessionKey.decrypt(region, interest.getAppParameters(), requestId);
194 packet_struct::ParameterKV::Parser paramsParser(params);
195 return !!decrypted &&
197 decrypted.makeDecoder(),
198 EvDecoder::def<TT::SelectedChallenge, false, 1>([&](const Decoder::Tlv& d) {
199 for (const auto& ch : challenges) {
200 if (ch == nullptr) {
201 continue;
202 }
203 if (ch->getId() == tlv::Value(d.value, d.length)) {
204 challenge = ch;
205 return true;
206 }
207 }
208 return false;
209 }),
210 EvDecoder::def<TT::ParameterKey, true, 2>(
211 [&](const Decoder::Tlv& d) { return paramsParser.parseKey(d); }),
212 EvDecoder::def<TT::ParameterValue, true, 2>(
213 [&](const Decoder::Tlv& d) { return paramsParser.parseValue(d); })) &&
214 challenge != nullptr;
215 }
216};
217
219class ChallengeResponse : public packet_struct::ChallengeResponse {
220public:
227 Data::Signed toData(Region& region, const Interest& challengeRequest, const uint8_t* requestId,
228 detail::SessionKey& sessionKey, const EcPrivateKey& signer) const {
229 Encoder encoder(region);
230 switch (status) {
231 case Status::FAILURE:
232 break;
233 case Status::SUCCESS:
234 encoder.prepend(
235 [this](Encoder& encoder) { encoder.prependTlv(TT::IssuedCertName, issuedCertName); },
236 [this](Encoder& encoder) { detail::encodeFwHint(encoder, fwHint); });
237 break;
238 default:
239 encoder.prepend(
240 [this](Encoder& encoder) { encoder.prependTlv(TT::ChallengeStatus, challengeStatus); },
241 tlv::NniElement<>(TT::RemainingTries, remainingTries),
242 [this](Encoder& encoder) {
243 uint64_t remainingTime =
244 std::max<int>(0, port::Clock::sub(expireTime, port::Clock::now())) / 1000;
245 encoder.prependTlv(TT::RemainingTime, tlv::NNI(remainingTime));
246 },
247 params);
248 break;
249 }
250 encoder.prepend(tlv::NniElement<>(TT::Status, status));
251 encoder.trim();
252 if (!encoder) {
253 return Data::Signed();
254 }
255 auto encrypted = sessionKey.encrypt(region, tlv::Value(encoder), requestId);
256
257 Data data = region.create<Data>();
258 if (!encrypted || !data || !challengeRequest) {
259 return Data::Signed();
260 }
261 data.setName(challengeRequest.getName());
262 data.setFreshnessPeriod(4000);
263 data.setContent(encrypted);
264 return data.sign(signer);
265 }
266};
267
268inline Data::Signed
269makeError(Region& region, const Interest& interest, uint8_t errorCode, const EcPrivateKey& signer) {
270 Encoder encoder(region);
271 encoder.prepend(tlv::NniElement<>(TT::ErrorCode, errorCode),
272 [](Encoder& encoder) { encoder.prependTlv(TT::ErrorInfo); });
273 encoder.trim();
274
275 Data data = region.create<Data>();
276 if (!encoder || !data || !interest) {
277 return Data::Signed();
278 }
279 data.setName(interest.getName());
280 data.setFreshnessPeriod(4000);
281 data.setContent(tlv::Value(encoder));
282 return data.sign(signer);
283}
284
286class Session {
287public:
288 explicit Session(const CaProfile& profile, const EcPrivateKey& signer,
289 const ChallengeList& challenges)
290 : m_challengeRegion(makeSubRegion(m_region, 512))
291 , m_profile(profile)
292 , m_signer(signer)
293 , m_challenges(challenges)
294 , m_signingPolicy(detail::makeISigPolicy()) {
295 NDNPH_ASSERT(m_challengeRegion != nullptr);
296 for (Challenge* ch : challenges) {
297 if (ch != nullptr) {
298 ch->clear();
299 }
300 }
301 }
302
303 Data::Signed handleNewRequest(Region& packetRegion, const Interest& interest) {
304 if (!m_newRequest.fromInterest(m_region, interest, m_profile, m_signingPolicy)) {
305 NDNPH_NDNCERT_LOG("NewRequest parse error");
306 return makeError(packetRegion, interest, ErrorCode::BadParameterFormat, m_signer);
307 }
308
309 // TODO check ValidityPeriod
310
311 mbedtls::Mpi ecdhPvt;
312 if (mbedtls_ecdh_gen_public(mbedtls::P256::group(), ecdhPvt, m_newResponse.ecdhPub,
313 mbedtls::rng, nullptr) != 0 ||
314 !port::RandomSource::generate(m_newResponse.salt, sizeof(m_newResponse.salt)) ||
315 !port::RandomSource::generate(m_newResponse.requestId, sizeof(m_newResponse.requestId)) ||
316 !m_sessionKey.makeKey(ecdhPvt, m_newRequest.ecdhPub, m_newResponse.salt,
317 m_newResponse.requestId)) {
318 NDNPH_NDNCERT_LOG("NewRequest ECDH or session key error");
319 return Data::Signed();
320 }
321
322 NDNPH_NDNCERT_LOG("NewResponse continue");
323 return m_newResponse.toData(packetRegion, interest, m_challenges, m_signer);
324 }
325
326 Data::Signed handleChallengeRequest(Region& packetRegion, const Interest& interest) {
327 m_challengeRegion->reset();
328 Challenge* prevChallenge = m_challengeRequest.challenge;
329 if (!m_challengeRequest.fromInterest(*m_challengeRegion, interest, m_profile,
330 m_newResponse.requestId, m_sessionKey, m_newRequest.pub,
331 m_challenges, m_signingPolicy)) {
332 NDNPH_NDNCERT_LOG("ChallengeRequest parse error");
333 return makeError(packetRegion, interest, ErrorCode::BadParameterFormat, m_signer);
334 }
335
336 auto now = port::Clock::now();
337 if (prevChallenge == nullptr) {
338 m_challengeResponse.status = Status::CHALLENGE;
339 m_challengeResponse.remainingTries = m_challengeRequest.challenge->getRetryLimit();
340 m_challengeResponse.expireTime =
341 port::Clock::add(now, m_challengeRequest.challenge->getTimeLimit());
342 } else if (m_challengeRequest.challenge != prevChallenge) {
343 NDNPH_NDNCERT_LOG("ChallengeRequest wrong challenge");
344 return makeError(packetRegion, interest, ErrorCode::OutOfTries, m_signer);
345 }
346
347 if (m_challengeResponse.remainingTries == 0) {
348 NDNPH_NDNCERT_LOG("ChallengeRequest out of tries");
349 return makeError(packetRegion, interest, ErrorCode::OutOfTries, m_signer);
350 }
351 if (port::Clock::isBefore(m_challengeResponse.expireTime, now)) {
352 NDNPH_NDNCERT_LOG("ChallengeRequest out of time");
353 return makeError(packetRegion, interest, ErrorCode::OutOfTime, m_signer);
354 }
355
356 ChallengeResult result =
357 m_challengeRequest.challenge->process(*m_challengeRegion, m_challengeRequest);
358 m_challengeResponse.challengeStatus = tlv::Value::fromString(result.challengeStatus);
359 m_challengeResponse.params = result.params;
360 if (result.success) {
361 m_issuedCert = m_region.create<Data>();
362 auto validity = certificate::getValidity(m_newRequest.certRequest);
363 if (m_issuedCert.decodeFrom(m_newRequest.pub.buildCertificate(
364 m_region, m_newRequest.pub.getName(), validity, m_signer)) &&
365 !!(m_challengeResponse.issuedCertName = m_issuedCert.getFullName(m_region))) {
366 m_challengeResponse.status = Status::SUCCESS;
367 m_challengeResponse.fwHint = m_profile.prefix.append(m_region, getCaComponent());
368 NDNPH_NDNCERT_LOG("ChallengeResponse cert issued");
369 } else {
370 m_challengeResponse.status = Status::PENDING;
371 NDNPH_NDNCERT_LOG("ChallengeResponse cert issuance error");
372 }
373 } else if (result.decrementRetry) {
374 --m_challengeResponse.remainingTries;
375 NDNPH_NDNCERT_LOG("ChallengeResponse decrement retry");
376 } else {
377 NDNPH_NDNCERT_LOG("ChallengeResponse continue");
378 }
379
380 return m_challengeResponse.toData(packetRegion, interest, m_newResponse.requestId, m_sessionKey,
381 m_signer);
382 }
383
384 const Name& getIssuedCertName() const {
385 return m_challengeResponse.issuedCertName;
386 }
387
388 const Data& getIssuedCert() const {
389 return m_issuedCert;
390 }
391
392private:
393 StaticRegion<2048> m_region;
394 Region* m_challengeRegion = nullptr;
395 const CaProfile& m_profile;
396 const EcPrivateKey& m_signer;
397 ChallengeList m_challenges;
398 detail::ISigPolicy m_signingPolicy;
399 NewRequest m_newRequest;
400 NewResponse m_newResponse;
401 detail::SessionKey m_sessionKey;
402 ChallengeRequest m_challengeRequest;
403 ChallengeResponse m_challengeResponse;
404 Data m_issuedCert;
405};
406
408class Server : public PacketHandler {
409public:
410 struct Options {
413
416
419
422 };
423
424 explicit Server(const Options& opts)
425 : PacketHandler(opts.face)
426 , m_profile(opts.profile)
427 , m_challenges(opts.challenges)
428 , m_signer(opts.signer) {}
429
430private:
431 bool processInterest(Interest interest) final {
432 StaticRegion<1024> packetRegion;
433 const Name& interestName = interest.getName();
434 if (NewRequest::isName(m_profile, interestName)) {
435 m_session.reset(new Session(m_profile, m_signer, m_challenges));
436 reply(m_session->handleNewRequest(packetRegion, interest));
437 return true;
438 } else if (m_session != nullptr && ChallengeRequest::isName(m_profile, interestName)) {
439 reply(m_session->handleChallengeRequest(packetRegion, interest));
440 return true;
441 } else if (m_session != nullptr && m_session->getIssuedCertName() == interestName) {
442 reply(m_session->getIssuedCert());
443 return true;
444 }
445 return false;
446 }
447
448private:
449 const CaProfile& m_profile;
450 ChallengeList m_challenges;
451 const EcPrivateKey& m_signer;
452 std::unique_ptr<Session> m_session;
453};
454
456class NopChallenge : public Challenge {
457public:
458 tlv::Value getId() const override {
459 return challenge_consts::nop();
460 }
461
462 int getTimeLimit() const override {
463 return 60000;
464 }
465
466 int getRetryLimit() const override {
467 return 1;
468 }
469
470 void clear() override {}
471
473 ChallengeResult result;
474 result.success = true;
475 return result;
476 }
477};
478
481public:
482 tlv::Value getId() const override {
483 return challenge_consts::possession();
484 }
485
486 int getTimeLimit() const override {
487 return 60000;
488 }
489
490 int getRetryLimit() const override {
491 return 1;
492 }
493
494 void clear() override {
495 m_cert = tlv::Value();
496 }
497
498 ChallengeResult process(Region&, const ChallengeRequest& request) override {
499 tlv::Value proof = request.params.get(challenge_consts::proof());
500 if (!proof) {
501 return process0(request);
502 }
503
504 ChallengeResult result;
505 result.success = process1(proof);
506 result.decrementRetry = !result.success;
507 return result;
508 }
509
510private:
511 ChallengeResult process0(const ChallengeRequest& request) {
512 m_cert = request.params.get(challenge_consts::issuedcert());
513
515 ndnph::Data data = temp.create<ndnph::Data>();
516 NDNPH_ASSERT(!!data);
517
518 m_region.reset();
519 if (!(m_cert.makeDecoder().decode(data) && m_pub.import(temp, data) &&
520 certificate::getValidity(data).includesUnix())) {
521 // don't reveal the error until proof is submitted
522 m_pub = EcPublicKey();
523 }
524 // TODO check certificate revocation
525 // TODO check name assignment policy
526
527 ChallengeResult result;
528 if (!port::RandomSource::generate(m_nonce, sizeof(m_nonce))) {
529 // server error, decrement retry to fail the challenge
530 result.decrementRetry = true;
531 result.challengeStatus = "server-error";
532 return result;
533 }
534
535 result.challengeStatus = "need-proof";
536 result.params.set(challenge_consts::nonce(), tlv::Value(m_nonce, sizeof(m_nonce)));
537 return result;
538 }
539
540 bool process1(tlv::Value proof) {
541 return m_pub.verify({tlv::Value(m_nonce, sizeof(m_nonce))}, proof.begin(), proof.size());
542 }
543
544private:
545 StaticRegion<256> m_region;
546 EcPublicKey m_pub;
547 tlv::Value m_cert;
548 uint8_t m_nonce[16];
549};
550
551} // namespace server
552
554
555} // namespace ndncert
556} // namespace ndnph
557
558#endif // NDNPH_HAVE_MBED
559#endif // NDNPH_APP_NDNCERT_SERVER_HPP
#define NDNPH_NDNCERT_LOG(...)
Definition common.hpp:15
Data packet.
Definition data.hpp:136
detail::SignedDataRef Signed
Result of Data::sign operation.
Definition data.hpp:246
void setContent(tlv::Value v)
Definition data.hpp:176
void setName(const Name &v)
Definition data.hpp:144
Signed sign(const PrivateKey &key, DSigInfo sigInfo=DSigInfo()) const
Sign the packet with a private key.
Definition data.hpp:254
void setFreshnessPeriod(uint32_t v)
Definition data.hpp:160
void setIsFinalBlock(bool v)
Definition data.hpp:168
Decoded TLV.
Definition decoder.hpp:13
TLV encoder that accepts items in reverse order.
Definition encoder.hpp:10
bool prepend(const First &first, const Arg &... arg)
Prepend a sequence of values.
Definition encoder.hpp:123
void trim() const
Release unused space to the Region.
Definition encoder.hpp:58
bool prependTlv(uint32_t type, OmitEmptyTag omitEmpty, const Arg &... arg)
Prepend TLV, measuring TLV-LENGTH automatically.
Definition encoder.hpp:143
static bool decodeValue(const Decoder &input, const E &... defs)
Decode input TLV-VALUE with a sequence of element definitions.
Definition ev-decoder.hpp:126
Network layer face.
Definition face.hpp:12
Interest packet.
Definition interest.hpp:284
const ISigInfo * getSigInfo() const
Retrieve SignatureInfo.
Definition interest.hpp:332
bool verify(const PublicKey &key) const
Verify the packet with a public key.
Definition interest.hpp:476
tlv::Value getAppParameters() const
Retrieve AppParameters.
Definition interest.hpp:321
Name.
Definition name.hpp:14
size_t length() const
Definition name.hpp:77
size_t size() const
Get number of components.
Definition name.hpp:86
const uint8_t * value() const
Definition name.hpp:81
Name append(Region &region, const C &... comps) const
Append a sequence of components.
Definition name.hpp:183
Base class to receive packets from Face.
Definition packet-handler.hpp:10
Region-based memory allocator thats owns memory of NDNph objects.
Definition region.hpp:9
RefType create(Arg &&... arg)
Allocate and create an object, and return its reference.
Definition region.hpp:90
Region with statically allocated memory.
Definition region.hpp:143
Indicate that TLV-VALUE should be a timestamp.
Definition convention.hpp:27
Definition convention.hpp:74
const Name & getName() const
Definition interest.hpp:68
Definition data.hpp:42
EC private key.
Definition ec.hpp:180
EC public key.
Definition ec.hpp:65
bool check(const ISigInfo &si)
Check that SigInfo fields fulfill current policy.
Definition sig-info.hpp:285
Multi-Precision Integer.
Definition mbed-common.hpp:102
Symmetric key used in CHALLENGE step.
Definition common.hpp:33
tlv::Value decrypt(Region &region, tlv::Value message, const uint8_t *requestId)
Decrypt from encrypted-message.
Definition common.hpp:53
tlv::Value encrypt(Region &region, tlv::Value plaintext, const uint8_t *requestId)
Encrypt to encrypted-message.
Definition common.hpp:48
CA profile packet.
Definition server.hpp:52
Data::Signed toData(Region &region, const EcPrivateKey &signer) const
Build CA profile packet.
Definition server.hpp:59
CHALLENGE request packet.
Definition server.hpp:158
bool fromInterest(Region &region, const Interest &interest, const CaProfile &profile, const uint8_t *requestId, detail::SessionKey &sessionKey, const EcPublicKey &verifier, const ChallengeList &challenges, detail::ISigPolicy &signingPolicy)
Extract CHALLENGE request from Interest packet.
Definition server.hpp:182
static bool isName(const CaProfile &profile, const Name &name)
Determine whether name is a valid CHALLENGE request packet name.
Definition server.hpp:161
static const uint8_t * parseName(const CaProfile &profile, const Name &name)
Extract requestId from Interest name.
Definition server.hpp:173
CHALLENGE response packet.
Definition server.hpp:219
Data::Signed toData(Region &region, const Interest &challengeRequest, const uint8_t *requestId, detail::SessionKey &sessionKey, const EcPrivateKey &signer) const
Build CHALLENGE response packet.
Definition server.hpp:227
Server side of a challenge.
Definition server.hpp:29
virtual tlv::Value getId() const =0
virtual ChallengeResult process(Region &region, const ChallengeRequest &request)=0
Process a CHALLENGE request packet.
virtual int getRetryLimit() const =0
virtual void clear()=0
Clear state and prepare the challenge for new session.
virtual int getTimeLimit() const =0
NEW request packet.
Definition server.hpp:85
EcPublicKey pub
Requester public key.
Definition server.hpp:114
bool fromInterest(Region &region, const Interest &interest, const CaProfile &profile, detail::ISigPolicy &signingPolicy)
Extract NEW request from Interest packet.
Definition server.hpp:99
static bool isName(const CaProfile &profile, const Name &name)
Determine whether name is a valid NEW request packet name.
Definition server.hpp:88
NEW response packet.
Definition server.hpp:118
Data::Signed toData(Region &region, const Interest &newRequest, const ChallengeList &challenges, const EcPrivateKey &signer) const
Build NEW response packet.
Definition server.hpp:127
The "nop" challenge where the server would approve every request.
Definition server.hpp:456
ChallengeResult process(Region &, const ChallengeRequest &) override
Process a CHALLENGE request packet.
Definition server.hpp:472
int getRetryLimit() const override
Definition server.hpp:466
tlv::Value getId() const override
Definition server.hpp:458
void clear() override
Clear state and prepare the challenge for new session.
Definition server.hpp:470
int getTimeLimit() const override
Definition server.hpp:462
The "possession" challenge where client must present an existing certificate.
Definition server.hpp:480
int getRetryLimit() const override
Definition server.hpp:490
tlv::Value getId() const override
Definition server.hpp:482
void clear() override
Clear state and prepare the challenge for new session.
Definition server.hpp:494
ChallengeResult process(Region &, const ChallengeRequest &request) override
Process a CHALLENGE request packet.
Definition server.hpp:498
int getTimeLimit() const override
Definition server.hpp:486
Server application.
Definition server.hpp:408
Server(const Options &opts)
Definition server.hpp:424
bool processInterest(Interest interest) final
Override to receive Interest packets.
Definition server.hpp:431
Server session logic.
Definition server.hpp:286
Data::Signed handleChallengeRequest(Region &packetRegion, const Interest &interest)
Definition server.hpp:326
const Data & getIssuedCert() const
Definition server.hpp:388
Session(const CaProfile &profile, const EcPrivateKey &signer, const ChallengeList &challenges)
Definition server.hpp:288
const Name & getIssuedCertName() const
Definition server.hpp:384
Data::Signed handleNewRequest(Region &packetRegion, const Interest &interest)
Definition server.hpp:303
NonNegativeInteger encoding.
Definition nni.hpp:118
Encode to a TLV element where TLV-VALUE is a NonNegativeInteger.
Definition nni.hpp:170
A sequence of bytes, usually TLV-VALUE.
Definition value.hpp:11
Decoder makeDecoder() const
Create a Decoder over this value buffer.
Definition value.hpp:64
const uint8_t * begin() const
Definition value.hpp:38
size_t size() const
Definition value.hpp:46
#define NDNPH_ASSERT(x)
Definition common.hpp:30
@ GenericNameComponent
Definition an.hpp:20
detail::TypedNumber< TT::SegmentNameComponent > Segment
SegmentNameComponent convention.
Definition convention.hpp:209
detail::TypedNumber< TT::VersionNameComponent > Version
VersionNameComponent convention.
Definition convention.hpp:223
@ Salt
Definition an.hpp:23
@ ErrorCode
Definition an.hpp:34
@ MaxValidityPeriod
Definition an.hpp:18
@ Challenge
Definition an.hpp:25
@ CaInfo
Definition an.hpp:14
@ ErrorInfo
Definition an.hpp:35
@ RequestId
Definition an.hpp:24
@ CaCertificate
Definition an.hpp:17
@ CaPrefix
Definition an.hpp:13
@ EcdhPub
Definition an.hpp:21
tlv::Value proof()
Definition an.hpp:136
Data::Signed makeError(Region &region, const Interest &interest, uint8_t errorCode, const EcPrivateKey &signer)
Definition server.hpp:269
std::array< Challenge *, detail::MaxChallenges::value > ChallengeList
Definition server.hpp:49
Component getInfoComponent()
Return 'INFO' component.
Definition an.hpp:53
Component getCaComponent()
Return 'CA' component.
Definition an.hpp:45
Component getNewComponent()
Return 'NEW' component.
Definition an.hpp:69
Component getChallengeComponent()
Return 'CHALLENGE' component.
Definition an.hpp:77
Definition fs.hpp:33
Region * makeSubRegion(Region &parent, size_t capacity)
Create Region inside a parent Region.
Definition region.hpp:173
ec::EcPublicKey EcPublicKey
Definition ec.hpp:325
packet_struct::ParameterKV params
Definition server.hpp:20
bool success
Definition server.hpp:17
const char * challengeStatus
Definition server.hpp:19
bool decrementRetry
Definition server.hpp:18
const EcPrivateKey & signer
CA private key.
Definition server.hpp:421
const CaProfile & profile
CA profile.
Definition server.hpp:415
const ChallengeList & challenges
List of offered challenges.
Definition server.hpp:418
Face & face
Face for communication.
Definition server.hpp:412