mirror of
https://github.com/matter-labs/teepot.git
synced 2025-07-21 07:03:56 +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
|
||||
// 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.
|
||||
|
|
|
@ -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).
|
||||
///
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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, 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.
|
||||
|
@ -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, 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.
|
||||
|
@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
///
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue