LibItsSecurity_Encdec.cc 1.29 KB
Newer Older
#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);
  }

garciay's avatar
garciay committed
  INTEGER fx__dec__CertificateBase(BITSTRING& b, IEEE1609dot2::CertificateBase& p_cert) {
    loggers::get_instance().log_msg(">>> fx__dec__CertificateBase: ", b);

    EtsiTs103097Codec codec;
    OCTETSTRING is = bit2oct(b);
    if (codec.decode(is, p_cert) == -1) {
      loggers::get_instance().warning("fx__dec__CertificateBase: -1 result code was returned");
      return -1;
    }
    
    loggers::get_instance().log_msg("<<< fx__dec__CertificateBase: ", p_cert);
    return 0;
  
  BITSTRING fx__enc__ToBeSignedCertificate(const IEEE1609dot2::ToBeSignedCertificate& p) {
    return int2bit(0, 1);
  }
  
  BITSTRING fx__enc__Ieee1609Dot2Data(const IEEE1609dot2::Ieee1609Dot2Data& p) {
    return int2bit(0, 1);
  }
  
} //end namespace