fn parse_certdata(
    qe_id: quote::QeId,
    quote: &[u8],
) -> Result<quote::Qe3CertDataPpid<'static>, Quote3Error> {
    let quote = quote::Quote::parse(quote).map_err(|e| {
        error!("PPID query: failed to parse quote: {}", e);
        Quote3Error::NoPlatformCertData
    })?;

    let quote::QuoteHeader::V3 {
        qe3_vendor_id,
        user_data,
        ..
    } = quote.header();

    if **qe3_vendor_id != quote::QE3_VENDOR_ID_INTEL {
        error!("PPID query: QE vendor ID is not Intel");
        return Err(Quote3Error::NoPlatformCertData);
    }

    let mut qe_id = qe_id.into_owned();
    qe_id.resize(20usize, 0u8);
    if *qe_id != **user_data {
        error!("PPID query: QE ID mismatch");
        return Err(Quote3Error::NoPlatformCertData);
    }

    let sig = quote
        .signature::<quote::Quote3SignatureEcdsaP256>()
        .map_err(|e| {
            error!("PPID query: {}", e);
            Quote3Error::NoPlatformCertData
        })?;

    let cd = sig
        .certification_data::<quote::Qe3CertDataPpid>()
        .map_err(|e| {
            error!("PPID query: {}", e);
            Quote3Error::NoPlatformCertData
        })?;

    // PpidEncryptedRsa2048 / PpidCleartext not supported
    if sig.certification_data_type() != quote::CertificationDataType::PpidEncryptedRsa3072 {
        error!(
            "PPID query: Invalid certification data type: {:?}",
            sig.certification_data_type()
        );
        return Err(Quote3Error::NoPlatformCertData);
    }

    Ok(cd.clone_owned())
}
/// Check if a quote matches the QE ID and parse the QE certification data from
/// the quote.
Check if a quote matches the QE ID and parse the QE certification data from
the quote.
Check if a quote matches the QE ID and parse the QE certification data from the quote .
fn parse_certdata(
    qe_id: quote::QeId,
    quote: &[u8],
) -> Result<quote::Qe3CertDataPpid<'static>, Quote3Error> {
    let quote = quote::Quote::parse(quote).map_err(|e| {
        error!("PPID query: failed to parse quote: {}", e);
        Quote3Error::NoPlatformCertData
    })?;
    let quote::QuoteHeader::V3 {
        qe3_vendor_id,
        user_data,
        ..
    } = quote.header();
    if **qe3_vendor_id != quote::QE3_VENDOR_ID_INTEL {
        error!("PPID query: QE vendor ID is not Intel");
        return Err(Quote3Error::NoPlatformCertData);
    }
    let mut qe_id = qe_id.into_owned();
    qe_id.resize(20usize, 0u8);
    if *qe_id != **user_data {
        error!("PPID query: QE ID mismatch");
        return Err(Quote3Error::NoPlatformCertData);
    }
    let sig = quote
        .signature::<quote::Quote3SignatureEcdsaP256>()
        .map_err(|e| {
            error!("PPID query: {}", e);
            Quote3Error::NoPlatformCertData
        })?;
    let cd = sig
        .certification_data::<quote::Qe3CertDataPpid>()
        .map_err(|e| {
            error!("PPID query: {}", e);
            Quote3Error::NoPlatformCertData
        })?;
    // PpidEncryptedRsa2048 / PpidCleartext not supported
    if sig.certification_data_type() != quote::CertificationDataType::PpidEncryptedRsa3072 {
        error!(
            "PPID query: Invalid certification data type: {:?}",
            sig.certification_data_type()
        );
        return Err(Quote3Error::NoPlatformCertData);
    }
    Ok(cd.clone_owned())
}
fn parse_certdata ( qe_id : quote :: QeId , quote : & [ u8 ] , ) -> Result < quote :: Qe3CertDataPpid < ' static > , Quote3Error > { let quote = quote :: Quote :: parse ( quote ) . map_err ( | e | { error ! ( " " e ) ; Quote3Error :: NoPlatformCertData } ) ? ; let quote :: QuoteHeader :: V3 { qe3_vendor_id , user_data , .. } = quote . header ( ) ; if * * qe3_vendor_id != quote :: QE3_VENDOR_ID_INTEL { error ! ( " " ) ; return Err ( Quote3Error :: NoPlatformCertData ) ; } let mut qe_id = qe_id . into_owned ( ) ; qe_id . resize ( 20usize , 0u8 ) ; if * qe_id != * * user_data { error ! ( " " ) ; return Err ( Quote3Error :: NoPlatformCertData ) ; } let sig = quote . signature :: < quote :: Quote3SignatureEcdsaP256 > ( ) . map_err ( | e | { error ! ( " " e ) ; Quote3Error :: NoPlatformCertData } ) ? ; let cd = sig . certification_data :: < quote :: Qe3CertDataPpid > ( ) . map_err ( | e | { error ! ( " " e ) ; Quote3Error :: NoPlatformCertData } ) ? ; // PpidEncryptedRsa2048 / PpidCleartext not supported if sig . certification_data_type ( ) != quote :: CertificationDataType :: PpidEncryptedRsa3072 { error ! ( " " sig certification_data_type ( ) ) ; return Err ( Quote3Error :: NoPlatformCertData ) ; } Ok ( cd . clone_owned ( ) ) }
Check if a quote matches the QE ID and parse the QE certification data from
the quote.
Check if a quote matches the QE ID and parse the QE certification data from the quote .
qe_id
quote::QeId
quote
&[u8]
qe_id
quote::QeId
quote
&[u8]