blob: 9f6c39abfce55c228e4555b12b7290e6365ac70f [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.
4 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
5 * See COPYING for copyright and distribution information.
6 */
7
8#include "../../encoding/der/der.hpp"
9#include <ndn-cpp/security/certificate/certificate-extension.hpp>
10
11using namespace std;
12using namespace ndn::ptr_lib;
13
14namespace ndn {
15
16shared_ptr<der::DerNode>
17CertificateExtension::toDer()
18{
19 shared_ptr<der::DerSequence> root(new der::DerSequence);
20
21 shared_ptr<der::DerOid> extensionId(new der::DerOid(extensionId_));
22 shared_ptr<der::DerBool> isCritical(new der::DerBool(isCritical_));
23 shared_ptr<der::DerOctetString> extensionValue(new der::DerOctetString(*extensionValue_));
24
25 root->addChild(extensionId);
26 root->addChild(isCritical);
27 root->addChild(extensionValue);
28
29 root->getSize();
30
31 return root;
32}
33
34Blob
35CertificateExtension::toDerBlob()
36{
37#if 0 // Need to convert blob_stream.
38 blob_stream blobStream;
39 ostream& start = reinterpret_cast<ostream&>(blobStream);
40
41 toDer()->encode(start);
42
43 return blobStream.buf();
44#else
45 throw std::runtime_error("not implemented");
46#endif
47}
48
49
50}