Jeff Thompson | 3a2eb2f | 2013-12-11 11:00:27 -0800 | [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 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
| 5 | * See COPYING for copyright and distribution information. |
| 6 | */ |
| 7 | |
Yingdi Yu | 4f32463 | 2014-01-15 18:10:03 -0800 | [diff] [blame] | 8 | #ifndef NDN_SEC_POLICY_SELF_VERIFY_HPP |
| 9 | #define NDN_SEC_POLICY_SELF_VERIFY_HPP |
Jeff Thompson | 3a2eb2f | 2013-12-11 11:00:27 -0800 | [diff] [blame] | 10 | |
Yingdi Yu | 4f32463 | 2014-01-15 18:10:03 -0800 | [diff] [blame] | 11 | #include "sec-policy.hpp" |
Jeff Thompson | 3a2eb2f | 2013-12-11 11:00:27 -0800 | [diff] [blame] | 12 | |
| 13 | namespace ndn { |
| 14 | |
Jeff Thompson | 3a2eb2f | 2013-12-11 11:00:27 -0800 | [diff] [blame] | 15 | /** |
Yingdi Yu | 4f32463 | 2014-01-15 18:10:03 -0800 | [diff] [blame] | 16 | * A SecPolicySelfVerify implements a PolicyManager to use the public key DER in the data packet's KeyLocator (if available) |
Jeff Thompson | 3a2eb2f | 2013-12-11 11:00:27 -0800 | [diff] [blame] | 17 | * or look in the IdentityStorage for the public key with the name in the KeyLocator (if available) and use |
| 18 | * it to verify the data packet, without searching a certificate chain. If the public key can't be found, the |
| 19 | * verification fails. |
| 20 | */ |
Yingdi Yu | 4f32463 | 2014-01-15 18:10:03 -0800 | [diff] [blame] | 21 | class SecPolicySelfVerify : public SecPolicy { |
Jeff Thompson | 3a2eb2f | 2013-12-11 11:00:27 -0800 | [diff] [blame] | 22 | public: |
| 23 | /** |
Yingdi Yu | 4f32463 | 2014-01-15 18:10:03 -0800 | [diff] [blame] | 24 | * Create a new SecPolicySelfVerify which will look up the public key in the given identityManager. |
Jeff Thompson | 3a2eb2f | 2013-12-11 11:00:27 -0800 | [diff] [blame] | 25 | * @param identityManager (optional) The IdentityManager for looking up the public key. This points to an object must which remain |
Yingdi Yu | 4f32463 | 2014-01-15 18:10:03 -0800 | [diff] [blame] | 26 | * valid during the life of this SecPolicySelfVerify. If omitted, then don't look for a public key with the name |
Jeff Thompson | 3a2eb2f | 2013-12-11 11:00:27 -0800 | [diff] [blame] | 27 | * in the KeyLocator and rely on the KeyLocator having the full public key DER. |
| 28 | */ |
Yingdi Yu | 4f32463 | 2014-01-15 18:10:03 -0800 | [diff] [blame] | 29 | SecPolicySelfVerify() |
Jeff Thompson | 3a2eb2f | 2013-12-11 11:00:27 -0800 | [diff] [blame] | 30 | { |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * The virtual destructor. |
| 35 | */ |
| 36 | virtual |
Yingdi Yu | 4f32463 | 2014-01-15 18:10:03 -0800 | [diff] [blame] | 37 | ~SecPolicySelfVerify(); |
Jeff Thompson | 3a2eb2f | 2013-12-11 11:00:27 -0800 | [diff] [blame] | 38 | |
| 39 | /** |
Yingdi Yu | e07e339 | 2014-01-28 10:29:27 -0800 | [diff] [blame] | 40 | * Check whether the received data packet complies with the verification policy, and get the indication of the next verification step. |
| 41 | * If there is no next verification step, that imlies policy MUST have already made the verification decision. |
| 42 | * i.e., either onVerified or onVerifyFailed callback is invoked. |
Jeff Thompson | 3a2eb2f | 2013-12-11 11:00:27 -0800 | [diff] [blame] | 43 | * @param data The Data object with the signature to check. |
| 44 | * @param stepCount The number of verification steps that have been done, used to track the verification progress. |
Jeff Thompson | 3a2eb2f | 2013-12-11 11:00:27 -0800 | [diff] [blame] | 45 | * @param onVerified If the signature is verified, this calls onVerified(data). |
Yingdi Yu | e07e339 | 2014-01-28 10:29:27 -0800 | [diff] [blame] | 46 | * @param onVerifyFailed If the signature check fails, this calls onVerifyFailed(data). |
| 47 | * @return the indication of next verification step, null if there is no further step. |
Jeff Thompson | 3a2eb2f | 2013-12-11 11:00:27 -0800 | [diff] [blame] | 48 | */ |
| 49 | virtual ptr_lib::shared_ptr<ValidationRequest> |
| 50 | checkVerificationPolicy |
Yingdi Yu | 4270f20 | 2014-01-28 14:19:16 -0800 | [diff] [blame] | 51 | (const ptr_lib::shared_ptr<const Data>& data, int stepCount, const OnVerified& onVerified, const OnVerifyFailed& onVerifyFailed); |
Yingdi Yu | e07e339 | 2014-01-28 10:29:27 -0800 | [diff] [blame] | 52 | |
Jeff Thompson | 3a2eb2f | 2013-12-11 11:00:27 -0800 | [diff] [blame] | 53 | /** |
Yingdi Yu | e07e339 | 2014-01-28 10:29:27 -0800 | [diff] [blame] | 54 | * Check whether the received interest packet complies with the verification policy, and get the indication of the next verification step. |
| 55 | * If there is no next verification step, that implies policy MUST have already made the verification decision. |
| 56 | * i.e., either onVerified or onVerifyFailed callback is invoked. |
| 57 | * @param data The Data object with the signature to check. |
| 58 | * @param stepCount The number of verification steps that have been done, used to track the verification progress. |
| 59 | * @param onVerified If the signature is verified, this calls onVerified(data). |
| 60 | * @param onVerifyFailed If the signature check fails, this calls onVerifyFailed(data). |
| 61 | * @return the indication of next verification step, null if there is no further step. |
Jeff Thompson | 3a2eb2f | 2013-12-11 11:00:27 -0800 | [diff] [blame] | 62 | */ |
Yingdi Yu | e07e339 | 2014-01-28 10:29:27 -0800 | [diff] [blame] | 63 | virtual ptr_lib::shared_ptr<ValidationRequest> |
| 64 | checkVerificationPolicy |
Yingdi Yu | 4270f20 | 2014-01-28 14:19:16 -0800 | [diff] [blame] | 65 | (const ptr_lib::shared_ptr<const Interest>& interest, int stepCount, const OnVerified& onVerified, const OnVerifyFailed& onVerifyFailed); |
Jeff Thompson | 3a2eb2f | 2013-12-11 11:00:27 -0800 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | } |
| 69 | |
| 70 | #endif |