blob: fbfb15136567485f53c0e753d7d819f5c9f24356 [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 Afanasyev4c9a3d52017-01-03 17:45:19 -08003 * Copyright (c) 2013-2017 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
Alexander Afanasyev4c9a3d52017-01-03 17:45:19 -080022#ifndef NDN_SECURITY_V1_SECURED_BAG_HPP
23#define NDN_SECURITY_V1_SECURED_BAG_HPP
Yingdi Yu64c3fb42014-02-26 17:30:04 -080024
Alexander Afanasyev4c9a3d52017-01-03 17:45:19 -080025#include "../../common.hpp"
26#include "identity-certificate.hpp"
Yingdi Yu64c3fb42014-02-26 17:30:04 -080027
28namespace ndn {
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070029namespace security {
Alexander Afanasyev4c9a3d52017-01-03 17:45:19 -080030namespace v1 {
Yingdi Yu64c3fb42014-02-26 17:30:04 -080031
32class SecuredBag
33{
34public:
Junxiao Shibe8d2212014-12-01 23:41:24 -070035 class Error : public tlv::Error
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070036 {
37 public:
38 explicit
39 Error(const std::string& what)
Junxiao Shibe8d2212014-12-01 23:41:24 -070040 : tlv::Error(what)
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070041 {
42 }
43 };
Yingdi Yu64c3fb42014-02-26 17:30:04 -080044
Junxiao Shibe8d2212014-12-01 23:41:24 -070045 SecuredBag();
46
47 explicit
48 SecuredBag(const Block& wire);
Yingdi Yu64c3fb42014-02-26 17:30:04 -080049
Alexander Afanasyev4c9a3d52017-01-03 17:45:19 -080050 SecuredBag(const IdentityCertificate& cert,
Junxiao Shibe8d2212014-12-01 23:41:24 -070051 ConstBufferPtr key);
Yingdi Yu64c3fb42014-02-26 17:30:04 -080052
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070053 virtual
Junxiao Shibe8d2212014-12-01 23:41:24 -070054 ~SecuredBag();
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070055
Yingdi Yu64c3fb42014-02-26 17:30:04 -080056 void
Junxiao Shibe8d2212014-12-01 23:41:24 -070057 wireDecode(const Block& wire);
Yingdi Yu64c3fb42014-02-26 17:30:04 -080058
Junxiao Shibe8d2212014-12-01 23:41:24 -070059 const Block&
60 wireEncode() const;
Yingdi Yu64c3fb42014-02-26 17:30:04 -080061
Alexander Afanasyev4c9a3d52017-01-03 17:45:19 -080062 const IdentityCertificate&
Yingdi Yu64c3fb42014-02-26 17:30:04 -080063 getCertificate() const
64 {
65 return m_cert;
66 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070067
Yingdi Yu64c3fb42014-02-26 17:30:04 -080068 ConstBufferPtr
69 getKey() const
70 {
71 return m_key;
72 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070073
Yingdi Yu64c3fb42014-02-26 17:30:04 -080074private:
Alexander Afanasyev4c9a3d52017-01-03 17:45:19 -080075 IdentityCertificate m_cert;
Yingdi Yu64c3fb42014-02-26 17:30:04 -080076 ConstBufferPtr m_key;
77
78 mutable Block m_wire;
79};
80
Alexander Afanasyev4c9a3d52017-01-03 17:45:19 -080081} // namespace v1
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070082} // namespace security
Yingdi Yu64c3fb42014-02-26 17:30:04 -080083} // namespace ndn
84
Alexander Afanasyev4c9a3d52017-01-03 17:45:19 -080085#endif // NDN_SECURITY_V1_SECURED_BAG_HPP