From fdac0de34f202d6952ad1ae8e82658861655c4ce Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Fri, 27 Aug 2021 14:15:56 +0200 Subject: [PATCH] Add a CI job to run 'cargo test' with rustc/cargo from debian stable. Minor fixes so that the code compiles with rustc 1.48 --- .gitlab-ci.yml | 17 ++++++++++++++--- card-functionality/src/util.rs | 6 +++--- openpgp-card-sequoia/src/lib.rs | 4 ++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 20efadd..b314eed 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,6 @@ # SPDX-FileCopyrightText: 2021 Heiko Schaefer # SPDX-License-Identifier: CC0-1.0 -image: rust:latest - reuse: image: name: fsfe/reuse:latest @@ -12,15 +10,28 @@ reuse: cargo-test: stage: test + image: rust:latest + before_script: + - mkdir -p /run/user/$UID + - apt update -y -qq + - apt install -y -qq --no-install-recommends git clang make pkg-config nettle-dev libssl-dev capnproto ca-certificates libpcsclite-dev + - apt clean + script: + - cargo test + +cargo-test-debian-stable: + stage: test + image: debian:stable before_script: - mkdir -p /run/user/$UID - apt update -y -qq - apt install -y -qq --no-install-recommends git rustc cargo clang make pkg-config nettle-dev libssl-dev capnproto ca-certificates libpcsclite-dev - apt clean script: - - cargo test + - cargo test cargo-fmt: + image: rust:latest script: - rustup component add rustfmt - cargo fmt -- --check diff --git a/card-functionality/src/util.rs b/card-functionality/src/util.rs index e28c1a3..ab16c80 100644 --- a/card-functionality/src/util.rs +++ b/card-functionality/src/util.rs @@ -30,12 +30,12 @@ pub(crate) fn upload_subkeys( ) -> Result> { let mut out = vec![]; - for kt in [ + for kt in &[ KeyType::Signing, KeyType::Decryption, KeyType::Authentication, ] { - let vka = get_subkey(cert, kt)?; + let vka = get_subkey(cert, *kt)?; // store fingerprint as return-value let fp = vka.fingerprint().to_hex(); @@ -50,7 +50,7 @@ pub(crate) fn upload_subkeys( // upload key let cuk = vka_as_uploadable_key(vka, None); - let _ = ca.upload_key(cuk, kt)?; + ca.upload_key(cuk, *kt)?; } Ok(out) diff --git a/openpgp-card-sequoia/src/lib.rs b/openpgp-card-sequoia/src/lib.rs index 0221481..fd612f2 100644 --- a/openpgp-card-sequoia/src/lib.rs +++ b/openpgp-card-sequoia/src/lib.rs @@ -309,12 +309,12 @@ impl CardUploadableKey for SequoiaKey { let secret_key_material = unenc.map(|mpis| mpis.clone()); - match (&self.public, secret_key_material) { + match (self.public.clone(), secret_key_material) { ( mpi::PublicKey::RSA { e, n }, mpi::SecretKeyMaterial::RSA { d: _, p, q, u: _ }, ) => { - let sq_rsa = SqRSA::new(e.clone(), n.clone(), p, q); + let sq_rsa = SqRSA::new(e, n, p, q); Ok(PrivateKeyMaterial::R(Box::new(sq_rsa))) }