Commit a1e6df0f authored by filatov's avatar filatov
Browse files

accept security envelop v2

parent b0cc3163
......@@ -186,6 +186,9 @@ void geonetworking_layer::send_data(OCTETSTRING& data, params& params) {
loggers::get_instance().log("<<< geonetworking_layer::send_data");
}
const TTCN_RAWdescriptor_t _intx_raw_= {RAW_INTX,SG_NO,ORDER_MSB,ORDER_MSB,ORDER_LSB,ORDER_MSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN};
const TTCN_Typedescriptor_t _intx_descr_={"IntX", NULL, &_intx_raw_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE};
void geonetworking_layer::receive_data(OCTETSTRING& data, params& params) {
loggers::get_instance().log_msg(">>> geonetworking_layer::receive_data: ", data);
......@@ -202,14 +205,37 @@ void geonetworking_layer::receive_data(OCTETSTRING& data, params& params) {
///////////////////
// FIXME Check what to do with this!
if (*static_cast<const unsigned char*>(secured_data) == 0x02) { // This is the old Security version format, discard it
loggers::get_instance().warning("geonetworking_layer::receive_data: Old security format, discard it");
return;
}
///////////////////
if (security_services::get_instance().verify_and_extract_gn_payload(secured_data, _enable_security_checks, ieee_1609dot2_data, unsecured_gn_payload, params) != 0) {
loggers::get_instance().warning("geonetworking_layer::receive_data: Security error");
if (_enable_security_checks) {
return;
INTEGER n; int r;
TTCN_Buffer buf(secured_data);
loggers::get_instance().warning("geonetworking_layer::receive_data: Old security format, parse manualy");
buf.increase_pos(1); // skip version
n.decode(_intx_descr_, buf, TTCN_EncDec::CT_RAW);
if(n > (int)buf.get_read_len()){
loggers::get_instance().warning("geonetworking_layer::receive_data: Broken security headers");
return;
}
buf.increase_pos((int)n); // skip headers
// payload type
r = *buf.get_read_data();
buf.increase_pos(1);
if(r != 3){
n.decode(_intx_descr_, buf, TTCN_EncDec::CT_RAW);
//payload length
if(n > (int)buf.get_read_len()){
loggers::get_instance().warning("geonetworking_layer::receive_data: Broken security payload");
return;
}
unsecured_gn_payload = OCTETSTRING(n, buf.get_read_data());
}
}else{
///////////////////
if (security_services::get_instance().verify_and_extract_gn_payload(secured_data, _enable_security_checks, ieee_1609dot2_data, unsecured_gn_payload, params) != 0) {
loggers::get_instance().warning("geonetworking_layer::receive_data: Security error");
if (_enable_security_checks) {
return;
}
}
}
// Update data
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment