2021 edition upgrade; MSRV 1.56 (#343)

Changes the `edition` to 2021 in both the `yubikey` and `yubikey-cli`
crates.

Removes `TryFrom`/`TryInto` imports, now that they're in the prelude.
This commit is contained in:
Tony Arcieri (iqlusion)
2022-01-17 14:54:01 -08:00
committed by GitHub
parent 74a50f0f0c
commit dd4b1c60a4
18 changed files with 40 additions and 58 deletions
+4 -4
View File
@@ -36,13 +36,13 @@ jobs:
toolchain: stable toolchain: stable
deps: true deps: true
- platform: ubuntu-latest - platform: ubuntu-latest
toolchain: 1.51.0 # MSRV toolchain: 1.56.0 # MSRV
deps: sudo apt-get install libpcsclite-dev deps: sudo apt-get install libpcsclite-dev
- platform: windows-latest - platform: windows-latest
toolchain: 1.51.0 # MSRV toolchain: 1.56.0 # MSRV
deps: true deps: true
- platform: macos-latest - platform: macos-latest
toolchain: 1.51.0 # MSRV toolchain: 1.56.0 # MSRV
deps: true deps: true
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
steps: steps:
@@ -82,7 +82,7 @@ jobs:
- uses: actions-rs/toolchain@v1 - uses: actions-rs/toolchain@v1
with: with:
profile: minimal profile: minimal
toolchain: 1.51.0 # MSRV toolchain: 1.56.0 # MSRV
components: clippy components: clippy
override: true override: true
- run: sudo apt-get install libpcsclite-dev - run: sudo apt-get install libpcsclite-dev
Generated
+2 -2
View File
@@ -894,7 +894,7 @@ dependencies = [
[[package]] [[package]]
name = "yubikey" name = "yubikey"
version = "0.5.0" version = "0.6.0-pre"
dependencies = [ dependencies = [
"chrono", "chrono",
"cookie-factory", "cookie-factory",
@@ -928,7 +928,7 @@ dependencies = [
[[package]] [[package]]
name = "yubikey-cli" name = "yubikey-cli"
version = "0.5.0" version = "0.6.0-pre"
dependencies = [ dependencies = [
"env_logger", "env_logger",
"gumdrop", "gumdrop",
+3 -2
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "yubikey" name = "yubikey"
version = "0.5.0" # Also update html_root_url in lib.rs when bumping this version = "0.6.0-pre" # Also update html_root_url in lib.rs when bumping this
description = """ description = """
Pure Rust cross-platform host-side driver for YubiKey devices from Yubico with Pure Rust cross-platform host-side driver for YubiKey devices from Yubico with
support for hardware-backed public-key decryption and digital signatures using support for hardware-backed public-key decryption and digital signatures using
@@ -8,12 +8,13 @@ the Personal Identity Verification (PIV) application. Supports RSA (1024/2048)
or ECC (NIST P-256/P-384) algorithms e.g, PKCS#1v1.5, ECDSA or ECC (NIST P-256/P-384) algorithms e.g, PKCS#1v1.5, ECDSA
""" """
authors = ["Tony Arcieri <tony@iqlusion.io>", "Yubico AB"] authors = ["Tony Arcieri <tony@iqlusion.io>", "Yubico AB"]
edition = "2018"
license = "BSD-2-Clause" license = "BSD-2-Clause"
repository = "https://github.com/iqlusioninc/yubikey.rs" repository = "https://github.com/iqlusioninc/yubikey.rs"
readme = "README.md" readme = "README.md"
categories = ["api-bindings", "cryptography", "hardware-support"] categories = ["api-bindings", "cryptography", "hardware-support"]
keywords = ["ecdsa", "encryption", "rsa", "piv", "signature"] keywords = ["ecdsa", "encryption", "rsa", "piv", "signature"]
edition = "2021"
rust-version = "1.56"
[workspace] [workspace]
members = [".", "cli"] members = [".", "cli"]
+3 -3
View File
@@ -5,7 +5,7 @@
[![crate][crate-image]][crate-link] [![crate][crate-image]][crate-link]
[![Docs][docs-image]][docs-link] [![Docs][docs-image]][docs-link]
[![2-Clause BSD Licensed][license-image]][license-link] [![2-Clause BSD Licensed][license-image]][license-link]
![Rust Version][rustc-image] ![MSRV][msrv-image]
[![Safety Dance][safety-image]][safety-link] [![Safety Dance][safety-image]][safety-link]
[![Build Status][build-image]][build-link] [![Build Status][build-image]][build-link]
[![dependency status][deps-image]][deps-link] [![dependency status][deps-image]][deps-link]
@@ -36,7 +36,7 @@ endorsed by Yubico.
## Minimum Supported Rust Version ## Minimum Supported Rust Version
Rust **1.51** or newer. Rust **1.56** or newer.
## Supported YubiKeys ## Supported YubiKeys
@@ -165,7 +165,7 @@ or conditions.
[docs-link]: https://docs.rs/yubikey/ [docs-link]: https://docs.rs/yubikey/
[license-image]: https://img.shields.io/badge/license-BSD-blue.svg [license-image]: https://img.shields.io/badge/license-BSD-blue.svg
[license-link]: https://github.com/iqlusioninc/yubikey.rs/blob/main/COPYING [license-link]: https://github.com/iqlusioninc/yubikey.rs/blob/main/COPYING
[rustc-image]: https://img.shields.io/badge/rustc-1.51+-blue.svg [msrv-image]: https://img.shields.io/badge/rustc-1.56+-blue.svg
[safety-image]: https://img.shields.io/badge/unsafe-forbidden-success.svg [safety-image]: https://img.shields.io/badge/unsafe-forbidden-success.svg
[safety-link]: https://github.com/rust-secure-code/safety-dance/ [safety-link]: https://github.com/rust-secure-code/safety-dance/
[build-image]: https://github.com/iqlusioninc/yubikey.rs/workflows/CI/badge.svg?branch=main&event=push [build-image]: https://github.com/iqlusioninc/yubikey.rs/workflows/CI/badge.svg?branch=main&event=push
+4 -3
View File
@@ -1,17 +1,18 @@
[package] [package]
name = "yubikey-cli" name = "yubikey-cli"
version = "0.5.0" version = "0.6.0-pre"
description = """ description = """
Command-line interface for performing encryption and signing using RSA/ECC keys Command-line interface for performing encryption and signing using RSA/ECC keys
stored on YubiKey devices. stored on YubiKey devices.
""" """
authors = ["Tony Arcieri <tony@iqlusion.io>"] authors = ["Tony Arcieri <tony@iqlusion.io>"]
edition = "2018"
license = "BSD-2-Clause" license = "BSD-2-Clause"
repository = "https://github.com/iqlusioninc/yubikey.rs" repository = "https://github.com/iqlusioninc/yubikey.rs"
readme = "README.md" readme = "README.md"
categories = ["command-line-utilities", "cryptography", "hardware-support"] categories = ["command-line-utilities", "cryptography", "hardware-support"]
keywords = ["ecdsa", "rsa", "piv", "pcsc", "yubikey"] keywords = ["ecdsa", "rsa", "piv", "pcsc", "yubikey"]
edition = "2021"
rust-version = "1.56"
[dependencies] [dependencies]
gumdrop = "0.8" gumdrop = "0.8"
@@ -22,4 +23,4 @@ sha2 = "0.9"
subtle-encoding = "0.5" subtle-encoding = "0.5"
termcolor = "1" termcolor = "1"
x509-parser = "0.12" x509-parser = "0.12"
yubikey = { version = "0.5", path = ".." } yubikey = { version = "=0.6.0-pre", path = ".." }
-1
View File
@@ -33,7 +33,6 @@
use crate::{Error, Result, YubiKey}; use crate::{Error, Result, YubiKey};
use rand_core::{OsRng, RngCore}; use rand_core::{OsRng, RngCore};
use std::{ use std::{
convert::TryInto,
fmt::{self, Debug, Display}, fmt::{self, Debug, Display},
str, str,
}; };
+5 -7
View File
@@ -47,9 +47,7 @@ use p256::NistP256;
use p384::NistP384; use p384::NistP384;
use rsa::{PublicKeyParts, RsaPublicKey}; use rsa::{PublicKeyParts, RsaPublicKey};
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
use std::convert::TryFrom; use std::{fmt, ops::DerefMut};
use std::fmt;
use std::ops::DerefMut;
use x509::{der::Oid, RelativeDistinguishedName}; use x509::{der::Oid, RelativeDistinguishedName};
use x509_parser::{parse_x509_certificate, x509::SubjectPublicKeyInfo}; use x509_parser::{parse_x509_certificate, x509::SubjectPublicKeyInfo};
use zeroize::Zeroizing; use zeroize::Zeroizing;
@@ -85,7 +83,7 @@ impl TryFrom<&[u8]> for Serial {
fn try_from(bytes: &[u8]) -> Result<Serial> { fn try_from(bytes: &[u8]) -> Result<Serial> {
if bytes.len() <= 20 { if bytes.len() <= 20 {
Ok(Serial(BigUint::from_bytes_be(&bytes))) Ok(Serial(BigUint::from_bytes_be(bytes)))
} else { } else {
Err(Error::ParseError) Err(Error::ParseError)
} }
@@ -365,12 +363,12 @@ impl Certificate {
&serial.to_bytes(), &serial.to_bytes(),
&signature_algorithm, &signature_algorithm,
// Issuer and subject are the same in self-signed certificates. // Issuer and subject are the same in self-signed certificates.
&subject, subject,
Utc::now(), Utc::now(),
not_after, not_after,
&subject, subject,
&subject_pki, &subject_pki,
&extensions, extensions,
), ),
tbs_cert.deref_mut(), tbs_cert.deref_mut(),
) )
-1
View File
@@ -32,7 +32,6 @@
use crate::{Error, Result, YubiKey}; use crate::{Error, Result, YubiKey};
use std::{ use std::{
convert::TryInto,
fmt::{self, Debug, Display}, fmt::{self, Debug, Display},
str, str,
}; };
+1 -4
View File
@@ -41,10 +41,7 @@ use crate::{
Result, Result,
}; };
use log::error; use log::error;
use std::{ use std::time::{Duration, SystemTime, UNIX_EPOCH};
convert::TryInto,
time::{Duration, SystemTime, UNIX_EPOCH},
};
const CB_ADMIN_TIMESTAMP: usize = 0x04; const CB_ADMIN_TIMESTAMP: usize = 0x04;
const PROTECTED_FLAGS_1_PUK_NOBLOCK: u8 = 0x01; const PROTECTED_FLAGS_1_PUK_NOBLOCK: u8 = 0x01;
+2 -3
View File
@@ -33,7 +33,6 @@
use crate::{Error, Result}; use crate::{Error, Result};
use log::error; use log::error;
use rand_core::{OsRng, RngCore}; use rand_core::{OsRng, RngCore};
use std::convert::{TryFrom, TryInto};
use zeroize::{Zeroize, Zeroizing}; use zeroize::{Zeroize, Zeroizing};
#[cfg(feature = "untested")] #[cfg(feature = "untested")]
@@ -138,7 +137,7 @@ impl MgmKey {
} }
let mut mgm = [0u8; DES_LEN_3DES]; let mut mgm = [0u8; DES_LEN_3DES];
pbkdf2::<Hmac<Sha1>>(pin, &salt, ITER_MGM_PBKDF2, &mut mgm); pbkdf2::<Hmac<Sha1>>(pin, salt, ITER_MGM_PBKDF2, &mut mgm);
MgmKey::from_bytes(mgm) MgmKey::from_bytes(mgm)
} }
@@ -191,7 +190,7 @@ impl MgmKey {
pub fn set_manual(&self, yubikey: &mut YubiKey, require_touch: bool) -> Result<()> { pub fn set_manual(&self, yubikey: &mut YubiKey, require_touch: bool) -> Result<()> {
let txn = yubikey.begin_transaction()?; let txn = yubikey.begin_transaction()?;
txn.set_mgm_key(&self, require_touch).map_err(|e| { txn.set_mgm_key(self, require_touch).map_err(|e| {
// Log a warning, since the device mgm key is corrupt or we're in a state // Log a warning, since the device mgm key is corrupt or we're in a state
// where we can't set the mgm key. // where we can't set the mgm key.
error!("could not set new derived mgm key, err = {}", e); error!("could not set new derived mgm key, err = {}", e);
-1
View File
@@ -32,7 +32,6 @@
use crate::{consts::CB_OBJ_MAX, piv::SlotId, serialization::*, Error, Result, YubiKey}; use crate::{consts::CB_OBJ_MAX, piv::SlotId, serialization::*, Error, Result, YubiKey};
use log::error; use log::error;
use std::convert::{TryFrom, TryInto};
const OBJ_MSCMAP: u32 = 0x005f_ff10; const OBJ_MSCMAP: u32 = 0x005f_ff10;
+2 -2
View File
@@ -111,7 +111,7 @@ impl MsRoots {
let mut data_chunk: usize; let mut data_chunk: usize;
let data = &self.0; let data = &self.0;
let data_len = data.len(); let data_len = data.len();
let n_objs: usize;
let txn = yubikey.begin_transaction()?; let txn = yubikey.begin_transaction()?;
if data_len == 0 { if data_len == 0 {
@@ -119,7 +119,7 @@ impl MsRoots {
} }
// Calculate number of objects required to store blob // Calculate number of objects required to store blob
n_objs = (data_len / (CB_OBJ_MAX - CB_OBJ_TAG_MAX)) + 1; let n_objs: usize = (data_len / (CB_OBJ_MAX - CB_OBJ_TAG_MAX)) + 1;
if n_objs > 5 { if n_objs > 5 {
return Err(Error::SizeError); return Err(Error::SizeError);
+1 -1
View File
@@ -55,7 +55,7 @@ use crate::{
use elliptic_curve::sec1::EncodedPoint as EcPublicKey; use elliptic_curve::sec1::EncodedPoint as EcPublicKey;
use log::{debug, error, warn}; use log::{debug, error, warn};
use rsa::{BigUint, RsaPublicKey}; use rsa::{BigUint, RsaPublicKey};
use std::{convert::TryFrom, str::FromStr}; use std::str::FromStr;
#[cfg(feature = "untested")] #[cfg(feature = "untested")]
use { use {
+1 -1
View File
@@ -3,7 +3,6 @@
use crate::{Result, YubiKey}; use crate::{Result, YubiKey};
use std::{ use std::{
borrow::Cow, borrow::Cow,
convert::TryInto,
ffi::CStr, ffi::CStr,
sync::{Arc, Mutex}, sync::{Arc, Mutex},
}; };
@@ -45,6 +44,7 @@ impl Context {
c.list_readers(reader_names)?.collect() c.list_readers(reader_names)?.collect()
}; };
#[allow(clippy::needless_collect)]
let readers: Vec<_> = reader_cstrs let readers: Vec<_> = reader_cstrs
.iter() .iter()
.map(|name| Reader::new(name, Arc::clone(ctx))) .map(|name| Reader::new(name, Arc::clone(ctx)))
+2 -11
View File
@@ -65,7 +65,7 @@ impl Default for SettingSource {
/// These can be configured globally in `/etc/yubico/yubikeypiv.conf` by a /// These can be configured globally in `/etc/yubico/yubikeypiv.conf` by a
/// system administrator, or by the local user via `YUBIKEY_PIV_*` environment /// system administrator, or by the local user via `YUBIKEY_PIV_*` environment
/// variables. /// variables.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug, Default)]
pub struct Setting { pub struct Setting {
/// Boolean value /// Boolean value
pub value: bool, pub value: bool,
@@ -99,7 +99,7 @@ impl Setting {
} }
let (name, value) = { let (name, value) = {
let mut parts = line.splitn(1, '='); let mut parts = line.splitn(2, '=');
let name = parts.next(); let name = parts.next();
let value = parts.next(); let value = parts.next();
match (name, value, parts.next()) { match (name, value, parts.next()) {
@@ -130,12 +130,3 @@ impl Setting {
}) })
} }
} }
impl Default for Setting {
fn default() -> Self {
Self {
value: false,
source: SettingSource::default(),
}
}
}
-1
View File
@@ -11,7 +11,6 @@ use crate::{
Buffer, ObjectId, Buffer, ObjectId,
}; };
use log::{error, trace}; use log::{error, trace};
use std::convert::TryInto;
use zeroize::Zeroizing; use zeroize::Zeroizing;
#[cfg(feature = "untested")] #[cfg(feature = "untested")]
-1
View File
@@ -45,7 +45,6 @@ use log::{error, info};
use pcsc::Card; use pcsc::Card;
use rand_core::{OsRng, RngCore}; use rand_core::{OsRng, RngCore};
use std::{ use std::{
convert::{TryFrom, TryInto},
fmt::{self, Display}, fmt::{self, Display},
str::FromStr, str::FromStr,
}; };
+1 -1
View File
@@ -8,7 +8,7 @@ use log::trace;
use rand_core::{OsRng, RngCore}; use rand_core::{OsRng, RngCore};
use rsa::{hash::Hash::SHA2_256, PaddingScheme, PublicKey}; use rsa::{hash::Hash::SHA2_256, PaddingScheme, PublicKey};
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
use std::{convert::TryInto, env, sync::Mutex}; use std::{env, sync::Mutex};
use x509::RelativeDistinguishedName; use x509::RelativeDistinguishedName;
use yubikey::{ use yubikey::{
certificate::{Certificate, PublicKeyInfo}, certificate::{Certificate, PublicKeyInfo},