Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive Serialize and Deserialize for the TcbError #417

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions dcap/types/src/tcb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::{CertificationData, Quote3};
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use const_oid::ObjectIdentifier;
use serde::{Deserialize, Serialize};
use x509_cert::attr::{AttributeTypeAndValue, AttributeValue};
use x509_cert::der::asn1::OctetStringRef;
use x509_cert::der::{Decode, DecodePem};
Expand Down Expand Up @@ -52,12 +53,12 @@ const PCE_SVN_OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.840.1137
const FMSPC_OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.840.113741.1.13.1.4");

/// Error parsing TCB info from PCK leaf certificate
#[derive(Debug, PartialEq, displaydoc::Display)]
#[derive(Debug, PartialEq, displaydoc::Display, Clone, Serialize, Deserialize)]
pub enum Error {
/// Missing the SGX OID extension: {0}
MissingSgxExtension(String),
/// Failed to parse TCB info: {0}
Der(x509_cert::der::Error),
Der(String),
/// Expected an FMSPC size of 6 bytes, got {0}
FmspcSize(usize),
/// Unsupported quote certification data, should be `PckCertificateChain`
Expand All @@ -66,7 +67,7 @@ pub enum Error {

impl From<x509_cert::der::Error> for Error {
fn from(err: x509_cert::der::Error) -> Self {
Error::Der(err)
Error::Der(err.to_string())
}
}

Expand Down