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:
committed by
GitHub
parent
74a50f0f0c
commit
dd4b1c60a4
@@ -33,7 +33,6 @@
|
||||
use crate::{Error, Result, YubiKey};
|
||||
use rand_core::{OsRng, RngCore};
|
||||
use std::{
|
||||
convert::TryInto,
|
||||
fmt::{self, Debug, Display},
|
||||
str,
|
||||
};
|
||||
|
||||
+5
-7
@@ -47,9 +47,7 @@ use p256::NistP256;
|
||||
use p384::NistP384;
|
||||
use rsa::{PublicKeyParts, RsaPublicKey};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt;
|
||||
use std::ops::DerefMut;
|
||||
use std::{fmt, ops::DerefMut};
|
||||
use x509::{der::Oid, RelativeDistinguishedName};
|
||||
use x509_parser::{parse_x509_certificate, x509::SubjectPublicKeyInfo};
|
||||
use zeroize::Zeroizing;
|
||||
@@ -85,7 +83,7 @@ impl TryFrom<&[u8]> for Serial {
|
||||
|
||||
fn try_from(bytes: &[u8]) -> Result<Serial> {
|
||||
if bytes.len() <= 20 {
|
||||
Ok(Serial(BigUint::from_bytes_be(&bytes)))
|
||||
Ok(Serial(BigUint::from_bytes_be(bytes)))
|
||||
} else {
|
||||
Err(Error::ParseError)
|
||||
}
|
||||
@@ -365,12 +363,12 @@ impl Certificate {
|
||||
&serial.to_bytes(),
|
||||
&signature_algorithm,
|
||||
// Issuer and subject are the same in self-signed certificates.
|
||||
&subject,
|
||||
subject,
|
||||
Utc::now(),
|
||||
not_after,
|
||||
&subject,
|
||||
subject,
|
||||
&subject_pki,
|
||||
&extensions,
|
||||
extensions,
|
||||
),
|
||||
tbs_cert.deref_mut(),
|
||||
)
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
|
||||
use crate::{Error, Result, YubiKey};
|
||||
use std::{
|
||||
convert::TryInto,
|
||||
fmt::{self, Debug, Display},
|
||||
str,
|
||||
};
|
||||
|
||||
+1
-4
@@ -41,10 +41,7 @@ use crate::{
|
||||
Result,
|
||||
};
|
||||
use log::error;
|
||||
use std::{
|
||||
convert::TryInto,
|
||||
time::{Duration, SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
|
||||
const CB_ADMIN_TIMESTAMP: usize = 0x04;
|
||||
const PROTECTED_FLAGS_1_PUK_NOBLOCK: u8 = 0x01;
|
||||
|
||||
+2
-3
@@ -33,7 +33,6 @@
|
||||
use crate::{Error, Result};
|
||||
use log::error;
|
||||
use rand_core::{OsRng, RngCore};
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use zeroize::{Zeroize, Zeroizing};
|
||||
|
||||
#[cfg(feature = "untested")]
|
||||
@@ -138,7 +137,7 @@ impl MgmKey {
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -191,7 +190,7 @@ impl MgmKey {
|
||||
pub fn set_manual(&self, yubikey: &mut YubiKey, require_touch: bool) -> Result<()> {
|
||||
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
|
||||
// where we can't set the mgm key.
|
||||
error!("could not set new derived mgm key, err = {}", e);
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
|
||||
use crate::{consts::CB_OBJ_MAX, piv::SlotId, serialization::*, Error, Result, YubiKey};
|
||||
use log::error;
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
|
||||
const OBJ_MSCMAP: u32 = 0x005f_ff10;
|
||||
|
||||
|
||||
+2
-2
@@ -111,7 +111,7 @@ impl MsRoots {
|
||||
let mut data_chunk: usize;
|
||||
let data = &self.0;
|
||||
let data_len = data.len();
|
||||
let n_objs: usize;
|
||||
|
||||
let txn = yubikey.begin_transaction()?;
|
||||
|
||||
if data_len == 0 {
|
||||
@@ -119,7 +119,7 @@ impl MsRoots {
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return Err(Error::SizeError);
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ use crate::{
|
||||
use elliptic_curve::sec1::EncodedPoint as EcPublicKey;
|
||||
use log::{debug, error, warn};
|
||||
use rsa::{BigUint, RsaPublicKey};
|
||||
use std::{convert::TryFrom, str::FromStr};
|
||||
use std::str::FromStr;
|
||||
|
||||
#[cfg(feature = "untested")]
|
||||
use {
|
||||
|
||||
+1
-1
@@ -3,7 +3,6 @@
|
||||
use crate::{Result, YubiKey};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
convert::TryInto,
|
||||
ffi::CStr,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
@@ -45,6 +44,7 @@ impl Context {
|
||||
c.list_readers(reader_names)?.collect()
|
||||
};
|
||||
|
||||
#[allow(clippy::needless_collect)]
|
||||
let readers: Vec<_> = reader_cstrs
|
||||
.iter()
|
||||
.map(|name| Reader::new(name, Arc::clone(ctx)))
|
||||
|
||||
+2
-11
@@ -65,7 +65,7 @@ impl Default for SettingSource {
|
||||
/// These can be configured globally in `/etc/yubico/yubikeypiv.conf` by a
|
||||
/// system administrator, or by the local user via `YUBIKEY_PIV_*` environment
|
||||
/// variables.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
pub struct Setting {
|
||||
/// Boolean value
|
||||
pub value: bool,
|
||||
@@ -99,7 +99,7 @@ impl Setting {
|
||||
}
|
||||
|
||||
let (name, value) = {
|
||||
let mut parts = line.splitn(1, '=');
|
||||
let mut parts = line.splitn(2, '=');
|
||||
let name = parts.next();
|
||||
let 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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ use crate::{
|
||||
Buffer, ObjectId,
|
||||
};
|
||||
use log::{error, trace};
|
||||
use std::convert::TryInto;
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
#[cfg(feature = "untested")]
|
||||
|
||||
@@ -45,7 +45,6 @@ use log::{error, info};
|
||||
use pcsc::Card;
|
||||
use rand_core::{OsRng, RngCore};
|
||||
use std::{
|
||||
convert::{TryFrom, TryInto},
|
||||
fmt::{self, Display},
|
||||
str::FromStr,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user