Bump MSRV to 1.81 (#582)
This is required due to the `hybrid-array` crate, which has become a transitive dependency of the majority of our dependencies and will be required in the very near future.
This commit is contained in:
+2
-2
@@ -192,8 +192,8 @@ impl std::error::Error for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<x509_cert::der::Error> for Error {
|
||||
fn from(_err: x509_cert::der::Error) -> Error {
|
||||
impl From<der::Error> for Error {
|
||||
fn from(_err: der::Error) -> Error {
|
||||
Error::ParseError
|
||||
}
|
||||
}
|
||||
|
||||
+12
-20
@@ -155,15 +155,12 @@ impl MgmKey {
|
||||
pub fn get_protected(yubikey: &mut YubiKey) -> Result<Self> {
|
||||
let txn = yubikey.begin_transaction()?;
|
||||
|
||||
let protected_data = ProtectedData::read(&txn).map_err(|e| {
|
||||
error!("could not read protected data (err: {:?})", e);
|
||||
e
|
||||
})?;
|
||||
let protected_data = ProtectedData::read(&txn)
|
||||
.inspect_err(|e| error!("could not read protected data (err: {:?})", e))?;
|
||||
|
||||
let item = protected_data.get_item(TAG_PROTECTED_MGM).map_err(|e| {
|
||||
error!("could not read protected MGM from metadata (err: {:?})", e);
|
||||
e
|
||||
})?;
|
||||
let item = protected_data
|
||||
.get_item(TAG_PROTECTED_MGM)
|
||||
.inspect_err(|e| error!("could not read protected MGM from metadata (err: {:?})", e))?;
|
||||
|
||||
if item.len() != DES_LEN_3DES {
|
||||
error!(
|
||||
@@ -196,12 +193,10 @@ 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)
|
||||
// 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);
|
||||
e
|
||||
})?;
|
||||
.inspect_err(|e| error!("could not set new derived mgm key, err = {}", e))?;
|
||||
|
||||
// After this point, we've set the mgm key, so the function should succeed,
|
||||
// regardless of being able to set the metadata.
|
||||
@@ -255,12 +250,10 @@ impl MgmKey {
|
||||
pub fn set_protected(&self, yubikey: &mut YubiKey) -> Result<()> {
|
||||
let txn = yubikey.begin_transaction()?;
|
||||
|
||||
txn.set_mgm_key(self, false).map_err(|e| {
|
||||
txn.set_mgm_key(self, false)
|
||||
// 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);
|
||||
e
|
||||
})?;
|
||||
.inspect_err(|e| error!("could not set new derived mgm key, err = {}", e))?;
|
||||
|
||||
// after this point, we've set the mgm key, so the function should
|
||||
// succeed, regardless of being able to set the metadata
|
||||
@@ -272,10 +265,9 @@ impl MgmKey {
|
||||
if let Err(e) = protected_data.set_item(TAG_PROTECTED_MGM, self.as_ref()) {
|
||||
error!("could not set protected mgm item, err = {:?}", e);
|
||||
} else {
|
||||
protected_data.write(&txn).map_err(|e| {
|
||||
error!("could not write protected data, err = {:?}", e);
|
||||
e
|
||||
})?;
|
||||
protected_data
|
||||
.write(&txn)
|
||||
.inspect_err(|e| error!("could not write protected data, err = {:?}", e))?;
|
||||
}
|
||||
|
||||
// set the protected mgm flag in admin data
|
||||
|
||||
+3
-4
@@ -96,10 +96,9 @@ impl MsRoots {
|
||||
}
|
||||
}
|
||||
|
||||
MsRoots::new(&data).map(Some).map_err(|e| {
|
||||
error!("error parsing msroots: {:?}", e);
|
||||
e
|
||||
})
|
||||
MsRoots::new(&data)
|
||||
.map(Some)
|
||||
.inspect_err(|e| error!("error parsing msroots: {:?}", e))
|
||||
}
|
||||
|
||||
/// Write `msroots` file to YubiKey
|
||||
|
||||
+2
-8
@@ -66,10 +66,7 @@ impl<'tx> Transaction<'tx> {
|
||||
.p1(0x04)
|
||||
.data(piv::APPLET_ID)
|
||||
.transmit(self, 0xFF)
|
||||
.map_err(|e| {
|
||||
error!("failed communicating with card: '{}'", e);
|
||||
e
|
||||
})?;
|
||||
.inspect_err(|e| error!("failed communicating with card: '{}'", e))?;
|
||||
|
||||
if !response.is_success() {
|
||||
error!(
|
||||
@@ -335,10 +332,7 @@ impl<'tx> Transaction<'tx> {
|
||||
|
||||
let response = self
|
||||
.transfer_data(&templ, &indata[..offset], 1024)
|
||||
.map_err(|e| {
|
||||
error!("sign command failed to communicate: {}", e);
|
||||
e
|
||||
})?;
|
||||
.inspect_err(|e| error!("sign command failed to communicate: {}", e))?;
|
||||
|
||||
if !response.is_success() {
|
||||
error!("failed sign command with code {:x}", response.code());
|
||||
|
||||
+13
-17
@@ -42,7 +42,7 @@ use crate::{
|
||||
transaction::Transaction,
|
||||
};
|
||||
use log::{error, info};
|
||||
use pcsc::{Card, Disposition};
|
||||
use pcsc::Card;
|
||||
use rand_core::{OsRng, RngCore};
|
||||
use std::{
|
||||
fmt::{self, Display},
|
||||
@@ -293,7 +293,10 @@ impl YubiKey {
|
||||
/// `YubiKey` implements `Drop` which automatically disconnects the card using
|
||||
/// `Disposition::ResetCard`; you only need to call this function if you want to
|
||||
/// handle errors or use a different disposition method.
|
||||
pub fn disconnect(self, disposition: Disposition) -> core::result::Result<(), (Self, Error)> {
|
||||
pub fn disconnect(
|
||||
self,
|
||||
disposition: pcsc::Disposition,
|
||||
) -> core::result::Result<(), (Self, Error)> {
|
||||
let Self {
|
||||
card,
|
||||
name,
|
||||
@@ -523,15 +526,11 @@ impl YubiKey {
|
||||
|
||||
admin_data
|
||||
.set_item(TAG_ADMIN_TIMESTAMP, &tnow)
|
||||
.map_err(|e| {
|
||||
error!("could not set pin timestamp, err = {}", e);
|
||||
e
|
||||
})?;
|
||||
.inspect_err(|e| error!("could not set pin timestamp, err = {}", e))?;
|
||||
|
||||
admin_data.write(&txn).map_err(|e| {
|
||||
error!("could not write admin data, err = {}", e);
|
||||
e
|
||||
})?;
|
||||
admin_data
|
||||
.write(&txn)
|
||||
.inspect_err(|e| error!("could not write admin data, err = {}", e))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -581,7 +580,7 @@ impl YubiKey {
|
||||
|
||||
// Attempt to set the "PUK blocked" flag in admin data.
|
||||
let mut admin_data = AdminData::read(&txn)
|
||||
.map(|data| {
|
||||
.inspect(|data| {
|
||||
if let Ok(item) = data.get_item(TAG_ADMIN_FLAGS_1) {
|
||||
if item.len() == flags.len() {
|
||||
flags.copy_from_slice(item)
|
||||
@@ -593,8 +592,6 @@ impl YubiKey {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
data
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
@@ -703,10 +700,9 @@ impl<'a> TryFrom<&'a Reader<'_>> for YubiKey {
|
||||
type Error = Error;
|
||||
|
||||
fn try_from(reader: &'a Reader<'_>) -> Result<Self> {
|
||||
let mut card = reader.connect().map_err(|e| {
|
||||
error!("error connecting to reader '{}': {}", reader.name(), e);
|
||||
e
|
||||
})?;
|
||||
let mut card = reader
|
||||
.connect()
|
||||
.inspect_err(|e| error!("error connecting to reader '{}': {}", reader.name(), e))?;
|
||||
|
||||
info!("connected to reader: {}", reader.name());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user