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