blob: c31d70522a0853d00cacb3c111899baeb375ac76 [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
Prashanth Swaminathanb1b95962015-07-06 13:13:08 -070029 EncryptedContent(tlv::AlgorithmTypeValue type, const KeyLocator& keyLocator,
30 ConstBufferPtr payload, ConstBufferPtr iv = nullptr);
Prashanthc0029b62015-04-27 14:00:08 -070031
32 explicit
33 EncryptedContent(const Block& block);
34
35 void
36 setAlgorithmType(tlv::AlgorithmTypeValue type);
37
38 int32_t
39 getAlgorithmType() const
40 {
41 return m_type;
42 }
43
44 bool
45 hasKeyLocator() const
46 {
47 return m_hasKeyLocator;
48 }
49
50 void
51 setKeyLocator(const KeyLocator& keyLocator);
52
53 const KeyLocator&
54 getKeyLocator() const;
55
56 void
Prashanth Swaminathanb1b95962015-07-06 13:13:08 -070057 setInitialVector(ConstBufferPtr iv);
Prashanthc0029b62015-04-27 14:00:08 -070058
Prashanth Swaminathanb1b95962015-07-06 13:13:08 -070059 ConstBufferPtr
60 getInitialVector() const;
61
62 void
63 setPayload(ConstBufferPtr payload);
64
65 ConstBufferPtr
Prashanthc0029b62015-04-27 14:00:08 -070066 getPayload() const;
67
68 template<encoding::Tag TAG>
69 size_t
70 wireEncode(EncodingImpl<TAG>& block) const;
71
72 const Block&
73 wireEncode() const;
74
75 void
76 wireDecode(const Block& wire);
77
78public:
79 bool
80 operator==(const EncryptedContent& rhs) const;
81 bool
82 operator!=(const EncryptedContent& rhs) const
83 {
84 return !(*this == rhs);
85 }
86
87private:
88 int32_t m_type;
89 bool m_hasKeyLocator;
90 KeyLocator m_keyLocator;
91 ConstBufferPtr m_payload;
Prashanth Swaminathanb1b95962015-07-06 13:13:08 -070092 ConstBufferPtr m_iv;
Prashanthc0029b62015-04-27 14:00:08 -070093
94 mutable Block m_wire;
95};
96
97} // namespace gep
98} // namespace ndn
99
100#endif // NDN_ENCRYPTED_CONTENT_HPP