blob: 2d861a33bc711b68303393b146d6a30c83682e2d [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,
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070030 const uint8_t* payload, size_t payloadLen,
31 const uint8_t* iv = 0, size_t ivLen = 0);
Prashanthc0029b62015-04-27 14:00:08 -070032
33 explicit
34 EncryptedContent(const Block& block);
35
36 void
37 setAlgorithmType(tlv::AlgorithmTypeValue type);
38
39 int32_t
40 getAlgorithmType() const
41 {
42 return m_type;
43 }
44
45 bool
46 hasKeyLocator() const
47 {
48 return m_hasKeyLocator;
49 }
50
51 void
52 setKeyLocator(const KeyLocator& keyLocator);
53
54 const KeyLocator&
55 getKeyLocator() const;
56
57 void
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070058 setInitialVector(const uint8_t* iv, size_t ivLen);
Prashanthc0029b62015-04-27 14:00:08 -070059
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070060 const Buffer&
Prashanth Swaminathanb1b95962015-07-06 13:13:08 -070061 getInitialVector() const;
62
63 void
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070064 setPayload(const uint8_t* payload, size_t payloadLen);
Prashanth Swaminathanb1b95962015-07-06 13:13:08 -070065
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070066 const Buffer&
Prashanthc0029b62015-04-27 14:00:08 -070067 getPayload() const;
68
69 template<encoding::Tag TAG>
70 size_t
71 wireEncode(EncodingImpl<TAG>& block) const;
72
73 const Block&
74 wireEncode() const;
75
76 void
77 wireDecode(const Block& wire);
78
79public:
80 bool
81 operator==(const EncryptedContent& rhs) const;
82 bool
83 operator!=(const EncryptedContent& rhs) const
84 {
85 return !(*this == rhs);
86 }
87
88private:
89 int32_t m_type;
90 bool m_hasKeyLocator;
91 KeyLocator m_keyLocator;
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070092 Buffer m_payload;
93 Buffer m_iv;
Prashanthc0029b62015-04-27 14:00:08 -070094
95 mutable Block m_wire;
96};
97
98} // namespace gep
99} // namespace ndn
100
101#endif // NDN_ENCRYPTED_CONTENT_HPP