encrypted-content.h
1 
22 #ifndef NDN_ENCRYPTED_CONTENT_H
23 #define NDN_ENCRYPTED_CONTENT_H
24 
25 #include <ndn-cpp/c/encrypt/encrypted-content-types.h>
26 #include "../key-locator.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
40 static __inline void ndn_EncryptedContent_initialize
41  (struct ndn_EncryptedContent *self, struct ndn_NameComponent *keyNameComponents,
42  size_t maxKeyNameComponents) {
43  self->algorithmType = (ndn_EncryptAlgorithmType)-1;
44  ndn_KeyLocator_initialize
45  (&self->keyLocator, keyNameComponents, maxKeyNameComponents);
46  ndn_Blob_initialize(&self->initialVector, 0, 0);
47  ndn_Blob_initialize(&self->payload, 0, 0);
48 }
49 
58 static __inline ndn_Error
59 ndn_EncryptedContent_setFromEncryptedContent
60  (struct ndn_EncryptedContent *self, const struct ndn_EncryptedContent *other)
61 {
62  ndn_Error error;
63 
64  if (other == self)
65  // Setting to itself. Do nothing.
66  return NDN_ERROR_success;
67 
68  self->algorithmType = other->algorithmType;
69  if ((error = ndn_KeyLocator_setFromKeyLocator
70  (&self->keyLocator, &other->keyLocator)))
71  return error;
72  ndn_Blob_setFromBlob(&self->initialVector, &other->initialVector);
73  ndn_Blob_setFromBlob(&self->payload, &other->payload);
74 
75  return NDN_ERROR_success;
76 }
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif
ndn_EncryptAlgorithmType algorithmType
-1 for none
Definition: encrypted-content-types.h:38
Copyright (C) 2016 Regents of the University of California.
Definition: encrypted-content-types.h:37
Copyright (C) 2015-2016 Regents of the University of California.
Definition: name-types.h:33