Skip to content

Upgrade to 2024 edition; MSRV 1.85 #354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ssh-cipher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
strategy:
matrix:
rust:
- 1.81.0 # MSRV
- 1.85.0 # MSRV
- stable
target:
- thumbv7em-none-eabi
Expand All @@ -49,7 +49,7 @@ jobs:
strategy:
matrix:
rust:
- 1.81.0 # MSRV
- 1.85.0 # MSRV
- stable
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ssh-derive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
strategy:
matrix:
rust:
- 1.61.0 # MSRV
- 1.85.0 # MSRV
- stable
steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ssh-encoding.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
strategy:
matrix:
rust:
- 1.81.0 # MSRV
- 1.85.0 # MSRV
- stable
target:
- thumbv7em-none-eabi
Expand All @@ -47,7 +47,7 @@ jobs:
strategy:
matrix:
rust:
- 1.81.0 # MSRV
- 1.85.0 # MSRV
- stable
steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ssh-key.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
strategy:
matrix:
rust:
- 1.81.0 # MSRV
- 1.85.0 # MSRV
- stable
target:
- thumbv7em-none-eabi
Expand All @@ -80,7 +80,7 @@ jobs:
strategy:
matrix:
rust:
- 1.81.0 # MSRV
- 1.85.0 # MSRV
- stable
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ssh-protocol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
matrix:
rust:
- 1.81.0 # MSRV
- 1.85.0 # MSRV
- stable
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.81.0
toolchain: 1.85.0
components: clippy
- run: cargo clippy --all-features

Expand Down
4 changes: 2 additions & 2 deletions ssh-cipher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ repository = "https://github.com/RustCrypto/SSH"
categories = ["cryptography", "no-std"]
keywords = ["crypto", "encryption", "openssh", "ssh"]
readme = "README.md"
edition = "2021"
rust-version = "1.81"
edition = "2024"
rust-version = "1.85"

[dependencies]
cipher = "=0.5.0-pre.6"
Expand Down
2 changes: 1 addition & 1 deletion ssh-cipher/src/chacha20poly1305.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ pub use chacha20::ChaCha20Legacy as ChaCha20;

use crate::Tag;
use aead::{
array::typenum::{U0, U16, U32, U8},
AeadCore, Error, KeyInit, KeySizeUser, Result,
array::typenum::{U0, U8, U16, U32},
};
use cipher::{KeyIvInit, StreamCipher, StreamCipherSeek};
use poly1305::Poly1305;
Expand Down
2 changes: 1 addition & 1 deletion ssh-cipher/src/decryptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{Cipher, Error, Result};
use cipher::KeyIvInit;

#[cfg(feature = "aes-ctr")]
use crate::{encryptor::ctr_encrypt as ctr_decrypt, Ctr128BE};
use crate::{Ctr128BE, encryptor::ctr_encrypt as ctr_decrypt};

#[cfg(feature = "tdes")]
use des::TdesEde3;
Expand Down
2 changes: 1 addition & 1 deletion ssh-cipher/src/encryptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cipher::{Block, BlockCipher, BlockCipherEncrypt, KeyIvInit};
#[cfg(feature = "aes-ctr")]
use {
crate::Ctr128BE,
cipher::{array::sizes::U16, StreamCipherCore},
cipher::{StreamCipherCore, array::sizes::U16},
};

#[cfg(feature = "tdes")]
Expand Down
4 changes: 2 additions & 2 deletions ssh-cipher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ pub use crate::{decryptor::Decryptor, encryptor::Encryptor};
#[cfg(feature = "chacha20poly1305")]
pub use crate::chacha20poly1305::{ChaCha20, ChaCha20Poly1305, ChaChaKey, ChaChaNonce};

use cipher::array::{typenum::U16, Array};
use cipher::array::{Array, typenum::U16};
use core::{fmt, str};
use encoding::{Label, LabelError};

#[cfg(feature = "aes-gcm")]
use {
aead::{array::typenum::U12, AeadInPlace},
aead::{AeadInPlace, array::typenum::U12},
aes_gcm::{Aes128Gcm, Aes256Gcm},
};

Expand Down
4 changes: 2 additions & 2 deletions ssh-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ repository = "https://github.com/RustCrypto/SSH"
categories = ["authentication", "cryptography", "encoding", "no-std", "parser-implementations"]
keywords = ["crypto", "certificate", "key", "openssh", "ssh"]
readme = "README.md"
edition = "2021"
rust-version = "1.61"
edition = "2024"
rust-version = "1.85"

[lib]
proc-macro = true
Expand Down
12 changes: 7 additions & 5 deletions ssh-derive/src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use proc_macro2::TokenStream;
use quote::quote;
use syn::{spanned::Spanned, DataEnum, DataStruct, DeriveInput};
use syn::{DataEnum, DataStruct, DeriveInput, spanned::Spanned};

use crate::attributes::{ContainerAttributes, FieldAttributes};

Expand Down Expand Up @@ -222,10 +222,12 @@ mod tests {
});
let actual = derive_for_fields(&syn::Fields::Named(fields), quote! { Self });
assert!(actual.is_err());
assert!(actual
.unwrap_err()
.to_string()
.contains("unknown attribute"));
assert!(
actual
.unwrap_err()
.to_string()
.contains("unknown attribute")
);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions ssh-derive/src/encode.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Support for deriving the `Encode` trait on structs.

use proc_macro2::TokenStream;
use quote::{quote, ToTokens};
use syn::{spanned::Spanned, DataEnum, DataStruct, DeriveInput};
use quote::{ToTokens, quote};
use syn::{DataEnum, DataStruct, DeriveInput, spanned::Spanned};

use crate::attributes::{ContainerAttributes, FieldAttributes};

Expand Down
2 changes: 1 addition & 1 deletion ssh-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mod decode;
mod encode;

use proc_macro::TokenStream;
use syn::{parse_macro_input, DeriveInput};
use syn::{DeriveInput, parse_macro_input};

/// Derive the [`Decode`][1] trait on a `struct`.
///
Expand Down
4 changes: 2 additions & 2 deletions ssh-encoding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ repository = "https://github.com/RustCrypto/SSH"
categories = ["authentication", "cryptography", "encoding", "no-std", "parser-implementations"]
keywords = ["crypto", "certificate", "key", "openssh", "ssh"]
readme = "README.md"
edition = "2021"
rust-version = "1.81"
edition = "2024"
rust-version = "1.85"

[dependencies]
base64ct = { version = "1.7", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion ssh-encoding/src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//!
//! [RFC4251 § 5]: https://datatracker.ietf.org/doc/html/rfc4251#section-5

use crate::{reader::Reader, Error, Result};
use crate::{Error, Result, reader::Reader};

#[cfg(feature = "alloc")]
use alloc::{string::String, vec::Vec};
Expand Down
2 changes: 1 addition & 1 deletion ssh-encoding/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//!
//! [RFC4251 § 5]: https://datatracker.ietf.org/doc/html/rfc4251#section-5

use crate::{checked::CheckedSum, writer::Writer, Error};
use crate::{Error, checked::CheckedSum, writer::Writer};
use core::str;

#[cfg(feature = "alloc")]
Expand Down
4 changes: 2 additions & 2 deletions ssh-encoding/src/pem/decode.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{reader::PemReader, PemLabel};
use super::{PemLabel, reader::PemReader};
use crate::{Decode, Reader};

/// Decoding trait for PEM documents.
Expand All @@ -13,7 +13,7 @@ pub trait DecodePem: Decode + PemLabel + Sized {

impl<T: Decode + PemLabel + Sized> DecodePem for T {
fn decode_pem(pem: impl AsRef<[u8]>) -> Result<Self, Self::Error> {
let mut reader = PemReader::new(pem.as_ref()).map_err(crate::Error::from)?;
let mut reader = PemReader::new(pem.as_ref())?;
Self::validate_pem_label(reader.type_label()).map_err(crate::Error::from)?;

let ret = Self::decode(&mut reader)?;
Expand Down
6 changes: 3 additions & 3 deletions ssh-encoding/src/pem/encode.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{writer::PemWriter, LineEnding, PemLabel};
use super::{LineEnding, PemLabel, writer::PemWriter};
use crate::{Encode, Error};
use core::str;

Expand All @@ -22,10 +22,10 @@ pub trait EncodePem: Encode + PemLabel {

impl<T: Encode + PemLabel> EncodePem for T {
fn encode_pem<'o>(&self, line_ending: LineEnding, out: &'o mut [u8]) -> Result<&'o str, Error> {
let mut writer = PemWriter::new(Self::PEM_LABEL, line_ending, out).map_err(Error::from)?;
let mut writer = PemWriter::new(Self::PEM_LABEL, line_ending, out)?;
self.encode(&mut writer)?;

let encoded_len = writer.finish().map_err(Error::from)?;
let encoded_len = writer.finish()?;
str::from_utf8(&out[..encoded_len]).map_err(Error::from)
}

Expand Down
4 changes: 2 additions & 2 deletions ssh-encoding/src/pem/writer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{LineEnding, LINE_WIDTH};
use super::{LINE_WIDTH, LineEnding};
use crate::{Result, Writer};

/// Inner PEM encoder.
Expand Down Expand Up @@ -33,7 +33,7 @@ impl<'o> PemWriter<'o> {
}
}

impl<'o> Writer for PemWriter<'o> {
impl Writer for PemWriter<'_> {
fn write(&mut self, bytes: &[u8]) -> Result<()> {
Ok(self.inner.encode(bytes)?)
}
Expand Down
2 changes: 1 addition & 1 deletion ssh-encoding/src/reader.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Reader trait and associated implementations.

use crate::{decode::Decode, Error, Result};
use crate::{Error, Result, decode::Decode};
use core::str;

/// Reader trait which decodes the binary SSH protocol serialization from
Expand Down
4 changes: 2 additions & 2 deletions ssh-encoding/tests/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ fn decode_u8() {
fn decode_boolean() {
let mut bytes = hex!("01").as_slice();
let ret = bool::decode(&mut bytes).unwrap();
assert_eq!(ret, true);
assert!(ret);

// "All non-zero values MUST be interpreted as TRUE"
let mut bytes = hex!("FF").as_slice();
let ret = bool::decode(&mut bytes).unwrap();
assert_eq!(ret, true);
assert!(ret);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions ssh-key/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ repository = "https://github.com/RustCrypto/SSH"
categories = ["authentication", "cryptography", "encoding", "no-std", "parser-implementations"]
keywords = ["crypto", "certificate", "openssh", "ssh", "sshsig"]
readme = "README.md"
edition = "2021"
rust-version = "1.81"
edition = "2024"
rust-version = "1.85"

[dependencies]
cipher = { package = "ssh-cipher", version = "=0.3.0-pre.2", features = ["zeroize"], path = "../ssh-cipher" }
Expand Down
4 changes: 2 additions & 2 deletions ssh-key/src/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ mod unix_time;
pub use self::{builder::Builder, cert_type::CertType, field::Field, options_map::OptionsMap};

use crate::{
public::{KeyData, SshFormat},
Algorithm, Error, Fingerprint, HashAlg, Result, Signature,
public::{KeyData, SshFormat},
};
use alloc::{
borrow::ToOwned,
Expand All @@ -22,7 +22,7 @@ use encoding::{Base64Reader, CheckedSum, Decode, Encode, Reader, Writer};
use signature::Verifier;

#[cfg(feature = "serde")]
use serde::{de, ser, Deserialize, Serialize};
use serde::{Deserialize, Serialize, de, ser};

#[cfg(feature = "std")]
use {
Expand Down
2 changes: 1 addition & 1 deletion ssh-key/src/certificate/builder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! OpenSSH certificate builder.

use super::{CertType, Certificate, Field, OptionsMap};
use crate::{public, Result, Signature, SigningKey};
use crate::{Result, Signature, SigningKey, public};
use alloc::{string::String, vec::Vec};

#[cfg(feature = "rand_core")]
Expand Down
26 changes: 12 additions & 14 deletions ssh-key/src/certificate/options_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,18 @@ impl Decode for OptionsMap {

impl Encode for OptionsMap {
fn encoded_len(&self) -> encoding::Result<usize> {
self.iter()
.try_fold(4, |acc, (name, data)| {
[
acc,
name.encoded_len()?,
if data.is_empty() {
4
} else {
data.encoded_len_prefixed()?
},
]
.checked_sum()
})
.map_err(Into::into)
self.iter().try_fold(4, |acc, (name, data)| {
[
acc,
name.encoded_len()?,
if data.is_empty() {
4
} else {
data.encoded_len_prefixed()?
},
]
.checked_sum()
})
}

fn encode(&self, writer: &mut impl Writer) -> encoding::Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion ssh-key/src/certificate/unix_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl fmt::Debug for UnixTime {

#[cfg(test)]
mod tests {
use super::{UnixTime, MAX_SECS};
use super::{MAX_SECS, UnixTime};
use crate::Error;

#[test]
Expand Down
Loading