blob: 8e7297f43fcfa9b6d936f6f318cbc636a638ebac [file] [log] [blame]
Yumin Xia2c509c22017-02-09 14:37:36 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2014-2017, Regents of the University of California.
4 *
5 * This file is part of NDNS (Named Data Networking Domain Name Service).
6 * See AUTHORS.md for complete list of NDNS authors and contributors.
7 *
8 * NDNS is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef NDNS_UTIL_CERT_HELPER_HPP
21#define NDNS_UTIL_CERT_HELPER_HPP
22
23#include "common.hpp"
24#include <ndn-cxx/security/key-chain.hpp>
25#include <ndn-cxx/encoding/tlv.hpp>
26#include <ndn-cxx/security/signing-helpers.hpp>
27
28namespace ndn {
29namespace ndns {
30
31class CertHelper
32{
33public:
34 static security::Identity
35 getIdentity(const KeyChain& keyChain, const Name& identityName);
36
37 static bool
38 doesIdentityExist(const KeyChain& keyChain, const Name& identityName);
39
40 static Name
41 getIdentityNameFromCert(const Name& certName);
42
43 static security::v2::Certificate
44 getCertificate(const KeyChain& keyChain,
45 const Name& identity,
46 const Name& certName);
47
48 static security::v2::Certificate
49 getCertificate(const KeyChain& keyChain,
50 const Name& certName);
51
52 static const Name&
53 getDefaultKeyNameOfIdentity(const KeyChain& keyChain, const Name& identityName);
54
55 static const Name&
56 getDefaultCertificateNameOfIdentity(const KeyChain& keyChain, const Name& identityName);
57
58 static security::v2::Certificate
59 createCertificate(KeyChain& keyChain,
60 const security::Key& key,
61 const security::Key& signingKey,
62 const std::string& issuer,
63 const time::seconds& certValidity = time::days(10));
64};
65
66
67} // namespace ndns
68} // namespace ndn
69
70#endif // NDNS_UTIL_CERT_HELPER_HPP