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 | |
Jeff Thompson | 258a402 | 2013-10-15 17:43:58 -0700 | [diff] [blame] | 9 | #if 1 // TODO: Remove this when we don't throw "not implemented". |
| 10 | #include <stdexcept> |
| 11 | #endif |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 12 | #include "../../encoding/der/der.hpp" |
| 13 | #include <ndn-cpp/security/certificate/certificate-extension.hpp> |
| 14 | |
| 15 | using namespace std; |
| 16 | using namespace ndn::ptr_lib; |
| 17 | |
| 18 | namespace ndn { |
| 19 | |
| 20 | shared_ptr<der::DerNode> |
| 21 | CertificateExtension::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 Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | Blob |
| 39 | CertificateExtension::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 | } |