MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / encode_datawriter_submessage

Method encode_datawriter_submessage

dds/DCPS/security/CryptoBuiltInImpl.cpp:1487–1545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1485}
1486
1487bool CryptoBuiltInImpl::encode_datawriter_submessage(
1488 DDS::OctetSeq& encoded_rtps_submessage,
1489 const DDS::OctetSeq& plain_rtps_submessage,
1490 DatawriterCryptoHandle sending_datawriter_crypto,
1491 const DatareaderCryptoHandleSeq& receiving_datareader_crypto_list,
1492 CORBA::Long& receiving_datareader_crypto_list_index,
1493 SecurityException& ex)
1494{
1495 if (DDS::HANDLE_NIL == sending_datawriter_crypto) {
1496 return CommonUtilities::set_security_error(ex, -1, 0, "Invalid DataWriter handle");
1497 }
1498
1499 if (receiving_datareader_crypto_list_index < 0) {
1500 return CommonUtilities::set_security_error(ex, -1, 0, "Negative list index");
1501 }
1502
1503 const int len = static_cast<int>(receiving_datareader_crypto_list.length());
1504 // NOTE: as an extension to the spec, this plugin allows an empty list in the
1505 // case where the writer is sending to all associated readers.
1506 if (len && receiving_datareader_crypto_list_index >= len) {
1507 return CommonUtilities::set_security_error(ex, -1, 0, "List index too large");
1508 }
1509
1510 for (unsigned int i = 0; i < receiving_datareader_crypto_list.length(); ++i) {
1511 if (receiving_datareader_crypto_list[i] == DDS::HANDLE_NIL) {
1512 return CommonUtilities::set_security_error(ex, -1, 0, "Invalid DataReader handle in list");
1513 }
1514 }
1515
1516 NativeCryptoHandle encode_handle = sending_datawriter_crypto;
1517 ACE_Guard<ACE_Thread_Mutex> guard(mutex_);
1518 const EncryptOptions_t::const_iterator eo_iter = encrypt_options_.find(encode_handle);
1519 if (eo_iter == encrypt_options_.end()) {
1520 return CommonUtilities::set_security_error(ex, -1, 0, "Datawriter handle lacks encrypt options");
1521 }
1522
1523 if (!eo_iter->second.submessage_) {
1524 encoded_rtps_submessage = plain_rtps_submessage;
1525 receiving_datareader_crypto_list_index = len;
1526 return true;
1527 }
1528
1529 if (receiving_datareader_crypto_list.length() == 1) {
1530 const KeyTable_t::const_iterator iter = keys_.find(encode_handle);
1531 if (iter != keys_.end()) {
1532 const KeySeq& dw_keys = iter->second;
1533 if (dw_keys.length() == 1 && is_volatile_placeholder(dw_keys[0])) {
1534 encode_handle = receiving_datareader_crypto_list[0];
1535 }
1536 }
1537 }
1538
1539 const bool ok = encode_submessage(encoded_rtps_submessage,
1540 plain_rtps_submessage, encode_handle, ex);
1541 if (ok) {
1542 receiving_datareader_crypto_list_index = len;
1543 }
1544 return ok;

Callers 2

TEST_FFunction · 0.80

Calls 5

set_security_errorFunction · 0.85
is_volatile_placeholderFunction · 0.85
lengthMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected