Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2013 Regents of the University of California. |
Jeff Thompson | 173fd43 | 2013-10-12 18:16:41 -0700 | [diff] [blame^] | 4 | * @author: Yingdi Yu <yingdi@cs.ucla.edu> |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 5 | * @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 | |
| 12 | using namespace std; |
| 13 | using namespace ndn::ptr_lib; |
| 14 | |
| 15 | namespace ndn { |
| 16 | |
| 17 | shared_ptr<der::DerNode> |
| 18 | CertificateExtension::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 | |
| 35 | Blob |
| 36 | CertificateExtension::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 | } |