NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
secured-bag.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #include "secured-bag.hpp"
24 #include "util/concepts.hpp"
25 
26 namespace ndn {
27 
28 //BOOST_CONCEPT_ASSERT((boost::EqualityComparable<SecuredBag>));
29 BOOST_CONCEPT_ASSERT((WireEncodable<SecuredBag>));
30 BOOST_CONCEPT_ASSERT((WireDecodable<SecuredBag>));
31 static_assert(std::is_base_of<tlv::Error, SecuredBag::Error>::value,
32  "SecuredBag::Error must inherit from tlv::Error");
33 
35  : m_wire(tlv::security::IdentityPackage)
36 {
37 }
38 
40 {
41  this->wireDecode(wire);
42 }
43 
45  : m_cert(cert)
46  , m_key(key)
47  , m_wire(tlv::security::IdentityPackage)
48 {
49  Block wireKey(tlv::security::KeyPackage, m_key);
51  m_wire.push_back(wireCert);
52  m_wire.push_back(wireKey);
53 }
54 
56 {
57 }
58 
59 void
61 {
62  m_wire = wire;
63  m_wire.parse();
64 
66 
67  Block wireKey = m_wire.get(tlv::security::KeyPackage);
68  shared_ptr<Buffer> key = make_shared<Buffer>(wireKey.value(), wireKey.value_size());
69  m_key = key;
70 }
71 
72 const Block&
74 {
75  m_wire.encode();
76  return m_wire;
77 }
78 
79 } // namespace ndn
Copyright (c) 2011-2015 Regents of the University of California.
size_t value_size() const
Definition: block.cpp:529
void parse() const
Parse wire buffer into subblocks.
Definition: block.cpp:322
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
const uint8_t * value() const
Definition: block.cpp:520
const Block & wireEncode() const
Definition: secured-bag.cpp:73
const Block & get(uint32_t type) const
Get the first subelement of the requested type.
Definition: block.cpp:409
void push_back(const Block &element)
Definition: block.cpp:568
void wireDecode(const Block &wire)
Definition: secured-bag.cpp:60
void encode()
Encode subblocks into wire buffer.
Definition: block.cpp:355
Block blockFromValue() const
Definition: block.cpp:437
size_t wireEncode(EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const
Fast encoding or block size estimation.
Definition: data.cpp:52
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:33
a concept check for TLV abstraction with .wireEncode method
Definition: concepts.hpp:34
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
Definition: concepts.hpp:70