Jeff Thompson | 415da1e | 2013-10-17 16:52:59 -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: Yingdi Yu <yingdi@cs.ucla.edu> |
| 5 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
| 6 | * See COPYING for copyright and distribution information. |
| 7 | */ |
| 8 | |
| 9 | #include "simple-visitor.hpp" |
| 10 | #include <ndn-cpp/security/certificate/public-key.hpp> |
| 11 | #include "../der.hpp" |
| 12 | #include "public-key-visitor.hpp" |
| 13 | |
| 14 | using namespace std; |
| 15 | using namespace ndn::ptr_lib; |
| 16 | |
| 17 | namespace ndn { |
| 18 | |
| 19 | namespace der { |
| 20 | |
| 21 | ndnboost::any |
| 22 | PublicKeyVisitor::visit(DerSequence& derSeq) |
| 23 | { |
| 24 | const DerNodePtrList& children = derSeq.getChildren(); |
| 25 | |
| 26 | SimpleVisitor simpleVisitor; |
| 27 | shared_ptr<DerSequence> algoSeq = dynamic_pointer_cast<DerSequence>(children[0]); |
| 28 | OID algorithm = ndnboost::any_cast<OID>(algoSeq->getChildren()[0]->accept(simpleVisitor)); |
| 29 | Blob raw = derSeq.getRaw(); |
| 30 | return ndnboost::any(shared_ptr<PublicKey>(new PublicKey(algorithm, raw))); |
| 31 | } |
| 32 | |
| 33 | } // der |
| 34 | |
| 35 | } |