Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 1 | /* -*- 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 Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 11 | #include "sec-policy-chrono-chat-invitation.h" |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 12 | #include <ndn-cpp-dev/security/verifier.hpp> |
| 13 | #include <ndn-cpp-dev/security/signature-sha256-with-rsa.hpp> |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 14 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 15 | #include "logging.h" |
| 16 | |
| 17 | using namespace std; |
| 18 | using namespace ndn; |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 19 | using namespace ndn::ptr_lib; |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 20 | |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 21 | INIT_LOGGER("SecPolicyChronoChatInvitation"); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 22 | |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 23 | SecPolicyChronoChatInvitation::SecPolicyChronoChatInvitation(const string& chatroomName, |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 24 | const Name& signingIdentity, |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 25 | int stepLimit) |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 26 | : m_chatroomName(chatroomName) |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 27 | , m_signingIdentity(signingIdentity) |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 28 | , m_stepLimit(stepLimit) |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 29 | { |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 30 | m_invitationPolicyRule = make_shared<SecRuleRelative>("^<ndn><broadcast><chronos><invitation>([^<chatroom>]*)<chatroom>", |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 31 | "^([^<KEY>]*)<KEY>(<>*)[<dsk-.*><ksk-.*>]<ID-CERT>$", |
| 32 | "==", "\\1", "\\1\\2", true); |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 33 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 34 | m_kskRegex = make_shared<Regex>("^([^<KEY>]*)<KEY>(<>*<ksk-.*>)<ID-CERT><>$", "\\1\\2"); |
Yingdi Yu | ed8cfc4 | 2013-11-01 17:37:51 -0700 | [diff] [blame] | 35 | |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 36 | m_dskRule = make_shared<SecRuleRelative>("^([^<KEY>]*)<KEY><dsk-.*><ID-CERT><>$", |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 37 | "^([^<KEY>]*)<KEY>(<>*)<ksk-.*><ID-CERT>$", |
| 38 | "==", "\\1", "\\1\\2", true); |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 39 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 40 | m_keyNameRegex = make_shared<Regex>("^([^<KEY>]*)<KEY>(<>*<ksk-.*>)<ID-CERT>$", "\\1\\2"); |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 41 | } |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 42 | |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 43 | SecPolicyChronoChatInvitation::~SecPolicyChronoChatInvitation() |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 44 | {} |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 45 | |
| 46 | bool |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 47 | SecPolicyChronoChatInvitation::skipVerifyAndTrust (const Data& data) |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 48 | { return false; } |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 49 | |
| 50 | bool |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 51 | SecPolicyChronoChatInvitation::requireVerify (const Data& data) |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 52 | { return true; } |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 53 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 54 | shared_ptr<ValidationRequest> |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 55 | SecPolicyChronoChatInvitation::checkVerificationPolicy(const shared_ptr<Data>& data, |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 56 | int stepCount, |
| 57 | const OnVerified& onVerified, |
| 58 | const OnVerifyFailed& onVerifyFailed) |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 59 | { |
| 60 | if(m_stepLimit == stepCount) |
| 61 | { |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 62 | _LOG_ERROR("Reach the maximum steps of verification!"); |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 63 | onVerifyFailed(data); |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 64 | return shared_ptr<ValidationRequest>(); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 65 | } |
| 66 | |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 67 | try{ |
| 68 | SignatureSha256WithRsa sig(data->getSignature()); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 69 | |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 70 | const Name & keyLocatorName = sig.getKeyLocator().getName(); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 71 | |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 72 | if(m_invitationPolicyRule->satisfy(*data)) |
| 73 | { |
| 74 | // Name keyName = IdentityCertificate::certificateNameToPublicKeyName(keyLocatorName); |
| 75 | // map<Name, PublicKey>::iterator it = m_trustAnchors.find(keyName); |
| 76 | // if(m_trustAnchors.end() != it) |
| 77 | // { |
| 78 | // if(Sha256WithRsaHandler::verifySignature(*data, it->second)) |
| 79 | // onVerified(data); |
| 80 | // else |
| 81 | // onVerifyFailed(data); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 82 | |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 83 | // return shared_ptr<ValidationRequest>(); |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 84 | // } |
Yingdi Yu | ed8cfc4 | 2013-11-01 17:37:51 -0700 | [diff] [blame] | 85 | |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 86 | shared_ptr<const Certificate> trustedCert = m_certificateCache.getCertificate(keyLocatorName); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 87 | |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 88 | if(static_cast<bool>(trustedCert)){ |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 89 | if(Verifier::verifySignature(*data, sig, trustedCert->getPublicKeyInfo())) |
| 90 | onVerified(data); |
Yingdi Yu | ed8cfc4 | 2013-11-01 17:37:51 -0700 | [diff] [blame] | 91 | else |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 92 | onVerifyFailed(data); |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 93 | |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 94 | return shared_ptr<ValidationRequest>(); |
Yingdi Yu | ed8cfc4 | 2013-11-01 17:37:51 -0700 | [diff] [blame] | 95 | } |
Yingdi Yu | ed8cfc4 | 2013-11-01 17:37:51 -0700 | [diff] [blame] | 96 | |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 97 | OnVerified recursiveVerifiedCallback = boost::bind(&SecPolicyChronoChatInvitation::onDskCertificateVerified, |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 98 | this, |
| 99 | _1, |
| 100 | data, |
| 101 | onVerified, |
| 102 | onVerifyFailed); |
| 103 | |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 104 | OnVerifyFailed recursiveUnverifiedCallback = boost::bind(&SecPolicyChronoChatInvitation::onDskCertificateVerifyFailed, |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 105 | this, |
| 106 | _1, |
| 107 | data, |
| 108 | onVerifyFailed); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 109 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 110 | |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 111 | shared_ptr<Interest> interest = make_shared<Interest>(keyLocatorName); |
| 112 | |
| 113 | shared_ptr<ValidationRequest> nextStep = make_shared<ValidationRequest>(interest, |
| 114 | recursiveVerifiedCallback, |
| 115 | recursiveUnverifiedCallback, |
| 116 | 0, |
| 117 | stepCount + 1); |
| 118 | return nextStep; |
| 119 | } |
| 120 | |
| 121 | if(m_kskRegex->match(data->getName())) |
| 122 | { |
| 123 | Name keyName = m_kskRegex->expand(); |
| 124 | map<Name, PublicKey>::iterator it = m_trustAnchors.find(keyName); |
| 125 | if(m_trustAnchors.end() != it) |
| 126 | { |
| 127 | IdentityCertificate identityCertificate(*data); |
| 128 | if(it->second == identityCertificate.getPublicKeyInfo()) |
| 129 | { |
| 130 | onVerified(data); |
| 131 | } |
| 132 | else |
| 133 | onVerifyFailed(data); |
| 134 | } |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 135 | else |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 136 | onVerifyFailed(data); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 137 | |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 138 | return shared_ptr<ValidationRequest>(); |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | if(m_dskRule->satisfy(*data)) |
| 142 | { |
| 143 | m_keyNameRegex->match(keyLocatorName); |
| 144 | Name keyName = m_keyNameRegex->expand(); |
| 145 | |
| 146 | if(m_trustAnchors.end() != m_trustAnchors.find(keyName)) |
| 147 | if(Verifier::verifySignature(*data, sig, m_trustAnchors[keyName])) |
| 148 | onVerified(data); |
| 149 | else |
| 150 | onVerifyFailed(data); |
| 151 | else |
| 152 | onVerifyFailed(data); |
| 153 | |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 154 | return shared_ptr<ValidationRequest>(); |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 155 | } |
| 156 | }catch(SignatureSha256WithRsa::Error &e){ |
| 157 | _LOG_DEBUG("checkVerificationPolicy " << e.what()); |
| 158 | onVerifyFailed(data); |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 159 | return shared_ptr<ValidationRequest>(); |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 160 | }catch(KeyLocator::Error &e){ |
| 161 | _LOG_DEBUG("checkVerificationPolicy " << e.what()); |
| 162 | onVerifyFailed(data); |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 163 | return shared_ptr<ValidationRequest>(); |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 164 | } |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 165 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 166 | onVerifyFailed(data); |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 167 | return shared_ptr<ValidationRequest>(); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 168 | } |
| 169 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 170 | bool |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 171 | SecPolicyChronoChatInvitation::checkSigningPolicy(const Name& dataName, |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 172 | const Name& certificateName) |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 173 | { |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 174 | return true; |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 175 | } |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 176 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 177 | Name |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 178 | SecPolicyChronoChatInvitation::inferSigningIdentity(const Name& dataName) |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 179 | { |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 180 | return m_signingIdentity; |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | void |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 184 | SecPolicyChronoChatInvitation::addTrustAnchor(const EndorseCertificate& selfEndorseCertificate) |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 185 | { m_trustAnchors.insert(pair <Name, PublicKey > (selfEndorseCertificate.getPublicKeyName(), selfEndorseCertificate.getPublicKeyInfo())); } |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 186 | |
| 187 | |
| 188 | // void |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 189 | // SecPolicyChronoChatInvitation::addChatDataRule(const Name& prefix, |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 190 | // const IdentityCertificate identityCertificate) |
| 191 | // { |
| 192 | // Name dataPrefix = prefix; |
| 193 | // dataPrefix.append("chronos").append(m_chatroomName); |
| 194 | // Ptr<Regex> dataRegex = Regex::fromName(prefix); |
| 195 | // Name certName = identityCertificate.getName(); |
| 196 | // Name signerName = certName.getPrefix(certName.size()-1); |
| 197 | // Ptr<Regex> signerRegex = Regex::fromName(signerName, true); |
| 198 | |
| 199 | // ChatPolicyRule rule(dataRegex, signerRegex); |
| 200 | // map<Name, ChatPolicyRule>::iterator it = m_chatDataRules.find(dataPrefix); |
| 201 | // if(it != m_chatDataRules.end()) |
| 202 | // it->second = rule; |
| 203 | // else |
| 204 | // m_chatDataRules.insert(pair <Name, ChatPolicyRule > (dataPrefix, rule)); |
| 205 | // } |
| 206 | |
| 207 | |
| 208 | void |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 209 | SecPolicyChronoChatInvitation::onDskCertificateVerified(const shared_ptr<Data>& certData, |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 210 | shared_ptr<Data> originalData, |
| 211 | const OnVerified& onVerified, |
| 212 | const OnVerifyFailed& onVerifyFailed) |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 213 | { |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 214 | shared_ptr<IdentityCertificate> certificate = make_shared<IdentityCertificate>(*certData); |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 215 | |
| 216 | if(!certificate->isTooLate() && !certificate->isTooEarly()) |
| 217 | { |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 218 | Name certName = certificate->getName().getPrefix(-1); |
| 219 | map<Name, shared_ptr<IdentityCertificate> >::iterator it = m_dskCertificates.find(certName); |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 220 | if(it == m_dskCertificates.end()) |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 221 | m_dskCertificates.insert(pair <Name, shared_ptr<IdentityCertificate> > (certName, certificate)); |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 222 | |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 223 | if(Verifier::verifySignature(*originalData, originalData->getSignature(), certificate->getPublicKeyInfo())) |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 224 | { |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 225 | onVerified(originalData); |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 226 | return; |
| 227 | } |
| 228 | } |
| 229 | else |
| 230 | { |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 231 | onVerifyFailed(originalData); |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 232 | return; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | void |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 237 | SecPolicyChronoChatInvitation::onDskCertificateVerifyFailed(const shared_ptr<Data>& certData, |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 238 | shared_ptr<Data> originalData, |
| 239 | const OnVerifyFailed& onVerifyFailed) |
| 240 | { onVerifyFailed(originalData); } |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 241 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 242 | shared_ptr<IdentityCertificate> |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 243 | SecPolicyChronoChatInvitation::getValidatedDskCertificate(const ndn::Name& certName) |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 244 | { |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 245 | map<Name, shared_ptr<IdentityCertificate> >::iterator it = m_dskCertificates.find(certName); |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 246 | if(m_dskCertificates.end() != it) |
| 247 | return it->second; |
| 248 | else |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame] | 249 | return shared_ptr<IdentityCertificate>(); |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 250 | } |