mirror of
https://github.com/matter-labs/teepot.git
synced 2025-07-21 15:13:56 +02:00
feat: compat code for non x86_64-linux
- do not build packages, which require `x86_64-linux` - use Phala `dcap-qvl` crate for remote attestation, if possible - nix: exclude `nixsgx` on non `x86_64-linux` platforms Signed-off-by: Harald Hoyer <harald@matterlabs.dev>
This commit is contained in:
parent
ed808efd03
commit
eb39705ff1
41 changed files with 1531 additions and 519 deletions
|
@ -6,53 +6,64 @@
|
|||
#![deny(missing_docs)]
|
||||
#![deny(clippy::all)]
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use clap::Parser;
|
||||
use teepot::{
|
||||
log::{setup_logging, LogLevelParser},
|
||||
tdx::rtmr::TdxRtmrEvent,
|
||||
util::pad,
|
||||
};
|
||||
use tracing::{error, level_filters::LevelFilter};
|
||||
use tracing::error;
|
||||
|
||||
/// Extend a TDX rtmr with a hash digest for measured boot.
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
struct Arguments {
|
||||
/// digest in hex to extend the rtmr with
|
||||
#[arg(long)]
|
||||
digest: String,
|
||||
/// the number or the rtmr
|
||||
#[arg(long, default_value = "2")]
|
||||
rtmr: u64,
|
||||
/// Log level for the log output.
|
||||
/// Valid values are: `off`, `error`, `warn`, `info`, `debug`, `trace`
|
||||
#[clap(long, default_value_t = LevelFilter::WARN, value_parser = LogLevelParser)]
|
||||
pub log_level: LevelFilter,
|
||||
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
|
||||
mod os {
|
||||
use anyhow::{Context as _, Result};
|
||||
use clap::Parser;
|
||||
use teepot::{
|
||||
log::{setup_logging, LogLevelParser},
|
||||
tdx::rtmr::TdxRtmrEvent,
|
||||
util::pad,
|
||||
};
|
||||
use tracing::level_filters::LevelFilter;
|
||||
|
||||
/// Extend a TDX rtmr with a hash digest for measured boot.
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
struct Arguments {
|
||||
/// digest in hex to extend the rtmr with
|
||||
#[arg(long)]
|
||||
digest: String,
|
||||
/// the number or the rtmr
|
||||
#[arg(long, default_value = "2")]
|
||||
rtmr: u64,
|
||||
/// Log level for the log output.
|
||||
/// Valid values are: `off`, `error`, `warn`, `info`, `debug`, `trace`
|
||||
#[clap(long, default_value_t = LevelFilter::WARN, value_parser = LogLevelParser)]
|
||||
pub log_level: LevelFilter,
|
||||
}
|
||||
|
||||
pub fn main_with_error() -> Result<()> {
|
||||
let args = Arguments::parse();
|
||||
tracing::subscriber::set_global_default(setup_logging(
|
||||
env!("CARGO_CRATE_NAME"),
|
||||
&args.log_level,
|
||||
)?)?;
|
||||
|
||||
// Parse the digest string as a hex array
|
||||
let digest_bytes = hex::decode(&args.digest).context("Invalid digest format")?;
|
||||
let extend_data: [u8; 48] = pad(&digest_bytes).context("Invalid digest length")?;
|
||||
|
||||
// Extend the TDX measurement with the extend data
|
||||
TdxRtmrEvent::default()
|
||||
.with_extend_data(extend_data)
|
||||
.with_rtmr_index(args.rtmr)
|
||||
.extend()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn main_with_error() -> Result<()> {
|
||||
let args = Arguments::parse();
|
||||
tracing::subscriber::set_global_default(setup_logging(
|
||||
env!("CARGO_CRATE_NAME"),
|
||||
&args.log_level,
|
||||
)?)?;
|
||||
|
||||
// Parse the digest string as a hex array
|
||||
let digest_bytes = hex::decode(&args.digest).context("Invalid digest format")?;
|
||||
let extend_data: [u8; 48] = pad(&digest_bytes).context("Invalid digest length")?;
|
||||
|
||||
// Extend the TDX measurement with the extend data
|
||||
TdxRtmrEvent::default()
|
||||
.with_extend_data(extend_data)
|
||||
.with_rtmr_index(args.rtmr)
|
||||
.extend()?;
|
||||
|
||||
Ok(())
|
||||
#[cfg(not(all(target_os = "linux", target_arch = "x86_64")))]
|
||||
mod os {
|
||||
pub fn main_with_error() -> anyhow::Result<()> {
|
||||
anyhow::bail!("OS or architecture not supported");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let ret = main_with_error();
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let ret = os::main_with_error();
|
||||
if let Err(e) = &ret {
|
||||
error!(error = %e, "Execution failed");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue