blob: bcd8b5d21dd709ccb7660a649489d89fff95c365 [file] [log] [blame]
Zhiyi Zhang0a89b722017-04-28 17:56:01 -07001/**
2 * Copyright (c) 2017, Regents of the University of California.
3 *
4 * This file is part of ndncert, a certificate management system based on NDN.
5 *
6 * ndncert is free software: you can redistribute it and/or modify it under the terms
7 * of the GNU General Public License as published by the Free Software Foundation, either
8 * version 3 of the License, or (at your option) any later version.
9 *
10 * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 *
14 * You should have received copies of the GNU General Public License along with
15 * ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * See AUTHORS.md for complete list of ndncert authors and contributors.
18 */
19
20#ifndef NDNCERT_CHALLENGE_CREDENTIAL_HPP
21#define NDNCERT_CHALLENGE_CREDENTIAL_HPP
22
23#include "../challenge-module.hpp"
24
25namespace ndn {
26namespace ndncert {
27
28/**
29 * @brief Provide Credential based challenge
30 *
31 * Credential here means the certificate issued by a trust anchor. Once the requester
32 * could proof his/her possession of an existing certificate from other certificate, th
33 * requester could finish the challenge.
34 *
Zhiyi Zhang70fe2582017-05-19 15:01:03 -070035 * The requester needs to provide the proof of the possession of a certificate issued by
36 * a trust anchor. The challenge require the requester to pass the BASE64 certificate and
37 * a BASE64 self-signed certificate whose key is the same as the key in certificate.
38 *
Zhiyi Zhang0a89b722017-04-28 17:56:01 -070039 * The main process of this challenge module is:
40 * 1. Requester provides a certificate signed by that trusted certificate as credential.
41 * 2. The challenge module will verify the signature of the credential.
42 *
Zhiyi Zhanga9bda732017-05-20 22:58:55 -070043 * Failure info when application fails:
44 * FAILURE_INVALID_CREDENTIAL: When the cert issued from trust anchor or self-signed cert
45 * cannot be validated.
46 * FAILURE_INVALID_FORMAT: When the credential format is wrong.
Zhiyi Zhang0a89b722017-04-28 17:56:01 -070047 */
48class ChallengeCredential : public ChallengeModule
49{
50public:
Zhiyi Zhang70fe2582017-05-19 15:01:03 -070051 ChallengeCredential(const std::string& configPath = "");
Zhiyi Zhang0a89b722017-04-28 17:56:01 -070052
53PUBLIC_WITH_TESTS_ELSE_PROTECTED:
54 JsonSection
55 processSelectInterest(const Interest& interest, CertificateRequest& request) override;
56
57 JsonSection
58 processValidateInterest(const Interest& interest, CertificateRequest& request) override;
59
60 std::list<std::string>
61 getSelectRequirements() override;
62
63 std::list<std::string>
64 getValidateRequirements(const std::string& status) override;
65
66 JsonSection
67 doGenSelectParamsJson(const std::string& status,
68 const std::list<std::string>& paramList) override;
69
70 JsonSection
71 doGenValidateParamsJson(const std::string& status,
72 const std::list<std::string>& paramList) override;
73
74PUBLIC_WITH_TESTS_ELSE_PRIVATE:
75 void
76 parseConfigFile();
77
78PUBLIC_WITH_TESTS_ELSE_PRIVATE:
79 static const std::string FAILURE_INVALID_CREDENTIAL;
80 static const std::string FAILURE_INVALID_FORMAT;
Zhiyi Zhanga9bda732017-05-20 22:58:55 -070081
Zhiyi Zhang70fe2582017-05-19 15:01:03 -070082 static const std::string JSON_CREDENTIAL_CERT;
83 static const std::string JSON_CREDENTIAL_SELF;
Zhiyi Zhang0a89b722017-04-28 17:56:01 -070084
85PUBLIC_WITH_TESTS_ELSE_PRIVATE:
86 std::list<security::v2::Certificate> m_trustAnchors;
87 std::string m_configFile;
88};
89
90} // namespace ndncert
91} // namespace ndn
92
93#endif // NDNCERT_CHALLENGE_CREDENTIAL_HPP