From 33998eb12e7b13a963519fcb202413a5643abdf9 Mon Sep 17 00:00:00 2001 From: Nick Santana Date: Fri, 8 Sep 2023 07:36:04 -0700 Subject: [PATCH] Derive `Serialize`, and `Deserialize` for the `TcbError` Any error that is meant out be propagated out of an enclave needs to be able to be serialized and deserialized from the trusted side into the untrusted side. `Clone` was also added as the changes needed for `Serialize` and `Deserialize` made it possible for the error to be cloneable. --- dcap/types/src/tcb.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dcap/types/src/tcb.rs b/dcap/types/src/tcb.rs index 3df29ac5..23c89b58 100644 --- a/dcap/types/src/tcb.rs +++ b/dcap/types/src/tcb.rs @@ -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}; @@ -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` @@ -66,7 +67,7 @@ pub enum Error { impl From for Error { fn from(err: x509_cert::der::Error) -> Self { - Error::Der(err) + Error::Der(err.to_string()) } }