blob: 3393e8a27bb1557016af0b9775f185299931f320 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Yingdi Yu64c3fb42014-02-26 17:30:04 -08002/**
Alexander Afanasyevc169a812014-05-20 20:37:29 -04003 * Copyright (c) 2013-2014 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
Yingdi Yu64c3fb42014-02-26 17:30:04 -080020 */
21
22#ifndef NDN_SECURITY_SECURED_BAG_HPP
23#define NDN_SECURITY_SECURED_BAG_HPP
24
25#include "../common.hpp"
26#include "identity-certificate.hpp"
Yingdi Yu64c3fb42014-02-26 17:30:04 -080027
28namespace ndn {
29
30class SecuredBag
31{
32public:
Junxiao Shibe8d2212014-12-01 23:41:24 -070033 class Error : public tlv::Error
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070034 {
35 public:
36 explicit
37 Error(const std::string& what)
Junxiao Shibe8d2212014-12-01 23:41:24 -070038 : tlv::Error(what)
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070039 {
40 }
41 };
Yingdi Yu64c3fb42014-02-26 17:30:04 -080042
Junxiao Shibe8d2212014-12-01 23:41:24 -070043 SecuredBag();
44
45 explicit
46 SecuredBag(const Block& wire);
Yingdi Yu64c3fb42014-02-26 17:30:04 -080047
48 SecuredBag(const IdentityCertificate& cert,
Junxiao Shibe8d2212014-12-01 23:41:24 -070049 ConstBufferPtr key);
Yingdi Yu64c3fb42014-02-26 17:30:04 -080050
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070051 virtual
Junxiao Shibe8d2212014-12-01 23:41:24 -070052 ~SecuredBag();
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070053
Yingdi Yu64c3fb42014-02-26 17:30:04 -080054 void
Junxiao Shibe8d2212014-12-01 23:41:24 -070055 wireDecode(const Block& wire);
Yingdi Yu64c3fb42014-02-26 17:30:04 -080056
Junxiao Shibe8d2212014-12-01 23:41:24 -070057 const Block&
58 wireEncode() const;
Yingdi Yu64c3fb42014-02-26 17:30:04 -080059
60 const IdentityCertificate&
61 getCertificate() const
62 {
63 return m_cert;
64 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070065
Yingdi Yu64c3fb42014-02-26 17:30:04 -080066 ConstBufferPtr
67 getKey() const
68 {
69 return m_key;
70 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070071
Yingdi Yu64c3fb42014-02-26 17:30:04 -080072private:
73 IdentityCertificate m_cert;
74 ConstBufferPtr m_key;
75
76 mutable Block m_wire;
77};
78
79} // namespace ndn
80
Junxiao Shibe8d2212014-12-01 23:41:24 -070081#endif // NDN_SECURITY_SECURED_BAG_HPP