Skip to content

Commit

Permalink
Use separate types per path entry.
Browse files Browse the repository at this point in the history
Previously `mc-sgx-ql::PathInitializer::with_paths()` used the same
generic type for all the pathlike parameters. This had the side effect that all four
paths had to be the same type. Now each pathlike parameter has it's own
type.
  • Loading branch information
nick-mobilecoin committed Oct 18, 2022
1 parent 02c43f6 commit 8c9a0b5
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions dcap/ql/src/quote_enclave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl PathInitializer {
Self::with_paths(
"/usr/lib/x86_64-linux-gnu/libsgx_qe3.signed.so.1",
"/usr/lib/x86_64-linux-gnu/libsgx_pce.signed.so.1",
None,
None::<&Path>,
"/usr/lib/x86_64-linux-gnu/libsgx_id_enclave.signed.so.1",
)
}
Expand All @@ -73,12 +73,18 @@ impl PathInitializer {
/// * one of the paths does not point to a file
/// * one of the paths is longer than 259 (bytes)
/// * one of the paths contains a null (0) byte.
pub fn with_paths<P: AsRef<Path>>(
quoting_enclave: P,
provisioning_certificate_enclave: P,
quote_provider_library: Option<P>,
id_enclave: P,
) -> Result<()> {
pub fn with_paths<P1, P2, P3, P4>(
quoting_enclave: P1,
provisioning_certificate_enclave: P2,
quote_provider_library: Option<P3>,
id_enclave: P4,
) -> Result<()>
where
P1: AsRef<Path>,
P2: AsRef<Path>,
P3: AsRef<Path>,
P4: AsRef<Path>,
{
let mut value = PATH_INITIALIZER.lock().expect("Mutex has been poisoned");
if value.is_none() {
Self::set_paths(
Expand Down Expand Up @@ -110,12 +116,18 @@ impl PathInitializer {
}
}

fn set_paths<P: AsRef<Path>>(
quoting_enclave: P,
provisioning_certificate_enclave: P,
quote_provider_library: Option<P>,
id_enclave: P,
) -> Result<PathInitializer> {
fn set_paths<P1, P2, P3, P4>(
quoting_enclave: P1,
provisioning_certificate_enclave: P2,
quote_provider_library: Option<P3>,
id_enclave: P4,
) -> Result<PathInitializer>
where
P1: AsRef<Path>,
P2: AsRef<Path>,
P3: AsRef<Path>,
P4: AsRef<Path>,
{
Self::set_path(PathKind::QuotingEnclave, quoting_enclave)?;
Self::set_path(
PathKind::ProvisioningCertificateEnclave,
Expand Down

0 comments on commit 8c9a0b5

Please sign in to comment.