blob: e9b627f99e02510350122b860b60ecdb9d30f858 [file] [log] [blame]
Yumin Xia2c509c22017-02-09 14:37:36 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
Alexander Afanasyev60514ec2020-06-03 14:18:53 -04003 * Copyright (c) 2014-2020, Regents of the University of California.
Yumin Xia2c509c22017-02-09 14:37:36 -08004 *
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
Alexander Afanasyev60514ec2020-06-03 14:18:53 -040043 static security::Certificate
Yumin Xia2c509c22017-02-09 14:37:36 -080044 getCertificate(const KeyChain& keyChain,
45 const Name& identity,
46 const Name& certName);
47
Alexander Afanasyev60514ec2020-06-03 14:18:53 -040048 static security::Certificate
Yumin Xia2c509c22017-02-09 14:37:36 -080049 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
Alexander Afanasyev60514ec2020-06-03 14:18:53 -040058 static security::Certificate
Yumin Xia2c509c22017-02-09 14:37:36 -080059 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
Yumin Xia2c509c22017-02-09 14:37:36 -080066} // namespace ndns
67} // namespace ndn
68
69#endif // NDNS_UTIL_CERT_HELPER_HPP