From 1a392e800ac4e3ead8bf4d4bfd0865e4089a9c1a Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Fri, 11 Apr 2025 12:34:09 +0200 Subject: [PATCH] fixup! refactor(intel-dcap-api): split client.rs into smaller files Signed-off-by: Harald Hoyer --- .../intel-dcap-api/src/client/enclave_identity.rs | 4 ++-- crates/intel-dcap-api/src/client/fmspc.rs | 4 ++-- crates/intel-dcap-api/src/client/helpers.rs | 6 ++---- crates/intel-dcap-api/src/client/mod.rs | 13 ++++++------- crates/intel-dcap-api/src/client/pck_cert.rs | 4 ++-- crates/intel-dcap-api/src/client/pck_crl.rs | 6 ++++-- crates/intel-dcap-api/src/client/registration.rs | 2 ++ crates/intel-dcap-api/src/client/tcb_info.rs | 8 ++++---- 8 files changed, 24 insertions(+), 23 deletions(-) diff --git a/crates/intel-dcap-api/src/client/enclave_identity.rs b/crates/intel-dcap-api/src/client/enclave_identity.rs index 0d20b72..64e760b 100644 --- a/crates/intel-dcap-api/src/client/enclave_identity.rs +++ b/crates/intel-dcap-api/src/client/enclave_identity.rs @@ -1,6 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright (c) 2025 Matter Labs +//! Enclave Identity + use super::ApiClient; // Import from parent module use crate::{ error::IntelApiError, @@ -9,8 +11,6 @@ use crate::{ }; impl ApiClient { - // --- Enclave Identity --- - /// Retrieves the SGX QE Identity from the Intel API. /// /// Returns Enclave Identity JSON string (Appendix B) and Issuer Chain header. diff --git a/crates/intel-dcap-api/src/client/fmspc.rs b/crates/intel-dcap-api/src/client/fmspc.rs index cb74422..3963f1f 100644 --- a/crates/intel-dcap-api/src/client/fmspc.rs +++ b/crates/intel-dcap-api/src/client/fmspc.rs @@ -1,6 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright (c) 2025 Matter Labs +//! FMSPCs & TCB Evaluation Data Numbers + use super::ApiClient; // Import from parent module use crate::{ error::{check_status, IntelApiError}, @@ -11,8 +13,6 @@ use crate::{ use reqwest::StatusCode; impl ApiClient { - // --- FMSPCs & TCB Evaluation Data Numbers --- - /// GET /sgx/certification/{v3,v4}/fmspcs /// Retrieves a list of FMSPC values for SGX and TDX platforms (API v4 only). /// diff --git a/crates/intel-dcap-api/src/client/helpers.rs b/crates/intel-dcap-api/src/client/helpers.rs index 967df76..8ebc887 100644 --- a/crates/intel-dcap-api/src/client/helpers.rs +++ b/crates/intel-dcap-api/src/client/helpers.rs @@ -1,6 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright (c) 2025 Matter Labs +//! Internal helper methods + use super::ApiClient; // Import from parent module use crate::{ error::{check_status, extract_api_error_details, IntelApiError}, @@ -12,10 +14,6 @@ use reqwest::{RequestBuilder, Response, StatusCode}; use std::io; impl ApiClient { - // ------------------------ - // Internal helper methods - // ------------------------ - /// Helper to construct API paths dynamically based on version and technology (SGX/TDX). pub(super) fn build_api_path( &self, diff --git a/crates/intel-dcap-api/src/client/mod.rs b/crates/intel-dcap-api/src/client/mod.rs index d26a55d..d2d618d 100644 --- a/crates/intel-dcap-api/src/client/mod.rs +++ b/crates/intel-dcap-api/src/client/mod.rs @@ -9,10 +9,7 @@ mod pck_crl; mod registration; mod tcb_info; -use crate::{ - error::IntelApiError, - types::ApiVersion, // Import ApiVersion -}; +use crate::{error::IntelApiError, types::ApiVersion}; use reqwest::Client; use url::Url; @@ -63,7 +60,8 @@ impl ApiClient { /// This function may fail if the provided TLS version or base URL /// cannot be used to build a `reqwest` client. pub fn new() -> Result { - Self::new_with_options(BASE_URL, ApiVersion::V4) // Default to V4 + // Default to V4 + Self::new_with_options(BASE_URL, ApiVersion::V4) } /// Creates a new client targeting a specific API version. @@ -91,7 +89,8 @@ impl ApiClient { /// Returns an `IntelApiError` if the `reqwest` client cannot be built /// or if the provided base URL is invalid. pub fn new_with_base_url(base_url: impl reqwest::IntoUrl) -> Result { - Self::new_with_options(base_url, ApiVersion::V4) // Default to V4 + // Default to V4 + Self::new_with_options(base_url, ApiVersion::V4) } /// Creates a new client with a custom base URL and specific API version. @@ -114,7 +113,7 @@ impl ApiClient { .min_tls_version(reqwest::tls::Version::TLS_1_2) .build()?, base_url: base_url.into_url()?, - api_version, // Store the version + api_version, }) } } diff --git a/crates/intel-dcap-api/src/client/pck_cert.rs b/crates/intel-dcap-api/src/client/pck_cert.rs index 7580abd..fdc4842 100644 --- a/crates/intel-dcap-api/src/client/pck_cert.rs +++ b/crates/intel-dcap-api/src/client/pck_cert.rs @@ -1,6 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright (c) 2025 Matter Labs +//! Provisioning Certification Service + use super::ApiClient; // Import from parent module use crate::{ error::IntelApiError, @@ -11,8 +13,6 @@ use crate::{ use reqwest::header; impl ApiClient { - // === Provisioning Certification Service === - /// GET /sgx/certification/{v3,v4}/pckcert /// Retrieves a single SGX PCK certificate using encrypted PPID and SVNs. /// diff --git a/crates/intel-dcap-api/src/client/pck_crl.rs b/crates/intel-dcap-api/src/client/pck_crl.rs index 49ead3f..0226b11 100644 --- a/crates/intel-dcap-api/src/client/pck_crl.rs +++ b/crates/intel-dcap-api/src/client/pck_crl.rs @@ -1,6 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright (c) 2025 Matter Labs +//! PCK Certificate Revocation List + use super::ApiClient; // Import from parent module use crate::{ error::{check_status, IntelApiError}, @@ -52,8 +54,8 @@ impl ApiClient { let issuer_chain = self.get_required_header( &response, - "SGX-PCK-CRL-Issuer-Chain", // v4 name - Some("SGX-PCK-CRL-Issuer-Chain"), // v3 name + "SGX-PCK-CRL-Issuer-Chain", + Some("SGX-PCK-CRL-Issuer-Chain"), )?; // Response body is PEM or DER CRL diff --git a/crates/intel-dcap-api/src/client/registration.rs b/crates/intel-dcap-api/src/client/registration.rs index d4bd2cc..136c8c0 100644 --- a/crates/intel-dcap-api/src/client/registration.rs +++ b/crates/intel-dcap-api/src/client/registration.rs @@ -1,6 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright (c) 2025 Matter Labs +//! Registration + use super::ApiClient; // Import from parent module use crate::{ error::{check_status, IntelApiError}, diff --git a/crates/intel-dcap-api/src/client/tcb_info.rs b/crates/intel-dcap-api/src/client/tcb_info.rs index 94dc94f..9c001ca 100644 --- a/crates/intel-dcap-api/src/client/tcb_info.rs +++ b/crates/intel-dcap-api/src/client/tcb_info.rs @@ -1,6 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright (c) 2025 Matter Labs +//! TCB Info + use super::ApiClient; // Import from parent module use crate::{ error::IntelApiError, @@ -9,8 +11,6 @@ use crate::{ }; impl ApiClient { - // --- TCB Info --- - /// GET /sgx/certification/{v3,v4}/tcb /// Retrieves SGX TCB information for a given FMSPC. /// @@ -91,8 +91,8 @@ impl ApiClient { let (tcb_info_json, issuer_chain) = self .fetch_json_with_issuer_chain( request_builder, - "TCB-Info-Issuer-Chain", // v4 name - Some("SGX-TCB-Info-Issuer-Chain"), // v3 name + "TCB-Info-Issuer-Chain", + Some("SGX-TCB-Info-Issuer-Chain"), ) .await?;