/**
 * @author: Jeff Thompson
 * See COPYING for copyright and distribution information.
 */

#ifndef NDN_CONTENTOBJECT_H
#define	NDN_CONTENTOBJECT_H

#include "Name.h"
#include "PublisherPublicKeyDigest.h"
#include "Key.h"

#ifdef	__cplusplus
extern "C" {
#endif

struct ndn_Signature {
  unsigned char *digestAlgorithm;      /**< pointer to pre-allocated buffer.  0 for none.
                                        *   If none, default is 2.16.840.1.101.3.4.2.1 (sha-256). */
  unsigned int digestAlgorithmLength; /**< length of digestAlgorithm.  0 for none */
  unsigned char *witness;              /**< pointer to pre-allocated buffer.  0 for none. */
  unsigned int witnessLength;          /**< length of witness.  0 for none */
  unsigned char *signature;
  unsigned int signatureLength;
};

static inline void ndn_Signature_init(struct ndn_Signature *self) {
  self->digestAlgorithm = 0;
  self->digestAlgorithmLength = 0;
  self->witness = 0;
  self->witnessLength = 0;
  self->signature = 0;
  self->signatureLength = 0;
}

enum {
  ndn_ContentType_DATA = 0,
  ndn_ContentType_ENCR = 1,
  ndn_ContentType_GONE = 2,
  ndn_ContentType_KEY =  3,
  ndn_ContentType_LINK = 4,
  ndn_ContentType_NACK = 5
};

struct ndn_SignedInfo {
  struct ndn_PublisherPublicKeyDigest publisherPublicKeyDigest;
  // TODO: Implement timestamp
  int type;              /**< default is ndn_ContentType_DATA. -1 for none */
  int freshnessSeconds;  /**< -1 for none */
	unsigned char *finalBlockID;	    /**< pointer to pre-allocated buffer.  0 for none */
  unsigned int finalBlockIDLength;  /**< length of finalBlockID.  0 for none */
  struct ndn_KeyLocator keyLocator;
};

/**
 * Initialize the ndn_SignedInfo struct with values for none and the type to the default ndn_ContentType_DATA.
 * @param self pointer to the ndn_SignedInfo struct.
 */
static inline void ndn_SignedInfo_init(struct ndn_SignedInfo *self) {
  ndn_PublisherPublicKeyDigest_init(&self->publisherPublicKeyDigest);
  self->type = ndn_ContentType_DATA;
  self->freshnessSeconds = -1;
  self->finalBlockID = 0;
  self->finalBlockIDLength = 0;
  ndn_KeyLocator_init(&self->keyLocator);
}

struct ndn_ContentObject {
  struct ndn_Signature signature;
  struct ndn_Name name;
  struct ndn_SignedInfo signedInfo;
  unsigned char *content;     /**< pointer to the content */
  unsigned int contentLength; /**< length of content */
};

/**
 * Initialize an ndn_ContentObject struct with the pre-allocated nameComponents,
 * and defaults for all the values.
 * @param self pointer to the ndn_ContentObject struct
 * @param nameComponents the pre-allocated array of ndn_NameComponent
 * @param maxNameComponents the number of elements in the allocated nameComponents array
 */
static inline void ndn_ContentObject_init(struct ndn_ContentObject *self, struct ndn_NameComponent *nameComponents, unsigned int maxNameComponents) 
{
  ndn_Signature_init(&self->signature);
  ndn_Name_init(&self->name, nameComponents, maxNameComponents);
  ndn_SignedInfo_init(&self->signedInfo);
  self->content = 0;
  self->contentLength = 0;
}

#ifdef	__cplusplus
}
#endif

#endif
