NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
certificate-extension.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
25 #include "common.hpp"
26 
28 #include "cryptopp.hpp"
29 
30 namespace ndn {
31 
32 void
33 CertificateExtension::encode(CryptoPP::BufferedTransformation& out) const
34 {
35  using namespace CryptoPP;
36 
37  // Extension ::= SEQUENCE {
38  // extnID OBJECT IDENTIFIER,
39  // critical BOOLEAN DEFAULT FALSE,
40  // extnValue OCTET STRING }
41 
42  DERSequenceEncoder extension(out);
43  {
44  m_extensionId.encode(extension);
45  DEREncodeUnsigned(extension, m_isCritical, BOOLEAN);
46  DEREncodeOctetString(extension, m_extensionValue.buf(), m_extensionValue.size());
47  }
48  extension.MessageEnd();
49 }
50 
51 void
52 CertificateExtension::decode(CryptoPP::BufferedTransformation& in)
53 {
54  using namespace CryptoPP;
55 
56  // Extension ::= SEQUENCE {
57  // extnID OBJECT IDENTIFIER,
58  // critical BOOLEAN DEFAULT FALSE,
59  // extnValue OCTET STRING }
60 
61  BERSequenceDecoder extension(in);
62  {
63  m_extensionId.decode(extension);
64  BERDecodeUnsigned(extension, m_isCritical, BOOLEAN);
65 
66  // the extra copy operation can be optimized, but not trivial,
67  // since the length is not known in advance
68  SecByteBlock tmpBlock;
69  BERDecodeOctetString(extension, tmpBlock);
70  m_extensionValue.assign(tmpBlock.begin(), tmpBlock.end());
71  }
72  extension.MessageEnd();
73 }
74 
75 } // namespace ndn
Copyright (c) 2011-2015 Regents of the University of California.
Copyright (c) 2013-2014 Regents of the University of California.
Definition: oid.hpp:29
void encode(CryptoPP::BufferedTransformation &out) const
Definition: oid.cpp:130
void decode(CryptoPP::BufferedTransformation &in)
void decode(CryptoPP::BufferedTransformation &in)
Definition: oid.cpp:147
uint8_t * buf()
Definition: buffer.hpp:87
void encode(CryptoPP::BufferedTransformation &out) const