blob: f081f2a8036d77abc4e5243a06baedb148a71ad7 [file] [log] [blame]
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/**
* Copyright (C) 2013 Regents of the University of California.
* @author: Yingdi Yu <yingdi@cs.ucla.edu>
* @author: Jeff Thompson <jefft0@remap.ucla.edu>
* See COPYING for copyright and distribution information.
*/
#include "../../encoding/der/der.hpp"
#include "../../util/blob-stream.hpp"
#include <ndn-cpp/security/certificate/certificate-extension.hpp>
using namespace std;
namespace ndn {
ptr_lib::shared_ptr<der::DerNode>
CertificateExtension::toDer()
{
ptr_lib::shared_ptr<der::DerSequence> root(new der::DerSequence);
ptr_lib::shared_ptr<der::DerOid> extensionId(new der::DerOid(extensionId_));
ptr_lib::shared_ptr<der::DerBool> isCritical(new der::DerBool(isCritical_));
ptr_lib::shared_ptr<der::DerOctetString> extensionValue(new der::DerOctetString(*extensionValue_));
root->addChild(extensionId);
root->addChild(isCritical);
root->addChild(extensionValue);
root->getSize();
return root;
}
Blob
CertificateExtension::toDerBlob()
{
blob_stream blobStream;
der::OutputIterator& start = reinterpret_cast<der::OutputIterator&>(blobStream);
toDer()->encode(start);
return blobStream.buf();
}
}