Yumin Xia | 2c509c2 | 2017-02-09 14:37:36 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
Alexander Afanasyev | 60514ec | 2020-06-03 14:18:53 -0400 | [diff] [blame] | 3 | * Copyright (c) 2014-2020, Regents of the University of California. |
Yumin Xia | 2c509c2 | 2017-02-09 14:37:36 -0800 | [diff] [blame] | 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 | |
| 28 | namespace ndn { |
| 29 | namespace ndns { |
| 30 | |
| 31 | class CertHelper |
| 32 | { |
| 33 | public: |
| 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 Afanasyev | 60514ec | 2020-06-03 14:18:53 -0400 | [diff] [blame] | 43 | static security::Certificate |
Yumin Xia | 2c509c2 | 2017-02-09 14:37:36 -0800 | [diff] [blame] | 44 | getCertificate(const KeyChain& keyChain, |
| 45 | const Name& identity, |
| 46 | const Name& certName); |
| 47 | |
Alexander Afanasyev | 60514ec | 2020-06-03 14:18:53 -0400 | [diff] [blame] | 48 | static security::Certificate |
Yumin Xia | 2c509c2 | 2017-02-09 14:37:36 -0800 | [diff] [blame] | 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 | |
Alexander Afanasyev | 60514ec | 2020-06-03 14:18:53 -0400 | [diff] [blame] | 58 | static security::Certificate |
Yumin Xia | 2c509c2 | 2017-02-09 14:37:36 -0800 | [diff] [blame] | 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 | |
Yumin Xia | 2c509c2 | 2017-02-09 14:37:36 -0800 | [diff] [blame] | 66 | } // namespace ndns |
| 67 | } // namespace ndn |
| 68 | |
| 69 | #endif // NDNS_UTIL_CERT_HELPER_HPP |