Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e2faff1
Add basic framework for the EAT verifier
Dec 16, 2025
752c1b0
first version change
meilu-git Dec 18, 2025
49bb2db
Revert "first version change"
meilu-git Dec 18, 2025
ceceeb2
first version of decode
meilu-git Dec 18, 2025
3279339
add unit test
meilu-git Dec 19, 2025
dad9753
unit test
meilu-git Dec 19, 2025
95772d3
some code for debugging
meilu-git Dec 19, 2025
d48ce94
this is a working version
meilu-git Dec 19, 2025
201e8f8
intermi commit
meilu-git Dec 22, 2025
5253c88
take out tag and then use coset from main
meilu-git Dec 23, 2025
5d932f3
fix pipleline precheck error, add Clap cll to pass bin file ot decode.
meilu-git Dec 29, 2025
0bf0e92
add steps to run cli tool to decode the bins
meilu-git Dec 29, 2025
e47abaa
add step to call cli tool to validate bin files
meilu-git Dec 29, 2025
234a995
accidently checked cargo.toml that is workign in progress, roll back
meilu-git Dec 29, 2025
b915d7e
use Open SSL to parse pub key instead of 509 parser
meilu-git Dec 29, 2025
221d0e9
build the binary before running the cli
meilu-git Dec 30, 2025
6010d6e
update the working dir
meilu-git Dec 30, 2025
1ddeee2
one more try with working dir
meilu-git Dec 30, 2025
5979f07
code review feedback
meilu-git Dec 31, 2025
0484956
chamge the to add verify as a subcommand
meilu-git Jan 2, 2026
1630e41
code review feedback
meilu-git Jan 6, 2026
15f07bf
clean up
meilu-git Jan 6, 2026
94f16cd
code review feedback
meilu-git Jan 7, 2026
13944f7
update the cli due to foramt change
meilu-git Jan 7, 2026
668bbfd
fmt in yaml
meilu-git Jan 7, 2026
be1458f
code review feedback
meilu-git Jan 8, 2026
9cb5be1
code review feedback
meilu-git Jan 9, 2026
29d1200
Merge branch 'main' of https://github.com/chipsalliance/caliptra-mcu-…
Jan 14, 2026
f2c4774
address review comments
Jan 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/spdm-validator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ jobs:
exit 1
fi


- name: Verify EAT from measurement block for SPDM-MCTP
working-directory: ocp-eat-verifier
env:
SPDM_VALIDATOR_DIR: ${{ github.workspace }}/spdm-emu/build/bin
run: |
cargo build --release -p ocptoken
./target/release/ocptoken verify \
-e $SPDM_VALIDATOR_DIR/measurement_block_fd.bin


- name: Run SPDM validator tests on DOE transport
env:
SPDM_VALIDATOR_DIR: ${{ github.workspace }}/spdm-emu/build/bin
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/target*/
*target*/
**/target/
test_key

# By default, ignore Cargo.lock files in non-workspace directories.
Expand Down
19 changes: 19 additions & 0 deletions ocp-eat-verifier/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed under the Apache-2.0 license

[workspace]
members = [
"ocptoken-rs",
]
resolver = "2"

[workspace.package]
version = "0.1.0"
edition = "2021"
authors = ["Caliptra contributors"]

[workspace.dependencies]
coset = { git = "https://github.com/google/coset",rev = "3ebd2d7d0dafe2b6856934ea2b4fa28ea3d9a373"}
hex = "0.4"
thiserror = "2.0"
openssl = { version = "0.10", features = ["vendored"] }
clap = { version = "4", features = ["derive"] }
16 changes: 16 additions & 0 deletions ocp-eat-verifier/ocptoken-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Licensed under the Apache-2.0 license

[package]
name = "ocptoken"
version = "0.1.0"
edition = "2021"
authors = ["Caliptra Contributors"]

[dependencies]
coset.workspace = true
hex.workspace = true
thiserror.workspace = true
openssl.workspace = true
clap.workspace = true


34 changes: 34 additions & 0 deletions ocp-eat-verifier/ocptoken-rs/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Licensed under the Apache-2.0 license

use thiserror::Error;
/// Errors that can occur when working with OCP EAT tokens
#[derive(Error, Debug)]
pub enum OcpEatError {
/// COSE parsing or validation error
#[error("COSE error: {0:?}")]
CoseSign1(coset::CoseError),

#[error("Invalid token: {0}")]
InvalidToken(&'static str),

/// Certificate parsing error
#[error("Certificate error: {0}")]
Certificate(String),

/// Signature verification failure
#[error("Signature verification failed")]
SignatureVerification,

/// Crypto backend error
#[error("Crypto error: {0}")]
Crypto(String),
}

impl From<coset::CoseError> for OcpEatError {
fn from(err: coset::CoseError) -> Self {
OcpEatError::CoseSign1(err)
}
}

/// Result type for OCP EAT operations
pub type OcpEatResult<T> = std::result::Result<T, OcpEatError>;
4 changes: 4 additions & 0 deletions ocp-eat-verifier/ocptoken-rs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Licensed under the Apache-2.0 license

pub mod token;
pub mod error;
103 changes: 103 additions & 0 deletions ocp-eat-verifier/ocptoken-rs/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Licensed under the Apache-2.0 license

use clap::{Parser, Subcommand};
use std::fs;
use std::path::PathBuf;

use ocptoken::token::evidence::Evidence;

#[derive(Parser, Debug)]
#[command(
name = "ocptoken",
author,
version,
about = "Verify an OCP TOKEN COSE_Sign1 token",
long_about = None
)]
struct Cli {
#[command(subcommand)]
command: Commands,
}

#[derive(Subcommand, Debug)]
enum Commands {
/// Cryptographically verify the supplied OCP token using the EAT attestation key
Verify(VerifyArgs),
}

#[derive(Parser, Debug)]
#[command(
author,
version,
about = "Cryptographically verify the supplied OCP token using the EAT attestation key"
)]
struct VerifyArgs {
#[arg(
short = 'e',
long = "evidence",
value_name = "EVIDENCE",
default_value = "ocp_eat.cbor"
)]
evidence: PathBuf,
}

fn main() {
let cli = Cli::parse();

match cli.command {
Commands::Verify(args) => run_verify(&args),
}
}

fn run_verify(args: &VerifyArgs) {
// 1. Load the binary file
let encoded = match fs::read(&args.evidence) {
Ok(b) => b,
Err(e) => {
eprintln!(
"Failed to read evidence file '{}': {}",
args.evidence.display(),
e
);
std::process::exit(1);
}
};

println!(
"Loaded evidence file '{}' ({} bytes)",
args.evidence.display(),
encoded.len()
);

// 2. Decode the evidence
let ev = match Evidence::decode(&encoded) {
Ok(ev) => {
println!("Decode successful");
ev
}
Err(e) => {
eprintln!("Evidence::decode failed: {:?}", e);

// Optional debug dump
let prefix_len = encoded.len().min(32);
eprintln!(
"First {} bytes of input: {:02x?}",
prefix_len,
&encoded[..prefix_len]
);

std::process::exit(1);
}
};

// 3. Cryptographically verify
match ev.verify() {
Ok(()) => {
println!("Signature verification successful");
}
Err(e) => {
eprintln!("Evidence::verify failed: {:?}", e);
std::process::exit(1);
}
}
}
Loading