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" |
| 26 | #include "ccnx-wrapper.h" |
| 27 | #include "ccnx-name.h" |
| 28 | #include "ccnx-key.h" |
| 29 | #include "ccnx-pco.h" |
| 30 | #include <map> |
| 31 | |
| 32 | namespace Ccnx { |
| 33 | |
| 34 | class CcnxWrapper; |
| 35 | |
| 36 | // not thread-safe, don't want to add a mutex for KeyCache |
| 37 | // which increases the possibility of dead-locking |
| 38 | // ccnx-wrapper would take care of thread-safety issue |
| 39 | class Verifier |
| 40 | { |
| 41 | public: |
| 42 | Verifier(CcnxWrapper *ccnx); |
| 43 | ~Verifier(); |
| 44 | |
| 45 | bool verify(const PcoPtr &pco); |
| 46 | |
| 47 | private: |
| 48 | |
| 49 | private: |
| 50 | CcnxWrapper *m_ccnx; |
| 51 | Hash m_rootKeyDigest; |
| 52 | typedef std::map<Hash, KeyPtr> KeyCache; |
| 53 | KeyCache m_keyCache; |
| 54 | }; |
| 55 | |
| 56 | } // Ccnx |
| 57 | |
| 58 | #endif // CCNX_VERIFIER_H |