Skip to content

Commit

Permalink
Bump MSRV to 1.81
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
str4d committed Nov 6, 2024
1 parent 0a90dc3 commit 70fc164
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 28 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ jobs:
toolchain: stable
deps: true
- platform: ubuntu-latest
toolchain: 1.74.0 # MSRV
toolchain: 1.81.0 # MSRV
deps: sudo apt-get install libpcsclite-dev
- platform: windows-latest
toolchain: 1.74.0 # MSRV
toolchain: 1.81.0 # MSRV
deps: true
- platform: macos-latest
toolchain: 1.74.0 # MSRV
toolchain: 1.81.0 # MSRV
deps: true
runs-on: ${{ matrix.platform }}
steps:
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.74.0 # MSRV
toolchain: 1.81.0 # MSRV
components: clippy
override: true
- run: sudo apt-get install libpcsclite-dev
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Changed
- MSRV is now 1.81.

## 0.8.0 (2023-08-15)
### Added
- `impl Debug for {Context, YubiKey}` ([#457])
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ readme = "README.md"
categories = ["api-bindings", "authentication", "cryptography", "hardware-support"]
keywords = ["ecdsa", "encryption", "rsa", "piv", "signature"]
edition = "2021"
rust-version = "1.65"
rust-version = "1.81"

[workspace]
members = [".", "cli"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ or conditions.
[docs-link]: https://docs.rs/yubikey/
[license-image]: https://img.shields.io/badge/license-BSD-blue.svg
[license-link]: https://github.com/iqlusioninc/yubikey.rs/blob/main/COPYING
[msrv-image]: https://img.shields.io/badge/rustc-1.65+-blue.svg
[msrv-image]: https://img.shields.io/badge/rustc-1.81+-blue.svg
[safety-image]: https://img.shields.io/badge/unsafe-forbidden-success.svg
[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
Expand Down
4 changes: 4 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Changed
- MSRV is now 1.81.

## 0.7.0 (2022-11-14)
### Changed
- Bump `clap` to v4.0 ([#438])
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ readme = "README.md"
categories = ["command-line-utilities", "cryptography", "hardware-support"]
keywords = ["ecdsa", "rsa", "piv", "pcsc", "yubikey"]
edition = "2021"
rust-version = "1.56"
rust-version = "1.81"

[dependencies]
clap = { version = "4", features = ["derive"] }
Expand Down
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
10 changes: 2 additions & 8 deletions src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down Expand Up @@ -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());
Expand Down
14 changes: 8 additions & 6 deletions src/yubikey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -703,10 +706,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());

Expand Down
7 changes: 2 additions & 5 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ use signature::hazmat::PrehashVerifier;
use std::{env, str::FromStr, sync::Mutex, time::Duration};
use x509_cert::{der::Encode, name::Name, serial_number::SerialNumber, time::Validity};
use yubikey::{
certificate,
certificate::yubikey_signer,
certificate::Certificate,
certificate::{yubikey_signer, Certificate},
piv::{self, AlgorithmId, Key, ManagementSlotId, RetiredSlotId, SlotId},
Error, MgmKey, PinPolicy, Serial, TouchPolicy, YubiKey,
};
Expand Down Expand Up @@ -317,8 +315,7 @@ fn test_read_metadata() {
#[ignore]
fn test_parse_cert_from_der() {
let bob_der = std::fs::read("tests/assets/Bob.der").expect(".der file not found");
let cert =
certificate::Certificate::from_bytes(bob_der).expect("Failed to parse valid certificate");
let cert = Certificate::from_bytes(bob_der).expect("Failed to parse valid certificate");
assert_eq!(
cert.subject(),
"CN=Bob",
Expand Down

0 comments on commit 70fc164

Please sign in to comment.