#include "LibItsSecurity_EncdecDeclarations.hh"

#include "EtsiTs103097Codec.hh"
#include "loggers.hh"

namespace LibItsSecurity__EncdecDeclarations {

  BITSTRING fx__enc__CertificateBase(IEEE1609dot2::CertificateBase const& p_cert) {
    loggers::get_instance().log_msg(">>> fx__enc__CertificateBase: ", p_cert);

    EtsiTs103097Codec codec;
    OCTETSTRING os;
    if (codec.encode(p_cert, os) == -1) {
      loggers::get_instance().warning("fx__enc__CertificateBase: -1 result code was returned");
      return int2bit(0, 1);
    }
    
    return oct2bit(os);
  }
  INTEGER fx__dec__ToBeSignedCertificate(BITSTRING& b, LibItsSecurity__TypesAndValues::ToBeSignedCertificate& p) {
    loggers::get_instance().log_msg(">>> fx__dec__ToBeSignedCertificate: ", b);

    return -1;
  }
            















  /****************************************************
 * @desc    External function to encode a SecuredMessage type
 * @param   value to encode
 * @return  encoded value
 ****************************************************/
// BITSTRING fx__enc__SecuredMessage(const LibItsSecurity__TypesAndValues::SecuredMessage& p)
// {
//   return int2bit(0,8);
// }

/****************************************************
 * @desc    External function to encode a SecuredMessage type
 * @param   value to encode
 * @return  encoded value
 ****************************************************/
BITSTRING fx__enc__SecuredMessage(const LibItsSecurity__TypesAndValues::SecuredMessage& p)
{
  return int2bit(0,8);
}

/****************************************************
 * @desc    External function to decode a SecuredMessage type
 * @param   value to encode
 * @return  encoded value
 ****************************************************/

INTEGER fx__dec__SecuredMessage(BITSTRING& b, LibItsSecurity__TypesAndValues::SecuredMessage& p)
{
  return -1;
}

/****************************************************
 * @desc    External function to encode a ToBeSignedSecuredMessage type
 * @param   value to encode
 * @return  encoded value
 ****************************************************/
BITSTRING fx__enc__ToBeSignedSecuredMessage(const LibItsSecurity__TypesAndValues::ToBeSignedSecuredMessage& p)
{
  return int2bit(0,8);
}

/****************************************************
 * @desc    External function to decode a ToBeSignedSecuredMessage type
 * @param   value to encode
 * @return  encoded value
 ****************************************************/

INTEGER fx__dec__ToBeSignedSecuredMessage(BITSTRING& b, LibItsSecurity__TypesAndValues::ToBeSignedSecuredMessage& p)
{
  return -1;
}

/****************************************************
 * @desc    External function to encode a Certificate type
 * @param   value to encode
 * @return  encoded value
 ****************************************************/
BITSTRING fx__enc__Certificate(const LibItsSecurity__TypesAndValues::Certificate& p)
{
  return int2bit(0,8);
}

/****************************************************
 * @desc    External function to decode a Certificate type
 * @param   value to encode
 * @return  encoded value
 ****************************************************/

INTEGER fx__dec__Certificate(BITSTRING& b, LibItsSecurity__TypesAndValues::Certificate& p)
{
  return -1;
}

/****************************************************
 * @desc    External function to encode a ToBeSignedCertificate type
 * @param   value to encode
 * @return  encoded value
 ****************************************************/
BITSTRING fx__enc__ToBeSignedCertificate(const LibItsSecurity__TypesAndValues::ToBeSignedCertificate& p)
{
  return int2bit(0,8);
}

/****************************************************
 * @desc    External function to decode a ToBeSignedCertificate type
 * @param   value to encode
 * @return  encoded value
 ****************************************************/
/*
INTEGER fx__dec__ToBeSignedCertificate(BITSTRING& b, LibItsSecurity__TypesAndValues::ToBeSignedCertificate& p)
{
  return -1;
}
*/
} //end namespace
