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. |
| 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 | |
| 11 | using namespace std; |
| 12 | using namespace ndn::ptr_lib; |
| 13 | |
| 14 | namespace ndn { |
| 15 | |
| 16 | shared_ptr<der::DerNode> |
| 17 | CertificateExtension::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 | |
| 34 | Blob |
| 35 | CertificateExtension::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 | } |