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