blob: 221e943508d97ce6f422b0b0fc78719a55f9fe8b [file] [log] [blame]
Yingdi Yu42f66462013-10-31 17:38:22 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013, Regents of the University of California
4 * Yingdi Yu
5 *
6 * BSD license, See the LICENSE file for more information
7 *
8 * Author: Yingdi Yu <yingdi@cs.ucla.edu>
9 */
10
Yingdi Yueaa84e22014-01-16 10:30:26 -080011#ifndef SEC_POLICY_CHRONO_CHAT_PANEL_H
12#define SEC_POLICY_CHRONO_CHAT_PANEL_H
Yingdi Yu42f66462013-10-31 17:38:22 -070013
Yingdi Yu6df61252014-01-21 11:05:11 -080014#include <ndn-cpp-dev/security/sec-policy.hpp>
15#include <ndn-cpp-et/policy/sec-rule-relative.hpp>
Yingdi Yu64206112013-12-24 11:16:32 +080016#include <ndn-cpp-et/cache/ttl-certificate-cache.hpp>
Yingdi Yu42f66462013-10-31 17:38:22 -070017#include <map>
18
19#include "endorse-certificate.h"
20
Yingdi Yueaa84e22014-01-16 10:30:26 -080021class SecPolicyChronoChatPanel : public ndn::SecPolicy
Yingdi Yu42f66462013-10-31 17:38:22 -070022{
23public:
Yingdi Yueaa84e22014-01-16 10:30:26 -080024 SecPolicyChronoChatPanel(const int & stepLimit = 10);
Yingdi Yu42f66462013-10-31 17:38:22 -070025
Yingdi Yueaa84e22014-01-16 10:30:26 -080026 ~SecPolicyChronoChatPanel()
Yingdi Yu42f66462013-10-31 17:38:22 -070027 {}
28
29 /**
30 * @brief check if the received data packet can escape from verification
31 * @param data the received data packet
32 * @return true if the data does not need to be verified, otherwise false
33 */
34 bool
35 skipVerifyAndTrust (const ndn::Data & data);
36
37 /**
38 * @brief check if PolicyManager has the verification rule for the received data
39 * @param data the received data packet
40 * @return true if the data must be verified, otherwise false
41 */
42 bool
43 requireVerify (const ndn::Data & data);
44
45 /**
46 * @brief check whether received data packet complies with the verification policy, and get the indication of next verification step
47 * @param data the received data packet
48 * @param stepCount the number of verification steps that have been done, used to track the verification progress
49 * @param verifiedCallback the callback function that will be called if the received data packet has been validated
50 * @param unverifiedCallback the callback function that will be called if the received data packet cannot be validated
51 * @return the indication of next verification step, NULL if there is no further step
52 */
Yingdi Yu64206112013-12-24 11:16:32 +080053 ndn::ptr_lib::shared_ptr<ndn::ValidationRequest>
54 checkVerificationPolicy(const ndn::ptr_lib::shared_ptr<ndn::Data>& data,
55 int stepCount,
56 const ndn::OnVerified& onVerified,
57 const ndn::OnVerifyFailed& onVerifyFailed);
Yingdi Yu42f66462013-10-31 17:38:22 -070058
59
60 /**
61 * @brief check if the signing certificate name and data name satify the signing policy
62 * @param dataName the name of data to be signed
63 * @param certificateName the name of signing certificate
64 * @return true if the signing certificate can be used to sign the data, otherwise false
65 */
66 bool
67 checkSigningPolicy(const ndn::Name & dataName, const ndn::Name & certificateName);
68
69 /**
70 * @brief Infer signing identity name according to policy, if the signing identity cannot be inferred, it should return empty name
71 * @param dataName, the name of data to be signed
72 * @return the signing identity.
73 */
74 ndn::Name
75 inferSigningIdentity(const ndn::Name & dataName);
76
77
78 void
79 addTrustAnchor(const EndorseCertificate& selfEndorseCertificate);
80
Yingdi Yu6ea54e42013-11-12 17:50:21 -080081 void
82 removeTrustAnchor(const ndn::Name& keyName);
83
Yingdi Yu64206112013-12-24 11:16:32 +080084 ndn::ptr_lib::shared_ptr<ndn::PublicKey>
Yingdi Yu6b56f092013-11-10 11:54:02 -080085 getTrustedKey(const ndn::Name& inviterCertName);
86
Yingdi Yu42f66462013-10-31 17:38:22 -070087private:
88 int m_stepLimit;
Yingdi Yu64206112013-12-24 11:16:32 +080089 ndn::TTLCertificateCache m_certificateCache;
90 ndn::ptr_lib::shared_ptr<ndn::Regex> m_localPrefixRegex;
Yingdi Yu6df61252014-01-21 11:05:11 -080091 ndn::ptr_lib::shared_ptr<ndn::SecRuleRelative> m_invitationDataSigningRule;
Yingdi Yu64206112013-12-24 11:16:32 +080092 ndn::ptr_lib::shared_ptr<ndn::Regex> m_kskRegex;
Yingdi Yu6df61252014-01-21 11:05:11 -080093 ndn::ptr_lib::shared_ptr<ndn::SecRuleRelative> m_dskRule;
94 ndn::ptr_lib::shared_ptr<ndn::SecRuleRelative> m_endorseeRule;
Yingdi Yu64206112013-12-24 11:16:32 +080095 ndn::ptr_lib::shared_ptr<ndn::Regex> m_keyNameRegex;
96 ndn::ptr_lib::shared_ptr<ndn::Regex> m_signingCertificateRegex;
Yingdi Yu6df61252014-01-21 11:05:11 -080097 std::map<ndn::Name, ndn::PublicKey> m_trustAnchors;
Yingdi Yu42f66462013-10-31 17:38:22 -070098
99};
100
101#endif