Skip to content

Commit

Permalink
bump der to latest version
Browse files Browse the repository at this point in the history
To remove the use of unmaintained crate `proc-macro-error`.

Signed-off-by: Jiaqi Gao <[email protected]>
  • Loading branch information
gaojiaqi7 authored and jyao1 committed Sep 7, 2024
1 parent 55fd6ed commit cd526a6
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 322 deletions.
48 changes: 12 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/attestation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
crypto = { path = "../crypto" }
der = { version = "0.5.1", features = ["oid", "alloc", "derive"] }
der = { version = "0.7.9", features = ["oid", "alloc", "derive"] }
policy = {path = "../policy"}
spin = "0.9.2"
tdx-tdcall = { path = "../../deps/td-shim/tdx-tdcall"}
Expand Down
18 changes: 9 additions & 9 deletions src/attestation/src/attest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ use crate::{
};
use alloc::{string::String, vec, vec::Vec};
use core::{alloc::Layout, ffi::c_void, ops::Range};
use crypto::x509;
use der::{asn1::ObjectIdentifier, Any, Decodable, Decoder};
use crypto::{
x509,
x509::{Decode, ObjectIdentifier, OctetStringRef, Reader},
};
use tdx_tdcall::tdreport::*;

const TD_QUOTE_SIZE: usize = 0x2000;
Expand Down Expand Up @@ -101,11 +103,11 @@ pub fn get_fmspc_from_quote(quote: &[u8]) -> Result<[u8; 6], Error> {
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct InnerValue<'a> {
pub id: ObjectIdentifier,
pub value: Option<Any<'a>>,
pub value: Option<OctetStringRef<'a>>,
}

impl<'a> Decodable<'a> for InnerValue<'a> {
fn decode(decoder: &mut Decoder<'a>) -> der::Result<Self> {
impl<'a> Decode<'a> for InnerValue<'a> {
fn decode<R: der::Reader<'a>>(decoder: &mut R) -> der::Result<Self> {
decoder.sequence(|decoder| {
let id = decoder.decode()?;
let value = decoder.decode()?;
Expand All @@ -117,8 +119,8 @@ impl<'a> Decodable<'a> for InnerValue<'a> {

fn parse_fmspc_from_pck_cert(pck_der: &[u8]) -> Result<[u8; 6], Error> {
const PCK_FMSPC_EXTENSION_OID: ObjectIdentifier =
ObjectIdentifier::new("1.2.840.113741.1.13.1");
const PCK_FMSPC_OID: ObjectIdentifier = ObjectIdentifier::new("1.2.840.113741.1.13.1.4");
ObjectIdentifier::new_unwrap("1.2.840.113741.1.13.1");
const PCK_FMSPC_OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.840.113741.1.13.1.4");

let x509 = x509::Certificate::from_der(pck_der).map_err(|_| Error::InvalidQuote)?;
let extensions = x509.tbs_certificate.extensions.ok_or(Error::InvalidQuote)?;
Expand All @@ -132,8 +134,6 @@ fn parse_fmspc_from_pck_cert(pck_der: &[u8]) -> Result<[u8; 6], Error> {
return val
.value
.ok_or(Error::InvalidQuote)?
.octet_string()
.map_err(|_| Error::InvalidQuote)?
.as_bytes()
.try_into()
.map_err(|_| Error::InvalidQuote);
Expand Down
3 changes: 1 addition & 2 deletions src/attestation/src/root_ca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
//
// SPDX-License-Identifier: BSD-2-Clause-Patent

use crypto::x509::Certificate;
use der::Decodable;
use crypto::x509::{Certificate, Decode};
use spin::Once;

use crate::Error;
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"

[dependencies]
cfg-if = "1.0"
der = {version = "0.5.1", features = ["oid", "alloc", "derive"]}
der = {version = "0.7.9", features = ["oid", "alloc", "derive"]}
pki-types = { package = "rustls-pki-types", version = "1" }
rust_std_stub = { path = "../std-support/rust-std-stub" }
rustls = { path = "../../deps/rustls/rustls", default-features = false, features = ["no_std"], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cargo-fuzz = true
libfuzzer-sys = { version = "0.4", optional = true }
afl = { version = "*", optional = true }
arbitrary = "=1.1.3"
der = { version = "0.5.1", features = ["oid", "alloc"] }
der = { version = "0.7.9", features = ["oid", "alloc"] }
serde = "=1.0.198"

[dependencies.crypto]
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/fuzz/fuzz_targets/fuzzlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: BSD-2-Clause-Patent

use crypto::x509;
use der::{Decodable, Error};
use der::{Decode, Error};

pub fn fuzz_x509(data: &[u8]) -> core::result::Result<x509::Certificate, Error> {
x509::Certificate::from_der(data)
Expand Down
Loading

0 comments on commit cd526a6

Please sign in to comment.