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
"
23
#include "
encoding/tlv-security.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
34
SecuredBag::SecuredBag
()
35
: m_wire(tlv::
security
::
IdentityPackage
)
36
{
37
}
38
39
SecuredBag::SecuredBag
(
const
Block
& wire)
40
{
41
this->
wireDecode
(wire);
42
}
43
44
SecuredBag::SecuredBag
(
const
v1::IdentityCertificate
& cert,
ConstBufferPtr
key)
45
: m_cert(cert)
46
, m_key(key)
47
, m_wire(tlv::
security
::
IdentityPackage
)
48
{
49
Block
wireKey(
tlv::security::KeyPackage
, m_key);
50
Block
wireCert(
tlv::security::CertificatePackage
, cert.
wireEncode
());
51
m_wire.
push_back
(wireCert);
52
m_wire.
push_back
(wireKey);
53
}
54
55
SecuredBag::~SecuredBag
()
56
{
57
}
58
59
void
60
SecuredBag::wireDecode
(
const
Block
& wire)
61
{
62
m_wire = wire;
63
m_wire.
parse
();
64
65
m_cert.
wireDecode
(m_wire.
get
(
tlv::security::CertificatePackage
).
blockFromValue
());
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
&
73
SecuredBag::wireEncode
()
const
74
{
75
m_wire.
encode
();
76
return
m_wire;
77
}
78
79
}
// namespace ndn
ndn::security::v1::IdentityCertificate
Definition:
identity-certificate.hpp:34
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::Block::value_size
size_t value_size() const
Definition:
block.cpp:529
ndn::security::SecuredBag::SecuredBag
SecuredBag()
Definition:
secured-bag.cpp:34
ndn::Block::parse
void parse() const
Parse wire buffer into subblocks.
Definition:
block.cpp:322
ndn::Block
Class representing a wire element of NDN-TLV packet format.
Definition:
block.hpp:43
ndn::Block::value
const uint8_t * value() const
Definition:
block.cpp:520
ndn::security::SecuredBag::wireEncode
const Block & wireEncode() const
Definition:
secured-bag.cpp:73
ndn::tlv::security::IdentityPackage
Definition:
tlv-security.hpp:32
ndn::tlv::security::CertificatePackage
Definition:
tlv-security.hpp:34
tlv-security.hpp
ndn::security::v1::IdentityCertificate::wireDecode
void wireDecode(const Block &wire)
Definition:
identity-certificate.cpp:54
ndn::Block::get
const Block & get(uint32_t type) const
Get the first subelement of the requested type.
Definition:
block.cpp:409
ndn::security::SecuredBag::~SecuredBag
virtual ~SecuredBag()
Definition:
secured-bag.cpp:55
ndn::Block::push_back
void push_back(const Block &element)
Definition:
block.cpp:568
secured-bag.hpp
ndn::security::SecuredBag::wireDecode
void wireDecode(const Block &wire)
Definition:
secured-bag.cpp:60
ndn::Block::encode
void encode()
Encode subblocks into wire buffer.
Definition:
block.cpp:355
concepts.hpp
ndn::Block::blockFromValue
Block blockFromValue() const
Definition:
block.cpp:437
ndn::Data::wireEncode
size_t wireEncode(EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const
Fast encoding or block size estimation.
Definition:
data.cpp:52
ndn::ConstBufferPtr
shared_ptr< const Buffer > ConstBufferPtr
Definition:
buffer.hpp:33
ndn::WireEncodable
a concept check for TLV abstraction with .wireEncode method
Definition:
concepts.hpp:34
ndn::WireDecodable
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
Definition:
concepts.hpp:70
ndn::tlv::security::KeyPackage
Definition:
tlv-security.hpp:33
security
ndnSIM
ndn-cxx
src
security
secured-bag.cpp
Generated on Wed Jan 11 2017 18:17:14 for ndnSIM by
1.8.13