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

#ifndef NDN_KEY_CHAIN_HPP
#define NDN_KEY_CHAIN_HPP

#include "../data.hpp"

namespace ndn {

class KeyChain {
public:
  /**
   * In data, set the meta info publisher public key digest and key locator key to the public key and set the 
   * signature using the private key.
   * Note: the caller must make sure the timestamp is correct, for example with 
   * data.getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0).
   * @param data The Data object to sign and set the key and signature.
   * @param publicKeyDer A pointer to a buffer with the DER-encoded public key.
   * @param publicKeyDerLength The number of bytes in publicKeyDer.
   * @param privateKeyDer A pointer to a buffer with the DER-encoded private key.
   * @param privateKeyDerLength The number of bytes in privateKeyDer.
   * @param wireFormat The WireFormat for calling encodeData.
   */
  static void sign
    (Data& data, const unsigned char *publicKeyDer, unsigned int publicKeyDerLength, 
     const unsigned char *privateKeyDer, unsigned int privateKeyDerLength, WireFormat& wireFormat);

  /**
   * Call sign with the default public and private keys.
   * @param data
   * @param wireFormat The WireFormat for calling encodeData, or WireFormat::getDefaultWireFormat() if omitted.
   */
  static void defaultSign(Data& data, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat());

  /**
   * Use the WireFormat to decode the input as a Data packet and use the public key in the key locator to 
   * verify the signature.
   * This does just uses the public key without checking whether it is certified.
   * @param input A pointer to the input buffer to decode.
   * @param inputLength The number of bytes in input.
   * @param wireFormat The WireFormat for calling decodeData.
   * @return true if the public key in the Data object verifies the object, false if not or if the Data object
   * doesn't have a public key.
   */
  static bool selfVerifyData(const unsigned char *input, unsigned int inputLength, WireFormat& wireFormat);
  
  static bool selfVerifyData(const unsigned char *input, unsigned int inputLength)
  {
    return selfVerifyData(input, inputLength, *WireFormat::getDefaultWireFormat());
  }
};

}

#endif
