Zhenkai Zhu | dd1f14d | 2013-03-13 12:04:28 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2013 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu> |
| 19 | * Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 20 | */ |
| 21 | |
| 22 | #ifndef CCNX_VERIFIER_H |
| 23 | #define CCNX_VERIFIER_H |
| 24 | |
| 25 | #include "ccnx-common.h" |
Zhenkai Zhu | dd1f14d | 2013-03-13 12:04:28 -0700 | [diff] [blame] | 26 | #include "ccnx-name.h" |
Zhenkai Zhu | 9dd9adc | 2013-03-13 16:12:09 -0700 | [diff] [blame] | 27 | #include "ccnx-cert.h" |
Zhenkai Zhu | dd1f14d | 2013-03-13 12:04:28 -0700 | [diff] [blame] | 28 | #include "ccnx-pco.h" |
| 29 | #include <map> |
Zhenkai Zhu | 746d444 | 2013-03-13 17:06:54 -0700 | [diff] [blame] | 30 | #include <boost/thread/locks.hpp> |
| 31 | #include <boost/thread/recursive_mutex.hpp> |
| 32 | #include <boost/thread/thread.hpp> |
Zhenkai Zhu | dd1f14d | 2013-03-13 12:04:28 -0700 | [diff] [blame] | 33 | |
| 34 | namespace Ccnx { |
| 35 | |
| 36 | class CcnxWrapper; |
| 37 | |
Zhenkai Zhu | dd1f14d | 2013-03-13 12:04:28 -0700 | [diff] [blame] | 38 | class Verifier |
| 39 | { |
| 40 | public: |
| 41 | Verifier(CcnxWrapper *ccnx); |
| 42 | ~Verifier(); |
| 43 | |
Zhenkai Zhu | d5d99be | 2013-03-13 19:15:56 -0700 | [diff] [blame^] | 44 | bool verify(const PcoPtr &pco, double maxWait); |
Zhenkai Zhu | dd1f14d | 2013-03-13 12:04:28 -0700 | [diff] [blame] | 45 | |
| 46 | private: |
| 47 | |
| 48 | private: |
| 49 | CcnxWrapper *m_ccnx; |
| 50 | Hash m_rootKeyDigest; |
Zhenkai Zhu | 9dd9adc | 2013-03-13 16:12:09 -0700 | [diff] [blame] | 51 | typedef std::map<Hash, CertPtr> CertCache; |
| 52 | CertCache m_certCache; |
Zhenkai Zhu | 746d444 | 2013-03-13 17:06:54 -0700 | [diff] [blame] | 53 | typedef boost::recursive_mutex RecLock; |
| 54 | typedef boost::unique_lock<RecLock> UniqueRecLock; |
| 55 | RecLock m_cacheLock; |
Zhenkai Zhu | dd1f14d | 2013-03-13 12:04:28 -0700 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | } // Ccnx |
| 59 | |
| 60 | #endif // CCNX_VERIFIER_H |