Yingdi Yu | 8d7468f | 2014-02-21 14:49:45 -0800 | [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 | * BSD license, See the LICENSE file for more information |
| 5 | * Author: Yingdi Yu <yingdi@cs.ucla.edu> |
| 6 | */ |
| 7 | |
| 8 | #include "ndnsec-util.hpp" |
| 9 | #include "ndnsec-list.hpp" |
| 10 | #include "ndnsec-get-default.hpp" |
| 11 | #include "ndnsec-set-default.hpp" |
| 12 | #include "ndnsec-key-gen.hpp" |
| 13 | #include "ndnsec-dsk-gen.hpp" |
| 14 | #include "ndnsec-sign-req.hpp" |
| 15 | #include "ndnsec-cert-gen.hpp" |
| 16 | #include "ndnsec-cert-dump.hpp" |
| 17 | #include "ndnsec-cert-install.hpp" |
| 18 | #include "ndnsec-export.hpp" |
| 19 | #include "ndnsec-import.hpp" |
| 20 | #include "ndnsec-delete.hpp" |
| 21 | #include "ndnsec-sig-verify.hpp" |
| 22 | #include "ndnsec-set-acl.hpp" |
| 23 | #include "ndnsec-unlock-tpm.hpp" |
| 24 | #include "ndnsec-op-tool.hpp" |
| 25 | |
| 26 | using namespace ndn; |
| 27 | |
| 28 | std::string ndnsec_helper("\ |
| 29 | help Show all commands.\n\ |
| 30 | list Display information in PublicInfo.\n\ |
| 31 | get-default Get default setting info.\n\ |
| 32 | set-default Configure default setting.\n\ |
| 33 | key-gen Generate a Key-Signing-Key for an identity.\n\ |
Yingdi Yu | 8d7468f | 2014-02-21 14:49:45 -0800 | [diff] [blame] | 34 | sign-req Generate a certificate signing request.\n\ |
| 35 | cert-gen Generate an identity certificate.\n\ |
| 36 | cert-dump Dump a certificate from PublicInfo.\n\ |
| 37 | cert-install Install a certificate into PublicInfo.\n\ |
Yingdi Yu | 5c1f841 | 2014-03-25 11:49:47 -0700 | [diff] [blame] | 38 | delete Delete identity/key/certificate.\n\ |
Yingdi Yu | 8d7468f | 2014-02-21 14:49:45 -0800 | [diff] [blame] | 39 | export Export an identity package.\n\ |
| 40 | import Import an identity package.\n\ |
| 41 | sig-verify Verify the signature of a Data packet.\n\ |
| 42 | set-acl Configure ACL of a private key.\n\ |
| 43 | unlock-tpm Unlock Tpm.\n\ |
| 44 | op-tool Operator tool.\n\ |
| 45 | "); |
| 46 | |
Yingdi Yu | 5c1f841 | 2014-03-25 11:49:47 -0700 | [diff] [blame] | 47 | int |
| 48 | main(int argc, char** argv) |
Yingdi Yu | 8d7468f | 2014-02-21 14:49:45 -0800 | [diff] [blame] | 49 | { |
Yingdi Yu | b61f540 | 2014-02-26 17:46:11 -0800 | [diff] [blame] | 50 | if (argc < 2) |
Yingdi Yu | f8fc8de | 2014-02-25 15:45:39 -0800 | [diff] [blame] | 51 | { |
| 52 | std::cerr << ndnsec_helper << std::endl; |
| 53 | return 1; |
| 54 | } |
| 55 | |
Yingdi Yu | 8d7468f | 2014-02-21 14:49:45 -0800 | [diff] [blame] | 56 | std::string command(argv[1]); |
Yingdi Yu | b61f540 | 2014-02-26 17:46:11 -0800 | [diff] [blame] | 57 | |
| 58 | try |
| 59 | { |
| 60 | if (command == "help") { std::cerr << ndnsec_helper << std::endl; } |
| 61 | else if (command == "list") { return ndnsec_list(argc - 1, argv + 1); } |
| 62 | else if (command == "get-default") { return ndnsec_get_default(argc - 1, argv + 1); } |
| 63 | else if (command == "set-default") { return ndnsec_set_default(argc - 1, argv + 1); } |
| 64 | else if (command == "key-gen") { return ndnsec_key_gen(argc - 1, argv + 1); } |
| 65 | else if (command == "sign-req") { return ndnsec_sign_req(argc - 1, argv + 1); } |
| 66 | else if (command == "cert-gen") { return ndnsec_cert_gen(argc - 1, argv + 1); } |
| 67 | else if (command == "cert-dump") { return ndnsec_cert_dump(argc - 1, argv + 1); } |
| 68 | else if (command == "cert-install") { return ndnsec_cert_install(argc - 1, argv + 1); } |
| 69 | else if (command == "delete") { return ndnsec_delete(argc - 1, argv + 1); } |
| 70 | else if (command == "export") { return ndnsec_export(argc - 1, argv + 1); } |
| 71 | else if (command == "import") { return ndnsec_import(argc - 1, argv + 1); } |
| 72 | else if (command == "sig-verify") { return ndnsec_sig_verify(argc - 1, argv + 1); } |
| 73 | else if (command == "set-acl") { return ndnsec_set_acl(argc - 1, argv + 1); } |
| 74 | else if (command == "unlock-tpm") { return ndnsec_unlock_tpm(argc - 1, argv + 1); } |
| 75 | else if (command == "op-tool") { return ndnsec_op_tool(argc - 1, argv + 1); } |
| 76 | else { |
| 77 | std::cerr << ndnsec_helper << std::endl; |
| 78 | return 1; |
| 79 | } |
| 80 | } |
| 81 | catch (const std::runtime_error& e) |
| 82 | { |
| 83 | std::cerr << "ERROR: " << e.what() << std::endl; |
| 84 | return 1; |
| 85 | } |
Yingdi Yu | 8d7468f | 2014-02-21 14:49:45 -0800 | [diff] [blame] | 86 | |
| 87 | return 0; |
| 88 | } |