blob: ba67ac4d8f82ae41c018a0451dd402628393dc20 [file] [log] [blame]
Yingdi Yu233a9722014-03-07 15:47:09 -08001/* -*- 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 * See COPYING for copyright and distribution information.
6 */
7
8#include <ndn-cpp-dev/security/key-chain.hpp>
9#include <ndn-cpp-dev/face.hpp>
10
11using namespace ndn;
12
13int
14main()
15{
16 Name root("/ndn");
17
18 KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
19
20 if(!keyChain.doesIdentityExist(root))
21 return 1;
22
23 shared_ptr<boost::asio::io_service> ioService = make_shared<boost::asio::io_service>();
24 shared_ptr<Face> face = shared_ptr<Face>(new Face(ioService));
25
26 Name name("/local/ndn/prefix");
27 name.appendVersion().appendSegment(0);
28
29 Data data(name);
30 std::string prefix("/ndn/test");
31 data.setContent(reinterpret_cast<const uint8_t*>(prefix.c_str()), prefix.size());
32 keyChain.signByIdentity(data, root);
33
34 face->put(data);
35
36 ioService->run();
37}