blob: fdb6f03ce869864771e51133ea8887a06bee9fd3 [file] [log] [blame]
Yingdi Yu8d7468f2014-02-21 14:49:45 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013, Regents of the University of California
4 * BSD license, See the LICENSE file for more information
5 * Author: Yingdi Yu <yingdi@cs.ucla.edu>
6 */
7
8#ifndef NDNSEC_SIG_VERIFY_HPP
9#define NDNSEC_SIG_VERIFY_HPP
10
11#include "ndnsec-util.hpp"
12
13// using namespace ndn;
14// namespace po = boost::program_options;
15
16// shared_ptr<IdentityCertificate>
17// getCertificate(const std::string& certString)
18// {
19// std::string decoded;
20// CryptoPP::StringSource ss2(reinterpret_cast<const unsigned char *>(certString.c_str()), certString.size(), true,
21// new CryptoPP::Base64Decoder(new CryptoPP::StringSink(decoded)));
22
23// Data data;
24// data.wireDecode(Block(make_shared<Buffer>(decoded.begin(), decoded.end())));
25
26// shared_ptr<IdentityCertificate> identityCertificate = make_shared<IdentityCertificate>(boost::cref(data));
27
28// return identityCertificate;
29// }
30
31// bool
32// verifySignature(shared_ptr<IdentityCertificate> certificate, bool isDataPacket)
33// {
34// throw std::runtime_error("Not supported yet");
35// // if(isDataPacket)
36// // {
37// // std::string decoded;
38// // CryptoPP::FileSource ss2(cin, true,
39// // new CryptoPP::Base64Decoder(new CryptoPP::StringSink(decoded)));
40
41// // Data data;
42// // data.wireDecode(ptr_lib::make_shared<Buffer>(decoded.c_str(), decoded.size()));
43// // return PolicyManager::verifySignature(data, certificate->getPublicKeyInfo());
44// // }
45// // else
46// // {
47// // // The first two bytes indicates the boundary of the of the signed data and signature.
48// // // 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
49// // ptr_lib::shared_ptr<Blob> input = ptr_lib::shared_ptr<Blob>(new Blob ((istreambuf_iterator<char>(cin)), istreambuf_iterator<char>()));
50// // size_t size = input->at(0);
51// // size = ((size << 8) + input->at(1));
52
53// // Blob signedBlob(input->buf()+2, size);
54// // Blob signature(input->buf()+2+size, input->size()-2-size);
55
56// // return PolicyManager::verifySignature(signedBlob, signature, certificate->getPublicKeyInfo());
57// // }
58// }
59
60int
61ndnsec_sig_verify(int argc, char** argv)
62{
63 std::cerr << "Not supported yet" << std::endl;
64 return 1;
65 // bool isDataPacket = false;
66 // std::string certString;
67
68 // po::options_description desc("General Usage\n ndn-sig-verify [-h] [-d] certificate\nGeneral options");
69 // desc.add_options()
70 // ("help,h", "produce help message")
71 // ("data,d", "if specified, input from stdin will be treated as a Data packet, otherwise binary data")
72 // ("certificate,c", po::value<std::string>(&certString), "the certificate bits")
73 // ;
74
75 // po::positional_options_description p;
76 // p.add("certificate", 1);
77
78 // po::variables_map vm;
79 // try
80 // {
81 // po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
82 // po::notify(vm);
83 // }
84 // catch( const std::exception& e)
85 // {
86 // std::cerr << e.what() << std::endl;
87 // std::cerr << desc << std::endl;
88 // return 1;
89 // }
90
91 // if (vm.count("help") || vm.count("certificate")==0)
92 // {
93 // std::cerr << desc << std::endl;
94 // return 1;
95 // }
96 // if (vm.count("data"))
97 // isDataPacket = true;
98
99 // try
100 // {
101 // shared_ptr<IdentityCertificate> certificate = getCertificate(certString);
102 // bool res = verifySignature(certificate, isDataPacket);
103 // return (res ? 0 : 1);
104 // }
105 // catch(const std::exception &e)
106 // {
107 // std::cerr << "ERROR: " << e.what() << std::endl;
108 // return 1;
109 // }
110}
111
112#endif //NDNSEC_SIG_VERIFY_HPP