blob: ce3d4500e95bda9a07677af72baada0c07b67ae1 [file] [log] [blame]
Zhenkai Zhudd1f14d2013-03-13 12:04:28 -07001/* -*- 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
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070022#ifndef NDNX_VERIFIER_H
23#define NDNX_VERIFIER_H
Zhenkai Zhudd1f14d2013-03-13 12:04:28 -070024
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070025#include "ndnx-common.h"
26#include "ndnx-name.h"
27#include "ndnx-cert.h"
28#include "ndnx-pco.h"
Zhenkai Zhudd1f14d2013-03-13 12:04:28 -070029#include <map>
Zhenkai Zhu746d4442013-03-13 17:06:54 -070030#include <boost/thread/locks.hpp>
31#include <boost/thread/recursive_mutex.hpp>
32#include <boost/thread/thread.hpp>
Zhenkai Zhudd1f14d2013-03-13 12:04:28 -070033
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070034namespace Ndnx {
Zhenkai Zhudd1f14d2013-03-13 12:04:28 -070035
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070036class NdnxWrapper;
Zhenkai Zhudd1f14d2013-03-13 12:04:28 -070037
Zhenkai Zhudd1f14d2013-03-13 12:04:28 -070038class Verifier
39{
40public:
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070041 Verifier(NdnxWrapper *ndnx);
Zhenkai Zhudd1f14d2013-03-13 12:04:28 -070042 ~Verifier();
43
Zhenkai Zhud5d99be2013-03-13 19:15:56 -070044 bool verify(const PcoPtr &pco, double maxWait);
Zhenkai Zhudd1f14d2013-03-13 12:04:28 -070045
46private:
47
48private:
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070049 NdnxWrapper *m_ndnx;
Zhenkai Zhudd1f14d2013-03-13 12:04:28 -070050 Hash m_rootKeyDigest;
Zhenkai Zhu9dd9adc2013-03-13 16:12:09 -070051 typedef std::map<Hash, CertPtr> CertCache;
52 CertCache m_certCache;
Zhenkai Zhu746d4442013-03-13 17:06:54 -070053 typedef boost::recursive_mutex RecLock;
54 typedef boost::unique_lock<RecLock> UniqueRecLock;
55 RecLock m_cacheLock;
Zhenkai Zhudd1f14d2013-03-13 12:04:28 -070056};
57
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070058} // Ndnx
Zhenkai Zhudd1f14d2013-03-13 12:04:28 -070059
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070060#endif // NDNX_VERIFIER_H