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 | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 9 | #include "../../encoding/der/der.hpp" |
Jeff Thompson | 6154ae2 | 2013-10-18 10:44:57 -0700 | [diff] [blame^] | 10 | #include "../../util/blob-stream.hpp" |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 11 | #include <ndn-cpp/security/certificate/certificate-extension.hpp> |
| 12 | |
| 13 | using namespace std; |
| 14 | using namespace ndn::ptr_lib; |
| 15 | |
| 16 | namespace ndn { |
| 17 | |
| 18 | shared_ptr<der::DerNode> |
| 19 | CertificateExtension::toDer() |
| 20 | { |
| 21 | shared_ptr<der::DerSequence> root(new der::DerSequence); |
| 22 | |
| 23 | shared_ptr<der::DerOid> extensionId(new der::DerOid(extensionId_)); |
| 24 | shared_ptr<der::DerBool> isCritical(new der::DerBool(isCritical_)); |
| 25 | shared_ptr<der::DerOctetString> extensionValue(new der::DerOctetString(*extensionValue_)); |
| 26 | |
| 27 | root->addChild(extensionId); |
| 28 | root->addChild(isCritical); |
| 29 | root->addChild(extensionValue); |
| 30 | |
| 31 | root->getSize(); |
| 32 | |
| 33 | return root; |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | Blob |
| 37 | CertificateExtension::toDerBlob() |
| 38 | { |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 39 | blob_stream blobStream; |
Jeff Thompson | 6154ae2 | 2013-10-18 10:44:57 -0700 | [diff] [blame^] | 40 | der::OutputIterator& start = reinterpret_cast<der::OutputIterator&>(blobStream); |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 41 | |
| 42 | toDer()->encode(start); |
| 43 | |
| 44 | return blobStream.buf(); |
Jeff Thompson | 958bf9b | 2013-10-12 17:20:51 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | |
| 48 | } |