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

Update the rust toolchain to 1.83 #367

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
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
18 changes: 13 additions & 5 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ run_verification_tests dpe_profile_p384_sha384 rustcrypto

# Build fuzz target
( cd dpe/fuzz
rustup toolchain install nightly-2023-11-16
cargo +nightly-2023-11-16 install cargo-fuzz cargo-afl --locked
rustup toolchain install nightly-2024-12-20
cargo +nightly-2024-12-20 install cargo-fuzz cargo-afl --locked
cargo fmt --check
cargo clippy --features libfuzzer-sys
cargo clippy --features afl
cargo +nightly-2023-11-16 fuzz build --features libfuzzer-sys
cargo +nightly-2023-11-16 afl build --features afl
cargo +nightly-2024-12-20 fuzz build --features libfuzzer-sys
cargo +nightly-2024-12-20 afl build --features afl
)

# Fix license headers
Expand Down
5 changes: 4 additions & 1 deletion crypto/src/openssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ type OpensslPrivKey = CryptoBuf;

impl Crypto for OpensslCrypto {
type Cdi = OpensslCdi;
type Hasher<'c> = OpensslHasher where Self: 'c;
type Hasher<'c>
= OpensslHasher
where
Self: 'c;
type PrivKey = OpensslPrivKey;

#[cfg(feature = "deterministic_rand")]
Expand Down
5 changes: 4 additions & 1 deletion crypto/src/rustcrypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ impl RustCryptoImpl {

impl Crypto for RustCryptoImpl {
type Cdi = Vec<u8>;
type Hasher<'c> = RustCryptoHasher where Self: 'c;
type Hasher<'c>
= RustCryptoHasher
where
Self: 'c;
type PrivKey = CryptoBuf;

fn hash_initialize(&mut self, algs: AlgLen) -> Result<Self::Hasher<'_>, CryptoError> {
Expand Down
8 changes: 4 additions & 4 deletions dpe/src/commands/certify_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ mod tests {
let econtent = &econtent_info.econtent.as_mut().unwrap().to_der().unwrap()[4..];

// validate csr signature with the alias key
let csr_digest = env.crypto.hash(DPE_PROFILE.alg_len(), &econtent).unwrap();
let csr_digest = env.crypto.hash(DPE_PROFILE.alg_len(), econtent).unwrap();
let priv_key = match DPE_PROFILE.alg_len() {
AlgLen::Bit256 => EcKey::private_key_from_der(include_bytes!(
"../../../platform/src/test_data/key_256.der"
Expand All @@ -652,7 +652,7 @@ mod tests {
assert!(csr_sig.verify(csr_digest.bytes(), &alias_key).unwrap());

// validate csr
let (_, csr) = X509CertificationRequest::from_der(&econtent).unwrap();
let (_, csr) = X509CertificationRequest::from_der(econtent).unwrap();
let cri = csr.certification_request_info;
assert_eq!(cri.version.0, 0);
assert_eq!(
Expand All @@ -673,7 +673,7 @@ mod tests {
let y = BigNum::from_slice(&pub_key_der[DPE_PROFILE.get_ecc_int_size() + 1..]).unwrap();
let pub_key = EcKey::from_public_key_affine_coordinates(group, &x, &y).unwrap();

let cri_digest = env.crypto.hash(DPE_PROFILE.alg_len(), &cri.raw).unwrap();
let cri_digest = env.crypto.hash(DPE_PROFILE.alg_len(), cri.raw).unwrap();
assert!(cri_sig.verify(cri_digest.bytes(), &pub_key).unwrap());

// validate subject_name
Expand All @@ -693,7 +693,7 @@ mod tests {
let expected_subject_name = format!(
"CN={}, serialNumber={}",
str::from_utf8(subject_name.cn.bytes()).unwrap(),
str::from_utf8(&subject_name.serial.bytes()).unwrap()
str::from_utf8(subject_name.serial.bytes()).unwrap()
);
let actual_subject_name = cri.subject.to_string_with_registry(oid_registry()).unwrap();
assert_eq!(expected_subject_name, actual_subject_name);
Expand Down
8 changes: 4 additions & 4 deletions dpe/src/commands/derive_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ mod tests {
{
Ok(Response::RotateCtx(resp)) => resp.handle,
Ok(_) => panic!("Invalid response type"),
Err(e) => Err(e).unwrap(),
Err(e) => panic!("{:?}", e),
};

let parent_handle = match (DeriveContextCmd {
Expand All @@ -666,7 +666,7 @@ mod tests {
{
Ok(Response::DeriveContext(resp)) => resp.parent_handle,
Ok(_) => panic!("Invalid response type"),
Err(e) => Err(e).unwrap(),
Err(e) => panic!("{:?}", e),
};

let (new_context_handle, sig) = match (SignCmd {
Expand All @@ -686,7 +686,7 @@ mod tests {
.unwrap(),
),
Ok(_) => panic!("Invalid response type"),
Err(e) => Err(e).unwrap(),
Err(e) => panic!("{:?}", e),
};

let parent_handle = match (DeriveContextCmd {
Expand All @@ -701,7 +701,7 @@ mod tests {
{
Ok(Response::DeriveContext(resp)) => resp.parent_handle,
Ok(_) => panic!("Invalid response type"),
Err(e) => Err(e).unwrap(),
Err(e) => panic!("{:?}", e),
};

let ec_pub_key = {
Expand Down
14 changes: 7 additions & 7 deletions dpe/src/commands/destroy_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ mod tests {
{
Ok(Response::DeriveContext(resp)) => resp.handle,
Ok(_) => panic!("Invalid response type"),
Err(e) => Err(e).unwrap(),
Err(e) => panic!("{:?}", e),
};

// retire context with handle 1 and create new context
Expand All @@ -317,7 +317,7 @@ mod tests {
{
Ok(Response::DeriveContext(resp)) => resp.handle,
Ok(_) => panic!("Invalid response type"),
Err(e) => Err(e).unwrap(),
Err(e) => panic!("{:?}", e),
};

// retire context with handle 2 and create new context
Expand All @@ -332,7 +332,7 @@ mod tests {
{
Ok(Response::DeriveContext(resp)) => resp.handle,
Ok(_) => panic!("Invalid response type"),
Err(e) => Err(e).unwrap(),
Err(e) => panic!("{:?}", e),
};

DestroyCtxCmd { handle: handle_3 }
Expand Down Expand Up @@ -371,7 +371,7 @@ mod tests {
{
Ok(Response::DeriveContext(resp)) => resp.handle,
Ok(_) => panic!("Invalid response type"),
Err(e) => Err(e).unwrap(),
Err(e) => panic!("{:?}", e),
};

// derive one child from the parent
Expand All @@ -386,7 +386,7 @@ mod tests {
{
Ok(Response::DeriveContext(resp)) => resp.parent_handle,
Ok(_) => panic!("Invalid response type"),
Err(e) => Err(e).unwrap(),
Err(e) => panic!("{:?}", e),
};

// derive another child while retiring the parent handle
Expand All @@ -401,7 +401,7 @@ mod tests {
{
Ok(Response::DeriveContext(resp)) => resp.handle,
Ok(_) => panic!("Invalid response type"),
Err(e) => Err(e).unwrap(),
Err(e) => panic!("{:?}", e),
};

DestroyCtxCmd { handle: handle_b }
Expand All @@ -424,7 +424,7 @@ mod tests {
parent_idx: u8,
handle: &ContextHandle,
children: &[u8],
) -> () {
) {
dpe.contexts[idx].state = ContextState::Active;
dpe.contexts[idx].handle = *handle;
dpe.contexts[idx].parent_idx = parent_idx;
Expand Down
4 changes: 2 additions & 2 deletions dpe/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ impl Command<'_> {
}

fn parse_command<'a, T: FromBytes + KnownLayout + Immutable + 'a>(
build: impl FnOnce(&'a T) -> Command,
build: impl FnOnce(&'a T) -> Command<'a>,
bytes: &'a [u8],
) -> Result<Command, DpeErrorCode> {
) -> Result<Command<'a>, DpeErrorCode> {
let (prefix, _remaining_bytes) =
T::ref_from_prefix(bytes).map_err(|_| DpeErrorCode::InvalidArgument)?;
Ok(build(prefix))
Expand Down
6 changes: 6 additions & 0 deletions dpe/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ pub struct Context {
pub reserved: [u8; 1],
}

impl Default for Context {
fn default() -> Self {
Self::new()
}
}

impl Context {
pub const ROOT_INDEX: u8 = 0xff;

Expand Down
10 changes: 5 additions & 5 deletions dpe/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub struct DpeValidator<'a> {
pub dpe: &'a mut DpeInstance,
}

impl<'a> DpeValidator<'a> {
impl DpeValidator<'_> {
/// Validates that the shape of the DPE instance is well-formed and that
/// there is no illegal state present within the DPE.
#[cfg_attr(not(feature = "no-cfi"), cfi_impl_fn)]
Expand Down Expand Up @@ -466,7 +466,7 @@ pub mod tests {
crypto: OpensslCrypto::new(),
platform: DefaultPlatform,
};
let mut dpe_validator = DpeValidator {
let dpe_validator = DpeValidator {
dpe: &mut DpeInstance::new(&mut env, SUPPORT).unwrap(),
};

Expand Down Expand Up @@ -529,7 +529,7 @@ pub mod tests {
crypto: OpensslCrypto::new(),
platform: DefaultPlatform,
};
let mut dpe_validator = DpeValidator {
let dpe_validator = DpeValidator {
dpe: &mut DpeInstance::new(&mut env, Support::empty()).unwrap(),
};

Expand Down Expand Up @@ -581,7 +581,7 @@ pub mod tests {
crypto: OpensslCrypto::new(),
platform: DefaultPlatform,
};
let mut dpe_validator = DpeValidator {
let dpe_validator = DpeValidator {
dpe: &mut DpeInstance::new(&mut env, Support::all().difference(Support::AUTO_INIT))
.unwrap(),
};
Expand Down Expand Up @@ -692,7 +692,7 @@ pub mod tests {
crypto: OpensslCrypto::new(),
platform: DefaultPlatform,
};
let mut dpe_validator = DpeValidator {
let dpe_validator = DpeValidator {
dpe: &mut DpeInstance::new(&mut env, Support::empty()).unwrap(),
};
dpe_validator.dpe.has_initialized = U8Bool::new(true);
Expand Down
16 changes: 8 additions & 8 deletions dpe/src/x509.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2343,7 +2343,7 @@ pub(crate) mod tests {
let expected = format!(
"CN={}, serialNumber={}",
str::from_utf8(test_name.cn.bytes()).unwrap(),
str::from_utf8(&test_name.serial.bytes()).unwrap()
str::from_utf8(test_name.serial.bytes()).unwrap()
);
let actual = name.to_string_with_registry(oid_registry()).unwrap();
assert_eq!(expected, actual);
Expand Down Expand Up @@ -2536,10 +2536,10 @@ pub(crate) mod tests {

const ECC_INT_SIZE: usize = DPE_PROFILE.get_ecc_int_size();

const DEFAULT_OTHER_NAME_OID: &'static [u8] = &[0, 0, 0];
const DEFAULT_OTHER_NAME_OID: &[u8] = &[0, 0, 0];
const DEFAULT_OTHER_NAME_VALUE: &str = "default-other-name";

fn build_test_tbs<'a>(is_ca: bool, cert_buf: &'a mut [u8]) -> (usize, TbsCertificate<'a>) {
fn build_test_tbs(is_ca: bool, cert_buf: &mut [u8]) -> (usize, TbsCertificate<'_>) {
let mut issuer_der = [0u8; 1024];
let mut issuer_writer = CertWriter::new(&mut issuer_der, true);
let issuer_len = issuer_writer.encode_rdn(&TEST_ISSUER_NAME).unwrap();
Expand Down Expand Up @@ -2595,7 +2595,7 @@ pub(crate) mod tests {
let mut tbs_writer = CertWriter::new(cert_buf, true);
let bytes_written = tbs_writer
.encode_ecdsa_tbs(
&TEST_SERIAL,
TEST_SERIAL,
&issuer_der[..issuer_len],
&TEST_SUBJECT_NAME,
&test_pub,
Expand All @@ -2611,7 +2611,7 @@ pub(crate) mod tests {
)
}

fn build_test_cert<'a>(is_ca: bool, cert_buf: &'a mut [u8]) -> (usize, X509Certificate<'a>) {
fn build_test_cert(is_ca: bool, cert_buf: &mut [u8]) -> (usize, X509Certificate<'_>) {
let mut tbs_buf = [0u8; 1024];
let (tbs_written, _) = build_test_tbs(is_ca, &mut tbs_buf);

Expand All @@ -2622,7 +2622,7 @@ pub(crate) mod tests {

let mut w = CertWriter::new(cert_buf, true);
let bytes_written = w
.encode_ecdsa_certificate(&mut tbs_buf[..tbs_written], &test_sig)
.encode_ecdsa_certificate(&tbs_buf[..tbs_written], &test_sig)
.unwrap();

let mut parser = X509CertificateParser::new().with_deep_parse_extensions(true);
Expand Down Expand Up @@ -2690,7 +2690,7 @@ pub(crate) mod tests {
assert!(!ext.critical);
let san = ext.value;
assert_eq!(san.general_names.len(), 1);
let general_name = san.general_names.get(0).unwrap();
let general_name = san.general_names.first().unwrap();
match general_name {
GeneralName::OtherName(oid, other_name_value) => {
assert_eq!(oid.as_bytes(), DEFAULT_OTHER_NAME_OID);
Expand All @@ -2701,7 +2701,7 @@ pub(crate) mod tests {
};
}
Ok(None) => panic!("No SubjectAltName extension found!"),
Err(e) => panic!("Error {} parsing SubjectAltName extension", e.to_string()),
Err(e) => panic!("Error {} parsing SubjectAltName extension", e),
}
}

Expand Down
2 changes: 1 addition & 1 deletion platform/src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct Printer<'a> {
pub platform: &'a mut dyn Platform,
}

impl<'a> uWrite for Printer<'a> {
impl uWrite for Printer<'_> {
type Error = PlatformError;

fn write_str(&mut self, str: &str) -> Result<(), Self::Error> {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Licensed under the Apache-2.0 license

[toolchain]
channel = "1.70"
channel = "1.83"
components = ["rustfmt", "clippy"]
Loading