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 | { |
Jeff Thompson | 84cfe1d | 2013-10-15 17:59:01 -0700 | [diff] [blame] | 23 | #if 0 // Include again when der is defined. |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 24 | shared_ptr<der::DerSequence> root(new der::DerSequence); |
| 25 | |
| 26 | shared_ptr<der::DerOid> extensionId(new der::DerOid(extensionId_)); |
| 27 | shared_ptr<der::DerBool> isCritical(new der::DerBool(isCritical_)); |
| 28 | shared_ptr<der::DerOctetString> extensionValue(new der::DerOctetString(*extensionValue_)); |
| 29 | |
| 30 | root->addChild(extensionId); |
| 31 | root->addChild(isCritical); |
| 32 | root->addChild(extensionValue); |
| 33 | |
| 34 | root->getSize(); |
| 35 | |
| 36 | return root; |
Jeff Thompson | 84cfe1d | 2013-10-15 17:59:01 -0700 | [diff] [blame] | 37 | #else |
| 38 | throw std::runtime_error("not implemented"); |
| 39 | #endif |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | Blob |
| 43 | CertificateExtension::toDerBlob() |
| 44 | { |
| 45 | #if 0 // Need to convert blob_stream. |
| 46 | blob_stream blobStream; |
| 47 | ostream& start = reinterpret_cast<ostream&>(blobStream); |
| 48 | |
| 49 | toDer()->encode(start); |
| 50 | |
| 51 | return blobStream.buf(); |
| 52 | #else |
| 53 | throw std::runtime_error("not implemented"); |
| 54 | #endif |
| 55 | } |
| 56 | |
| 57 | |
| 58 | } |