| 1545 | } |
| 1546 | |
| 1547 | bool CryptoBuiltInImpl::encode_datareader_submessage( |
| 1548 | DDS::OctetSeq& encoded_rtps_submessage, |
| 1549 | const DDS::OctetSeq& plain_rtps_submessage, |
| 1550 | DatareaderCryptoHandle sending_datareader_crypto, |
| 1551 | const DatawriterCryptoHandleSeq& receiving_datawriter_crypto_list, |
| 1552 | SecurityException& ex) |
| 1553 | { |
| 1554 | if (DDS::HANDLE_NIL == sending_datareader_crypto) { |
| 1555 | return CommonUtilities::set_security_error(ex, -1, 0, "Invalid DataReader handle"); |
| 1556 | } |
| 1557 | |
| 1558 | for (unsigned int i = 0; i < receiving_datawriter_crypto_list.length(); ++i) { |
| 1559 | if (receiving_datawriter_crypto_list[i] == DDS::HANDLE_NIL) { |
| 1560 | return CommonUtilities::set_security_error(ex, -1, 0, "Invalid DataWriter handle in list"); |
| 1561 | } |
| 1562 | } |
| 1563 | |
| 1564 | NativeCryptoHandle encode_handle = sending_datareader_crypto; |
| 1565 | ACE_Guard<ACE_Thread_Mutex> guard(mutex_); |
| 1566 | if (receiving_datawriter_crypto_list.length() == 1) { |
| 1567 | const KeyTable_t::const_iterator iter = keys_.find(encode_handle); |
| 1568 | if (iter != keys_.end()) { |
| 1569 | const KeySeq& dr_keys = iter->second; |
| 1570 | if (dr_keys.length() == 1 && is_volatile_placeholder(dr_keys[0])) { |
| 1571 | encode_handle = receiving_datawriter_crypto_list[0]; |
| 1572 | } |
| 1573 | } |
| 1574 | } |
| 1575 | |
| 1576 | return encode_submessage(encoded_rtps_submessage, plain_rtps_submessage, |
| 1577 | encode_handle, ex); |
| 1578 | } |
| 1579 | |
| 1580 | bool CryptoBuiltInImpl::encode_rtps_message( |
| 1581 | DDS::OctetSeq& encoded_rtps_message, |
no test coverage detected