Skip to content

Commit

Permalink
Accept protected interpreter submessages
Browse files Browse the repository at this point in the history
Interpreter submessage protection not in spec, accept for compatibility.
  • Loading branch information
SelimV committed Nov 8, 2023
1 parent c684881 commit 3238d10
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
9 changes: 7 additions & 2 deletions src/rtps/message_receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,11 @@ impl MessageReceiver {
error!("Destination GUID did not match the handle used for decoding.");
}
}
Ok(DecodeOutcome::Success(DecodedSubmessage::Interpreter(interpreter_submessage))) => {
// This is not defined in the specification, but we accept for compatibility, as
// we would also accept unprotected ones.
self.handle_interpreter_submessage(interpreter_submessage);
}
Ok(DecodeOutcome::KeysNotFound(header_key_id)) => {
trace!(
"No matching submessage decode keys found for the key id {:?} for the remote \
Expand All @@ -955,10 +960,10 @@ impl MessageReceiver {
};
}

fn handle_interpreter_submessage(&mut self, interp_subm: InterpreterSubmessage)
fn handle_interpreter_submessage(&mut self, interpreter_submessage: InterpreterSubmessage)
// no return value, just change state of self.
{
match interp_subm {
match interpreter_submessage {
InterpreterSubmessage::InfoTimestamp(ts_struct, _flags) => {
// flags value was used already when parsing timestamp into an Option
self.source_timestamp = ts_struct.timestamp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bytes::Bytes;
use enumflags2::BitFlags;
use speedy::{Readable, Writable};
use log::warn;
use log::{info, warn};

use crate::{
messages::submessages::{
Expand Down Expand Up @@ -733,10 +733,16 @@ impl CryptoTransform for CryptographicBuiltin {
}
}

SubmessageBody::Interpreter(_) => Err(security_error!(
"Interpreter submessage after successful submessage decryption. This is not in the \
specification."
)),
SubmessageBody::Interpreter(interpreter_submessage) => {
info!(
"Interpreter submessage after successful submessage decryption. This is not in the \
specification, but we accept for compatibility as we also accept unprotected \
interpreter submessages."
);
Ok(DecodeOutcome::Success(DecodedSubmessage::Interpreter(
interpreter_submessage,
)))
}
SubmessageBody::Security(_) => Err(security_error!(
"Security submessage after successful submessage decryption."
)),
Expand Down
4 changes: 2 additions & 2 deletions src/security/cryptographic/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use speedy::{Readable, Writable};

use crate::{
messages::submessages::submessage::{ReaderSubmessage, WriterSubmessage},
messages::submessages::submessage::{InterpreterSubmessage, ReaderSubmessage, WriterSubmessage},
rtps::Submessage,
security::types::DataHolder,
structure::guid::GuidPrefix,
Expand Down Expand Up @@ -116,7 +116,7 @@ impl From<EncodedSubmessage> for Vec<Submessage> {
pub enum DecodedSubmessage {
// TODO: Should we support interpreter submessages here? The specification is unclear on this.
// See 8.5.1.6
//Interpreter(InterpreterSubmessage),
Interpreter(InterpreterSubmessage),
Writer(WriterSubmessage, Vec<EndpointCryptoHandle>),
Reader(ReaderSubmessage, Vec<EndpointCryptoHandle>),
}
Expand Down

0 comments on commit 3238d10

Please sign in to comment.