encrypted-content.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_ENCRYPTED_CONTENT_HPP
24 #define NDN_ENCRYPTED_CONTENT_HPP
25 
26 #include "../c/encrypt/algo/encrypt-params-types.h"
27 #include "../key-locator.hpp"
28 #include "../lite/encrypt/encrypted-content-lite.hpp"
29 
30 namespace ndn {
31 
38 public:
43  : algorithmType_((ndn_EncryptAlgorithmType)-1)
44  {
45  }
46 
51  ndn_EncryptAlgorithmType
52  getAlgorithmType() const { return algorithmType_; }
53 
58  const KeyLocator&
59  getKeyLocator() const { return keyLocator_; }
60 
61  KeyLocator&
62  getKeyLocator() { return keyLocator_; }
63 
68  const Blob&
69  getInitialVector() const { return initialVector_; }
70 
75  const Blob&
76  getPayload() const { return payload_; }
77 
85  setAlgorithmType(ndn_EncryptAlgorithmType algorithmType)
86  {
87  algorithmType_ = algorithmType;
88  return *this;
89  }
90 
100  setKeyLocator(const KeyLocator& keyLocator)
101  {
102  keyLocator_ = keyLocator;
103  return *this;
104  }
105 
114  setInitialVector(const Blob& initialVector)
115  {
116  initialVector_ = initialVector;
117  return *this;
118  }
119 
128  setPayload(const Blob& payload)
129  {
130  payload_ = payload;
131  return *this;
132  }
133 
140  Blob
142  {
143  return wireFormat.encodeEncryptedContent(*this);
144  }
145 
154  void
155  wireDecode
156  (const uint8_t *input, size_t inputLength,
158  {
159  wireFormat.decodeEncryptedContent(*this, input, inputLength);
160  }
161 
169  void
170  wireDecode
171  (const std::vector<uint8_t>& input,
173  {
174  wireDecode(&input[0], input.size(), wireFormat);
175  }
176 
184  void
185  wireDecode
186  (const Blob& input,
188  {
189  wireDecode(input.buf(), input.size(), wireFormat);
190  }
191 
200  void
201  get(EncryptedContentLite& encryptedContentLite) const;
202 
208  void
209  set(const EncryptedContentLite& encryptedContentLite);
210 
211 private:
212  ndn_EncryptAlgorithmType algorithmType_;
213  KeyLocator keyLocator_;
214  Blob initialVector_;
215  Blob payload_;
216 };
217 
218 }
219 
220 #endif
EncryptedContent()
Create an EncryptedContent where all the values are unspecified.
Definition: encrypted-content.hpp:42
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
EncryptedContent & setInitialVector(const Blob &initialVector)
Set the initial vector.
Definition: encrypted-content.hpp:114
const KeyLocator & getKeyLocator() const
Get the key locator.
Definition: encrypted-content.hpp:59
EncryptedContent & setKeyLocator(const KeyLocator &keyLocator)
Set this object to use a copy of the given KeyLocator object.
Definition: encrypted-content.hpp:100
Blob wireEncode(WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
Encode this EncryptedContent for a particular wire format.
Definition: encrypted-content.hpp:141
const Blob & getPayload() const
Get the payload.
Definition: encrypted-content.hpp:76
An EncryptedContentLite holds an encryption type, a payload and other fields representing encrypted c...
Definition: encrypted-content-lite.hpp:36
An EncryptedContent holds an encryption type, a payload and other fields representing encrypted conte...
Definition: encrypted-content.hpp:37
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
const uint8_t * buf() const
Return a const pointer to the first byte of the immutable byte array, or 0 if the pointer is null...
Definition: blob.hpp:159
EncryptedContent & setAlgorithmType(ndn_EncryptAlgorithmType algorithmType)
Set the algorithm type.
Definition: encrypted-content.hpp:85
void wireDecode(const uint8_t *input, size_t inputLength, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
Decode the input using a particular wire format and update this EncryptedContent. ...
Definition: encrypted-content.hpp:156
size_t size() const
Return the length of the immutable byte array.
Definition: blob.hpp:147
const Blob & getInitialVector() const
Get the initial vector.
Definition: encrypted-content.hpp:69
ndn_EncryptAlgorithmType getAlgorithmType() const
Get the algorithm type.
Definition: encrypted-content.hpp:52
void set(const EncryptedContentLite &encryptedContentLite)
Clear this EncryptedContent, and set the values by copying from encryptedContentLite.
Definition: encrypted-content.cpp:39
static WireFormat * getDefaultWireFormat()
Return the default WireFormat used by default encoding and decoding methods which was set with setDef...
Definition: wire-format.cpp:34
EncryptedContent & setPayload(const Blob &payload)
Set the encrypted payload.
Definition: encrypted-content.hpp:128
Definition: wire-format.hpp:39
Definition: key-locator.hpp:35