Prashanth | c0029b6 | 2015-04-27 14:00:08 -0700 | [diff] [blame] | 1 | #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 | |
| 10 | namespace ndn { |
| 11 | namespace gep { |
| 12 | |
| 13 | class EncryptedContent |
| 14 | { |
| 15 | public: |
| 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 | |
| 26 | public: |
| 27 | EncryptedContent(); |
| 28 | |
Prashanth Swaminathan | b1b9596 | 2015-07-06 13:13:08 -0700 | [diff] [blame] | 29 | EncryptedContent(tlv::AlgorithmTypeValue type, const KeyLocator& keyLocator, |
Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 30 | const uint8_t* payload, size_t payloadLen, |
| 31 | const uint8_t* iv = 0, size_t ivLen = 0); |
Prashanth | c0029b6 | 2015-04-27 14:00:08 -0700 | [diff] [blame] | 32 | |
| 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 Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 58 | setInitialVector(const uint8_t* iv, size_t ivLen); |
Prashanth | c0029b6 | 2015-04-27 14:00:08 -0700 | [diff] [blame] | 59 | |
Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 60 | const Buffer& |
Prashanth Swaminathan | b1b9596 | 2015-07-06 13:13:08 -0700 | [diff] [blame] | 61 | getInitialVector() const; |
| 62 | |
| 63 | void |
Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 64 | setPayload(const uint8_t* payload, size_t payloadLen); |
Prashanth Swaminathan | b1b9596 | 2015-07-06 13:13:08 -0700 | [diff] [blame] | 65 | |
Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 66 | const Buffer& |
Prashanth | c0029b6 | 2015-04-27 14:00:08 -0700 | [diff] [blame] | 67 | 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 | |
| 79 | public: |
| 80 | bool |
| 81 | operator==(const EncryptedContent& rhs) const; |
| 82 | bool |
| 83 | operator!=(const EncryptedContent& rhs) const |
| 84 | { |
| 85 | return !(*this == rhs); |
| 86 | } |
| 87 | |
| 88 | private: |
| 89 | int32_t m_type; |
| 90 | bool m_hasKeyLocator; |
| 91 | KeyLocator m_keyLocator; |
Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 92 | Buffer m_payload; |
| 93 | Buffer m_iv; |
Prashanth | c0029b6 | 2015-04-27 14:00:08 -0700 | [diff] [blame] | 94 | |
| 95 | mutable Block m_wire; |
| 96 | }; |
| 97 | |
| 98 | } // namespace gep |
| 99 | } // namespace ndn |
| 100 | |
| 101 | #endif // NDN_ENCRYPTED_CONTENT_HPP |