blob: 2d0203e3b7b4ca666f3de9a7eba87a33ceea0169 [file] [log] [blame]
Prashanthc0029b62015-04-27 14:00:08 -07001#ifndef NDN_ENCRYPTED_CONTENT_HPP
2#define NDN_ENCRYPTED_CONTENT_HPP
3
4#include <ndn-cxx/encoding/tlv.hpp>
5#include <ndn-cxx/key-locator.hpp>
6#include <list>
7
8#include "tlv.hpp"
9
10namespace ndn {
11namespace gep {
12
13class EncryptedContent
14{
15public:
16 class Error : public ndn::tlv::Error
17 {
18 public:
19 explicit
20 Error(const std::string& what)
21 : ndn::tlv::Error(what)
22 {
23 }
24 };
25
26public:
27 EncryptedContent();
28
29 EncryptedContent(tlv::AlgorithmTypeValue type, const KeyLocator& keyLocator, const ConstBufferPtr& payload);
30
31 explicit
32 EncryptedContent(const Block& block);
33
34 void
35 setAlgorithmType(tlv::AlgorithmTypeValue type);
36
37 int32_t
38 getAlgorithmType() const
39 {
40 return m_type;
41 }
42
43 bool
44 hasKeyLocator() const
45 {
46 return m_hasKeyLocator;
47 }
48
49 void
50 setKeyLocator(const KeyLocator& keyLocator);
51
52 const KeyLocator&
53 getKeyLocator() const;
54
55 void
56 setPayload(const ConstBufferPtr& payload);
57
58 const ConstBufferPtr
59 getPayload() const;
60
61 template<encoding::Tag TAG>
62 size_t
63 wireEncode(EncodingImpl<TAG>& block) const;
64
65 const Block&
66 wireEncode() const;
67
68 void
69 wireDecode(const Block& wire);
70
71public:
72 bool
73 operator==(const EncryptedContent& rhs) const;
74 bool
75 operator!=(const EncryptedContent& rhs) const
76 {
77 return !(*this == rhs);
78 }
79
80private:
81 int32_t m_type;
82 bool m_hasKeyLocator;
83 KeyLocator m_keyLocator;
84 ConstBufferPtr m_payload;
85
86 mutable Block m_wire;
87};
88
89} // namespace gep
90} // namespace ndn
91
92#endif // NDN_ENCRYPTED_CONTENT_HPP