Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enclaves #365

Merged
merged 2 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rmw_fastrtps_cpp/src/init_rmw_context_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ init_context_impl(rmw_context_t * context)
context->options.domain_id,
&context->options.security_options,
(context->options.localhost_only == RMW_LOCALHOST_ONLY_ENABLED) ? 1 : 0,
context->options.security_context,
context->options.enclave,
common_context.get()),
[&](CustomParticipantInfo * participant_info) {
if (RMW_RET_OK != rmw_fastrtps_shared_cpp::destroy_participant(participant_info)) {
Expand Down Expand Up @@ -173,7 +173,7 @@ init_context_impl(rmw_context_t * context)
}
common_context->graph_cache.add_participant(
common_context->gid,
context->options.security_context);
context->options.enclave);

graph_guard_condition.release();
publisher.release();
Expand Down
8 changes: 4 additions & 4 deletions rmw_fastrtps_cpp/src/rmw_node_names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ rmw_get_node_names(
}

rmw_ret_t
rmw_get_node_names_with_security_contexts(
rmw_get_node_names_with_enclaves(
const rmw_node_t * node,
rcutils_string_array_t * node_names,
rcutils_string_array_t * node_namespaces,
rcutils_string_array_t * security_contexts)
rcutils_string_array_t * enclaves)
{
return rmw_fastrtps_shared_cpp::__rmw_get_node_names_with_security_contexts(
eprosima_fastrtps_identifier, node, node_names, node_namespaces, security_contexts);
return rmw_fastrtps_shared_cpp::__rmw_get_node_names_with_enclaves(
eprosima_fastrtps_identifier, node, node_names, node_namespaces, enclaves);
}
} // extern "C"
4 changes: 2 additions & 2 deletions rmw_fastrtps_dynamic_cpp/src/init_rmw_context_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ init_context_impl(rmw_context_t * context)
context->options.domain_id,
&context->options.security_options,
(context->options.localhost_only == RMW_LOCALHOST_ONLY_ENABLED) ? 1 : 0,
context->options.security_context,
context->options.enclave,
common_context.get()),
[&](CustomParticipantInfo * participant_info) {
if (RMW_RET_OK != rmw_fastrtps_shared_cpp::destroy_participant(participant_info)) {
Expand Down Expand Up @@ -174,7 +174,7 @@ init_context_impl(rmw_context_t * context)
}
common_context->graph_cache.add_participant(
common_context->gid,
context->options.security_context);
context->options.enclave);

graph_guard_condition.release();
publisher.release();
Expand Down
8 changes: 4 additions & 4 deletions rmw_fastrtps_dynamic_cpp/src/rmw_node_names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ rmw_get_node_names(
}

rmw_ret_t
rmw_get_node_names_with_security_contexts(
rmw_get_node_names_with_enclaves(
const rmw_node_t * node,
rcutils_string_array_t * node_names,
rcutils_string_array_t * node_namespaces,
rcutils_string_array_t * security_contexts)
rcutils_string_array_t * enclaves)
{
return rmw_fastrtps_shared_cpp::__rmw_get_node_names_with_security_contexts(
eprosima_fastrtps_identifier, node, node_names, node_namespaces, security_contexts);
return rmw_fastrtps_shared_cpp::__rmw_get_node_names_with_enclaves(
eprosima_fastrtps_identifier, node, node_names, node_namespaces, enclaves);
}
} // extern "C"
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ class ParticipantListener : public eprosima::fastrtps::ParticipantListener
case eprosima::fastrtps::rtps::ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT:
{
auto map = rmw::impl::cpp::parse_key_value(info.info.m_userData);
auto name_found = map.find("securitycontext");
auto name_found = map.find("enclave");

if (name_found == map.end()) {
return;
}
auto security_context =
auto enclave =
std::string(name_found->second.begin(), name_found->second.end());

context->graph_cache.add_participant(
rmw_fastrtps_shared_cpp::create_rmw_gid(
identifier_, info.info.m_guid),
security_context);
enclave);
break;
}
case eprosima::fastrtps::rtps::ParticipantDiscoveryInfo::REMOVED_PARTICIPANT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ create_participant(
size_t domain_id,
const rmw_security_options_t * security_options,
bool localhost_only,
const char * security_context,
const char * enclave,
rmw_dds_common::Context * common_context);

RMW_FASTRTPS_SHARED_CPP_PUBLIC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ __rmw_init_event(

RMW_FASTRTPS_SHARED_CPP_PUBLIC
rmw_ret_t
__rmw_get_node_names_with_security_contexts(
__rmw_get_node_names_with_enclaves(
const char * identifier,
const rmw_node_t * node,
rcutils_string_array_t * node_names,
rcutils_string_array_t * node_namespaces,
rcutils_string_array_t * security_contexts);
rcutils_string_array_t * enclaves);

RMW_FASTRTPS_SHARED_CPP_PUBLIC
rmw_ret_t
Expand Down
8 changes: 4 additions & 4 deletions rmw_fastrtps_shared_cpp/src/participant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ rmw_fastrtps_shared_cpp::create_participant(
size_t domain_id,
const rmw_security_options_t * security_options,
bool localhost_only,
const char * security_context,
const char * enclave,
rmw_dds_common::Context * common_context)
{
if (!security_options) {
Expand All @@ -167,16 +167,16 @@ rmw_fastrtps_shared_cpp::create_participant(

participantAttrs.rtps.builtin.domainId = static_cast<uint32_t>(domain_id);

size_t length = snprintf(nullptr, 0, "securitycontext=%s;", security_context) + 1;
size_t length = snprintf(nullptr, 0, "enclave=%s;", enclave) + 1;
participantAttrs.rtps.userData.resize(length);
int written = snprintf(
reinterpret_cast<char *>(participantAttrs.rtps.userData.data()),
length, "securitycontext=%s;", security_context);
length, "enclave=%s;", enclave);
if (written < 0 || written > static_cast<int>(length) - 1) {
RMW_SET_ERROR_MSG("failed to populate user_data buffer");
return nullptr;
}
participantAttrs.rtps.setName(security_context);
participantAttrs.rtps.setName(enclave);

bool leave_middleware_default_qos = false;
const char * env_value;
Expand Down
14 changes: 7 additions & 7 deletions rmw_fastrtps_shared_cpp/src/rmw_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ rmw_init_options_init(
init_options->implementation_identifier = identifier;
init_options->allocator = allocator;
init_options->impl = nullptr;
init_options->security_context = NULL;
init_options->enclave = NULL;
init_options->domain_id = RMW_DEFAULT_DOMAIN_ID;
init_options->security_options = rmw_get_default_security_options();
init_options->localhost_only = RMW_LOCALHOST_ONLY_DEFAULT;
Expand All @@ -64,19 +64,19 @@ rmw_init_options_copy(
const rcutils_allocator_t * allocator = &src->allocator;
rmw_ret_t ret = RMW_RET_OK;

allocator->deallocate(dst->security_context, allocator->state);
allocator->deallocate(dst->enclave, allocator->state);
*dst = *src;
dst->security_context = NULL;
dst->enclave = NULL;
dst->security_options = rmw_get_zero_initialized_security_options();

dst->security_context = rcutils_strdup(src->security_context, *allocator);
if (src->security_context && !dst->security_context) {
dst->enclave = rcutils_strdup(src->enclave, *allocator);
if (src->enclave && !dst->enclave) {
ret = RMW_RET_BAD_ALLOC;
goto fail;
}
return rmw_security_options_copy(&src->security_options, allocator, &dst->security_options);
fail:
allocator->deallocate(dst->security_context, allocator->state);
allocator->deallocate(dst->enclave, allocator->state);
return ret;
}

Expand All @@ -91,7 +91,7 @@ rmw_init_options_fini(const char * identifier, rmw_init_options_t * init_options
init_options->implementation_identifier,
identifier,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
allocator.deallocate(init_options->security_context, allocator.state);
allocator.deallocate(init_options->enclave, allocator.state);
rmw_security_options_fini(&init_options->security_options, &allocator);
*init_options = rmw_get_zero_initialized_init_options();
return RMW_RET_OK;
Expand Down
8 changes: 4 additions & 4 deletions rmw_fastrtps_shared_cpp/src/rmw_node_names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ __rmw_get_node_names(
}

rmw_ret_t
__rmw_get_node_names_with_security_contexts(
__rmw_get_node_names_with_enclaves(
const char * identifier,
const rmw_node_t * node,
rcutils_string_array_t * node_names,
rcutils_string_array_t * node_namespaces,
rcutils_string_array_t * security_contexts)
rcutils_string_array_t * enclaves)
{
if (!node) {
RMW_SET_ERROR_MSG("null node handle");
Expand All @@ -86,7 +86,7 @@ __rmw_get_node_names_with_security_contexts(
if (rmw_check_zero_rmw_string_array(node_namespaces) != RMW_RET_OK) {
return RMW_RET_ERROR;
}
if (rmw_check_zero_rmw_string_array(security_contexts) != RMW_RET_OK) {
if (rmw_check_zero_rmw_string_array(enclaves) != RMW_RET_OK) {
return RMW_RET_ERROR;
}
if (node->implementation_identifier != identifier) {
Expand All @@ -99,7 +99,7 @@ __rmw_get_node_names_with_security_contexts(
return common_context->graph_cache.get_node_names(
node_names,
node_namespaces,
security_contexts,
enclaves,
&allocator);
}
} // namespace rmw_fastrtps_shared_cpp