mirror of
https://github.com/matter-labs/teepot.git
synced 2025-07-21 23:23:57 +02:00
fixup! refactor(intel-dcap-api): split client.rs into smaller files
Signed-off-by: Harald Hoyer <harald@matterlabs.dev>
This commit is contained in:
parent
4501b3421c
commit
1a392e800a
8 changed files with 24 additions and 23 deletions
|
@ -1,6 +1,8 @@
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
// Copyright (c) 2025 Matter Labs
|
// Copyright (c) 2025 Matter Labs
|
||||||
|
|
||||||
|
//! Enclave Identity
|
||||||
|
|
||||||
use super::ApiClient; // Import from parent module
|
use super::ApiClient; // Import from parent module
|
||||||
use crate::{
|
use crate::{
|
||||||
error::IntelApiError,
|
error::IntelApiError,
|
||||||
|
@ -9,8 +11,6 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
impl ApiClient {
|
impl ApiClient {
|
||||||
// --- Enclave Identity ---
|
|
||||||
|
|
||||||
/// Retrieves the SGX QE Identity from the Intel API.
|
/// Retrieves the SGX QE Identity from the Intel API.
|
||||||
///
|
///
|
||||||
/// Returns Enclave Identity JSON string (Appendix B) and Issuer Chain header.
|
/// Returns Enclave Identity JSON string (Appendix B) and Issuer Chain header.
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
// Copyright (c) 2025 Matter Labs
|
// Copyright (c) 2025 Matter Labs
|
||||||
|
|
||||||
|
//! FMSPCs & TCB Evaluation Data Numbers
|
||||||
|
|
||||||
use super::ApiClient; // Import from parent module
|
use super::ApiClient; // Import from parent module
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{check_status, IntelApiError},
|
error::{check_status, IntelApiError},
|
||||||
|
@ -11,8 +13,6 @@ use crate::{
|
||||||
use reqwest::StatusCode;
|
use reqwest::StatusCode;
|
||||||
|
|
||||||
impl ApiClient {
|
impl ApiClient {
|
||||||
// --- FMSPCs & TCB Evaluation Data Numbers ---
|
|
||||||
|
|
||||||
/// GET /sgx/certification/{v3,v4}/fmspcs
|
/// GET /sgx/certification/{v3,v4}/fmspcs
|
||||||
/// Retrieves a list of FMSPC values for SGX and TDX platforms (API v4 only).
|
/// Retrieves a list of FMSPC values for SGX and TDX platforms (API v4 only).
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
// Copyright (c) 2025 Matter Labs
|
// Copyright (c) 2025 Matter Labs
|
||||||
|
|
||||||
|
//! Internal helper methods
|
||||||
|
|
||||||
use super::ApiClient; // Import from parent module
|
use super::ApiClient; // Import from parent module
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{check_status, extract_api_error_details, IntelApiError},
|
error::{check_status, extract_api_error_details, IntelApiError},
|
||||||
|
@ -12,10 +14,6 @@ use reqwest::{RequestBuilder, Response, StatusCode};
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
impl ApiClient {
|
impl ApiClient {
|
||||||
// ------------------------
|
|
||||||
// Internal helper methods
|
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
/// Helper to construct API paths dynamically based on version and technology (SGX/TDX).
|
/// Helper to construct API paths dynamically based on version and technology (SGX/TDX).
|
||||||
pub(super) fn build_api_path(
|
pub(super) fn build_api_path(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
@ -9,10 +9,7 @@ mod pck_crl;
|
||||||
mod registration;
|
mod registration;
|
||||||
mod tcb_info;
|
mod tcb_info;
|
||||||
|
|
||||||
use crate::{
|
use crate::{error::IntelApiError, types::ApiVersion};
|
||||||
error::IntelApiError,
|
|
||||||
types::ApiVersion, // Import ApiVersion
|
|
||||||
};
|
|
||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -63,7 +60,8 @@ impl ApiClient {
|
||||||
/// This function may fail if the provided TLS version or base URL
|
/// This function may fail if the provided TLS version or base URL
|
||||||
/// cannot be used to build a `reqwest` client.
|
/// cannot be used to build a `reqwest` client.
|
||||||
pub fn new() -> Result<Self, IntelApiError> {
|
pub fn new() -> Result<Self, IntelApiError> {
|
||||||
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.
|
/// 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
|
/// Returns an `IntelApiError` if the `reqwest` client cannot be built
|
||||||
/// or if the provided base URL is invalid.
|
/// or if the provided base URL is invalid.
|
||||||
pub fn new_with_base_url(base_url: impl reqwest::IntoUrl) -> Result<Self, IntelApiError> {
|
pub fn new_with_base_url(base_url: impl reqwest::IntoUrl) -> Result<Self, IntelApiError> {
|
||||||
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.
|
/// 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)
|
.min_tls_version(reqwest::tls::Version::TLS_1_2)
|
||||||
.build()?,
|
.build()?,
|
||||||
base_url: base_url.into_url()?,
|
base_url: base_url.into_url()?,
|
||||||
api_version, // Store the version
|
api_version,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
// Copyright (c) 2025 Matter Labs
|
// Copyright (c) 2025 Matter Labs
|
||||||
|
|
||||||
|
//! Provisioning Certification Service
|
||||||
|
|
||||||
use super::ApiClient; // Import from parent module
|
use super::ApiClient; // Import from parent module
|
||||||
use crate::{
|
use crate::{
|
||||||
error::IntelApiError,
|
error::IntelApiError,
|
||||||
|
@ -11,8 +13,6 @@ use crate::{
|
||||||
use reqwest::header;
|
use reqwest::header;
|
||||||
|
|
||||||
impl ApiClient {
|
impl ApiClient {
|
||||||
// === Provisioning Certification Service ===
|
|
||||||
|
|
||||||
/// GET /sgx/certification/{v3,v4}/pckcert
|
/// GET /sgx/certification/{v3,v4}/pckcert
|
||||||
/// Retrieves a single SGX PCK certificate using encrypted PPID and SVNs.
|
/// Retrieves a single SGX PCK certificate using encrypted PPID and SVNs.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
// Copyright (c) 2025 Matter Labs
|
// Copyright (c) 2025 Matter Labs
|
||||||
|
|
||||||
|
//! PCK Certificate Revocation List
|
||||||
|
|
||||||
use super::ApiClient; // Import from parent module
|
use super::ApiClient; // Import from parent module
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{check_status, IntelApiError},
|
error::{check_status, IntelApiError},
|
||||||
|
@ -52,8 +54,8 @@ impl ApiClient {
|
||||||
|
|
||||||
let issuer_chain = self.get_required_header(
|
let issuer_chain = self.get_required_header(
|
||||||
&response,
|
&response,
|
||||||
"SGX-PCK-CRL-Issuer-Chain", // v4 name
|
"SGX-PCK-CRL-Issuer-Chain",
|
||||||
Some("SGX-PCK-CRL-Issuer-Chain"), // v3 name
|
Some("SGX-PCK-CRL-Issuer-Chain"),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Response body is PEM or DER CRL
|
// Response body is PEM or DER CRL
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
// Copyright (c) 2025 Matter Labs
|
// Copyright (c) 2025 Matter Labs
|
||||||
|
|
||||||
|
//! Registration
|
||||||
|
|
||||||
use super::ApiClient; // Import from parent module
|
use super::ApiClient; // Import from parent module
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{check_status, IntelApiError},
|
error::{check_status, IntelApiError},
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
// Copyright (c) 2025 Matter Labs
|
// Copyright (c) 2025 Matter Labs
|
||||||
|
|
||||||
|
//! TCB Info
|
||||||
|
|
||||||
use super::ApiClient; // Import from parent module
|
use super::ApiClient; // Import from parent module
|
||||||
use crate::{
|
use crate::{
|
||||||
error::IntelApiError,
|
error::IntelApiError,
|
||||||
|
@ -9,8 +11,6 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
impl ApiClient {
|
impl ApiClient {
|
||||||
// --- TCB Info ---
|
|
||||||
|
|
||||||
/// GET /sgx/certification/{v3,v4}/tcb
|
/// GET /sgx/certification/{v3,v4}/tcb
|
||||||
/// Retrieves SGX TCB information for a given FMSPC.
|
/// Retrieves SGX TCB information for a given FMSPC.
|
||||||
///
|
///
|
||||||
|
@ -91,8 +91,8 @@ impl ApiClient {
|
||||||
let (tcb_info_json, issuer_chain) = self
|
let (tcb_info_json, issuer_chain) = self
|
||||||
.fetch_json_with_issuer_chain(
|
.fetch_json_with_issuer_chain(
|
||||||
request_builder,
|
request_builder,
|
||||||
"TCB-Info-Issuer-Chain", // v4 name
|
"TCB-Info-Issuer-Chain",
|
||||||
Some("SGX-TCB-Info-Issuer-Chain"), // v3 name
|
Some("SGX-TCB-Info-Issuer-Chain"),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue