blob: b2c1bad0cbd21d77cf82542ff39e7908dfff647a [file] [log] [blame]
Jeff Thompson958bf9b2013-10-12 17:20:51 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
Jeff Thompson173fd432013-10-12 18:16:41 -07004 * @author: Yingdi Yu <yingdi@cs.ucla.edu>
Jeff Thompson958bf9b2013-10-12 17:20:51 -07005 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
6 * See COPYING for copyright and distribution information.
7 */
8
Jeff Thompson958bf9b2013-10-12 17:20:51 -07009#include "../../encoding/der/der.hpp"
Jeff Thompson6154ae22013-10-18 10:44:57 -070010#include "../../util/blob-stream.hpp"
Jeff Thompson958bf9b2013-10-12 17:20:51 -070011#include <ndn-cpp/security/certificate/certificate-extension.hpp>
12
13using namespace std;
14using namespace ndn::ptr_lib;
15
16namespace ndn {
17
18shared_ptr<der::DerNode>
19CertificateExtension::toDer()
20{
21 shared_ptr<der::DerSequence> root(new der::DerSequence);
22
23 shared_ptr<der::DerOid> extensionId(new der::DerOid(extensionId_));
24 shared_ptr<der::DerBool> isCritical(new der::DerBool(isCritical_));
25 shared_ptr<der::DerOctetString> extensionValue(new der::DerOctetString(*extensionValue_));
26
27 root->addChild(extensionId);
28 root->addChild(isCritical);
29 root->addChild(extensionValue);
30
31 root->getSize();
32
33 return root;
Jeff Thompson958bf9b2013-10-12 17:20:51 -070034}
35
36Blob
37CertificateExtension::toDerBlob()
38{
Jeff Thompson958bf9b2013-10-12 17:20:51 -070039 blob_stream blobStream;
Jeff Thompson6154ae22013-10-18 10:44:57 -070040 der::OutputIterator& start = reinterpret_cast<der::OutputIterator&>(blobStream);
Jeff Thompson958bf9b2013-10-12 17:20:51 -070041
42 toDer()->encode(start);
43
44 return blobStream.buf();
Jeff Thompson958bf9b2013-10-12 17:20:51 -070045}
46
47
48}