encrypted-content-lite.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_ENCRYPTED_CONTENT_LITE_HPP
24 #define NDN_ENCRYPTED_CONTENT_LITE_HPP
25 
26 #include "../key-locator-lite.hpp"
27 #include "../../c/encrypt/encrypted-content-types.h"
28 
29 namespace ndn {
30 
37 public:
48  (ndn_NameComponent* keyNameComponents, size_t maxKeyNameComponents);
49 
54  ndn_EncryptAlgorithmType
55  getAlgorithmType() const { return algorithmType; }
56 
61  const KeyLocatorLite&
62  getKeyLocator() const { return KeyLocatorLite::downCast(keyLocator); }
63 
65  getKeyLocator() { return KeyLocatorLite::downCast(keyLocator); }
66 
71  const BlobLite&
72  getInitialVector() const { return BlobLite::downCast(initialVector); }
73 
78  const BlobLite&
79  getPayload() const { return BlobLite::downCast(payload); }
80 
88  setAlgorithmType(ndn_EncryptAlgorithmType algorithmType)
89  {
90  this->algorithmType = algorithmType;
91  return *this;
92  }
93 
102  setInitialVector(const BlobLite& initialVector)
103  {
104  BlobLite::downCast(this->initialVector) = initialVector;
105  return *this;
106  }
107 
116  setPayload(const BlobLite& payload)
117  {
118  BlobLite::downCast(this->payload) = payload;
119  return *this;
120  }
121 
128  ndn_Error
129  set(const EncryptedContentLite& other);
130 
137  static EncryptedContentLite&
138  downCast(ndn_EncryptedContent& encryptedContent)
139  {
140  return *(EncryptedContentLite*)&encryptedContent;
141  }
142 
143  static const EncryptedContentLite&
144  downCast(const ndn_EncryptedContent& encryptedContent)
145  {
146  return *(EncryptedContentLite*)&encryptedContent;
147  }
148 
149 private:
150  // Declare friends who can downcast to the private base.
151  friend class Tlv0_1_1WireFormatLite;
152 
159 
165  EncryptedContentLite& operator=(const EncryptedContentLite& other);
166 };
167 
168 }
169 
170 #endif
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
ndn_Error set(const EncryptedContentLite &other)
Set this encryptedContent to have the values from the other encryptedContent.
Definition: encrypted-content-lite.cpp:34
ndn_EncryptAlgorithmType algorithmType
-1 for none
Definition: encrypted-content-types.h:38
EncryptedContentLite & setAlgorithmType(ndn_EncryptAlgorithmType algorithmType)
Set the algorithm type.
Definition: encrypted-content-lite.hpp:88
static KeyLocatorLite & downCast(ndn_KeyLocator &keyLocator)
Downcast the reference to the ndn_KeyLocator struct to a KeyLocatorLite.
Definition: key-locator-lite.hpp:100
An EncryptedContentLite holds an encryption type, a payload and other fields representing encrypted c...
Definition: encrypted-content-lite.hpp:36
Copyright (C) 2016 Regents of the University of California.
Definition: encrypted-content-types.h:37
static BlobLite & downCast(ndn_Blob &blob)
Downcast the reference to the ndn_Blob struct to a BlobLite.
Definition: blob-lite.hpp:76
A KeyLocatorLite holds a type and other info to represent the key which signs a Data packet...
Definition: key-locator-lite.hpp:34
ndn_EncryptAlgorithmType getAlgorithmType() const
Get the algorithm type.
Definition: encrypted-content-lite.hpp:55
Copyright (C) 2015-2016 Regents of the University of California.
Definition: name-types.h:33
const BlobLite & getInitialVector() const
Get the initial vector.
Definition: encrypted-content-lite.hpp:72
A BlobLite holds a pointer to an immutable pre-allocated buffer and its length This is like a JavaScr...
Definition: blob-lite.hpp:37
const KeyLocatorLite & getKeyLocator() const
Get the key locator.
Definition: encrypted-content-lite.hpp:62
EncryptedContentLite(ndn_NameComponent *keyNameComponents, size_t maxKeyNameComponents)
Create a EncryptedContentLite with values for none.
Definition: encrypted-content-lite.cpp:28
static EncryptedContentLite & downCast(ndn_EncryptedContent &encryptedContent)
Downcast the reference to the ndn_EncryptedContent struct to an EncryptedContentLite.
Definition: encrypted-content-lite.hpp:138
EncryptedContentLite & setPayload(const BlobLite &payload)
Set the encrypted payload.
Definition: encrypted-content-lite.hpp:116
EncryptedContentLite & setInitialVector(const BlobLite &initialVector)
Set the initial vector.
Definition: encrypted-content-lite.hpp:102
const BlobLite & getPayload() const
Get the payload.
Definition: encrypted-content-lite.hpp:79