blob: 446d8a4f3250593c42a2b926b642d14c77a25e14 [file] [log] [blame]
Yingdi Yu8d7468f2014-02-21 14:49:45 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07002/**
3 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
11 *
12 * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
Yingdi Yu8d7468f2014-02-21 14:49:45 -080013 */
14
15#ifndef NDNSEC_SIG_VERIFY_HPP
16#define NDNSEC_SIG_VERIFY_HPP
17
18#include "ndnsec-util.hpp"
19
20// using namespace ndn;
21// namespace po = boost::program_options;
22
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070023// shared_ptr<IdentityCertificate>
Yingdi Yu8d7468f2014-02-21 14:49:45 -080024// getCertificate(const std::string& certString)
25// {
26// std::string decoded;
27// CryptoPP::StringSource ss2(reinterpret_cast<const unsigned char *>(certString.c_str()), certString.size(), true,
28// new CryptoPP::Base64Decoder(new CryptoPP::StringSink(decoded)));
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070029
Yingdi Yu8d7468f2014-02-21 14:49:45 -080030// Data data;
31// data.wireDecode(Block(make_shared<Buffer>(decoded.begin(), decoded.end())));
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070032
Yingdi Yu8d7468f2014-02-21 14:49:45 -080033// shared_ptr<IdentityCertificate> identityCertificate = make_shared<IdentityCertificate>(boost::cref(data));
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070034
Yingdi Yu8d7468f2014-02-21 14:49:45 -080035// return identityCertificate;
36// }
37
38// bool
39// verifySignature(shared_ptr<IdentityCertificate> certificate, bool isDataPacket)
40// {
41// throw std::runtime_error("Not supported yet");
42// // if(isDataPacket)
43// // {
44// // std::string decoded;
45// // CryptoPP::FileSource ss2(cin, true,
46// // new CryptoPP::Base64Decoder(new CryptoPP::StringSink(decoded)));
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070047
Yingdi Yu8d7468f2014-02-21 14:49:45 -080048// // Data data;
49// // data.wireDecode(ptr_lib::make_shared<Buffer>(decoded.c_str(), decoded.size()));
50// // return PolicyManager::verifySignature(data, certificate->getPublicKeyInfo());
51// // }
52// // else
53// // {
54// // // The first two bytes indicates the boundary of the of the signed data and signature.
55// // // for example, if the size of the signed data is 300, then the boundary should be 300, so the first two bytes should be: 0x01 0x2C
56// // ptr_lib::shared_ptr<Blob> input = ptr_lib::shared_ptr<Blob>(new Blob ((istreambuf_iterator<char>(cin)), istreambuf_iterator<char>()));
57// // size_t size = input->at(0);
58// // size = ((size << 8) + input->at(1));
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070059
Yingdi Yu8d7468f2014-02-21 14:49:45 -080060// // Blob signedBlob(input->buf()+2, size);
61// // Blob signature(input->buf()+2+size, input->size()-2-size);
62
63// // return PolicyManager::verifySignature(signedBlob, signature, certificate->getPublicKeyInfo());
64// // }
65// }
66
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070067int
68ndnsec_sig_verify(int argc, char** argv)
Yingdi Yu8d7468f2014-02-21 14:49:45 -080069{
70 std::cerr << "Not supported yet" << std::endl;
71 return 1;
72 // bool isDataPacket = false;
73 // std::string certString;
74
75 // po::options_description desc("General Usage\n ndn-sig-verify [-h] [-d] certificate\nGeneral options");
76 // desc.add_options()
77 // ("help,h", "produce help message")
78 // ("data,d", "if specified, input from stdin will be treated as a Data packet, otherwise binary data")
79 // ("certificate,c", po::value<std::string>(&certString), "the certificate bits")
80 // ;
81
82 // po::positional_options_description p;
83 // p.add("certificate", 1);
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070084
Yingdi Yu8d7468f2014-02-21 14:49:45 -080085 // po::variables_map vm;
86 // try
87 // {
88 // po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
89 // po::notify(vm);
90 // }
91 // catch( const std::exception& e)
92 // {
93 // std::cerr << e.what() << std::endl;
94 // std::cerr << desc << std::endl;
95 // return 1;
96 // }
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070097
98 // if (vm.count("help") || vm.count("certificate")==0)
Yingdi Yu8d7468f2014-02-21 14:49:45 -080099 // {
100 // std::cerr << desc << std::endl;
101 // return 1;
102 // }
103 // if (vm.count("data"))
104 // isDataPacket = true;
105
106 // try
107 // {
108 // shared_ptr<IdentityCertificate> certificate = getCertificate(certString);
109 // bool res = verifySignature(certificate, isDataPacket);
110 // return (res ? 0 : 1);
111 // }
112 // catch(const std::exception &e)
113 // {
114 // std::cerr << "ERROR: " << e.what() << std::endl;
115 // return 1;
116 // }
117}
118
119#endif //NDNSEC_SIG_VERIFY_HPP