blob: a5f5542f8be5414b96e38a317ed58beb5a795373 [file] [log] [blame]
Jeff Thompson415da1e2013-10-17 16:52:59 -07001/* -*- 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
14using namespace std;
Jeff Thompson415da1e2013-10-17 16:52:59 -070015
16namespace ndn {
17
18namespace der {
19
20ndnboost::any
21PublicKeyVisitor::visit(DerSequence& derSeq)
22{
Jeff Thompson3d5096c2013-12-11 16:40:05 -080023 DerNodePtrList& children = derSeq.getChildren();
Jeff Thompson415da1e2013-10-17 16:52:59 -070024
25 SimpleVisitor simpleVisitor;
Jeff Thompsonce115762013-12-18 14:59:56 -080026 ptr_lib::shared_ptr<DerSequence> algoSeq = ptr_lib::dynamic_pointer_cast<DerSequence>(children[0]);
Jeff Thompson415da1e2013-10-17 16:52:59 -070027 OID algorithm = ndnboost::any_cast<OID>(algoSeq->getChildren()[0]->accept(simpleVisitor));
28 Blob raw = derSeq.getRaw();
Jeff Thompsonce115762013-12-18 14:59:56 -080029 return ndnboost::any(ptr_lib::shared_ptr<PublicKey>(new PublicKey(algorithm, raw)));
Jeff Thompson415da1e2013-10-17 16:52:59 -070030}
31
32} // der
33
34}