From 668b85189c5049fe9295487d1fe501e34484c9a0 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Wed, 6 May 2026 11:13:09 -0600 Subject: [PATCH] ed448: apply and fix workspace-level lints (#1334) Applies the workspace-level config added in #1323 to this crate and fixes any failures. --- Cargo.toml | 1 - ed25519/README.md | 4 ++-- ed25519/src/lib.rs | 2 +- ed25519/src/serde.rs | 2 +- ed448/Cargo.toml | 3 +++ ed448/README.md | 2 +- ed448/src/lib.rs | 11 +++++++---- ed448/src/pkcs8.rs | 8 ++++++-- ed448/tests/hex.rs | 8 ++++---- 9 files changed, 25 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0918086..0cf6f52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,6 @@ cast_possible_wrap = "warn" cast_precision_loss = "warn" cast_sign_loss = "warn" checked_conversions = "warn" -doc_markdown = "warn" from_iter_instead_of_collect = "warn" implicit_saturating_sub = "warn" manual_assert = "warn" diff --git a/ed25519/README.md b/ed25519/README.md index bc20559..b927a36 100644 --- a/ed25519/README.md +++ b/ed25519/README.md @@ -24,10 +24,10 @@ to be written abstractly in such a way that different signer/verifier providers can be plugged in, enabling support for using different Ed25519 implementations, including HSMs or Cloud KMS services. -## `SemVer` Policy +## SemVer Policy - All on-by-default features of this library are covered by `SemVer` -- MSRV is considered exempt from `SemVer` as noted above +- MSRV is considered exempt from SemVer as noted above - The `pkcs8` module is exempted as it uses a pre-1.0 dependency, however, breaking changes to this module will be accompanied by a minor version bump. diff --git a/ed25519/src/lib.rs b/ed25519/src/lib.rs index abbfb23..b9c11e3 100644 --- a/ed25519/src/lib.rs +++ b/ed25519/src/lib.rs @@ -316,7 +316,7 @@ pub struct Signature { } impl Signature { - /// Size of an encoded Ed25519 signature in bytes. + /// Size of an encoded Ed25519 signature in bytes (64-bytes). pub const BYTE_SIZE: usize = COMPONENT_SIZE * 2; /// Parse an Ed25519 signature from a byte slice. diff --git a/ed25519/src/serde.rs b/ed25519/src/serde.rs index 4d8d159..24c8fd3 100644 --- a/ed25519/src/serde.rs +++ b/ed25519/src/serde.rs @@ -48,7 +48,7 @@ impl<'de> serde_bytes::Deserialize<'de> for Signature { type Value = SignatureBytes; fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - formatter.write_str("bytestring of length 64") + formatter.write_str("bytestring of length 114") } fn visit_bytes(self, bytes: &[u8]) -> Result diff --git a/ed448/Cargo.toml b/ed448/Cargo.toml index 82bab02..6dfc86f 100644 --- a/ed448/Cargo.toml +++ b/ed448/Cargo.toml @@ -36,5 +36,8 @@ pem = ["alloc", "pkcs8/pem"] serde = ["dep:serdect"] serde_bytes = ["serde", "dep:serde_bytes"] +[lints] +workspace = true + [package.metadata.docs.rs] all-features = true diff --git a/ed448/README.md b/ed448/README.md index 8c2eb4b..0af3381 100644 --- a/ed448/README.md +++ b/ed448/README.md @@ -26,7 +26,7 @@ Ed448 implementations, including HSMs or Cloud KMS services. ## SemVer Policy -- All on-by-default features of this library are covered by SemVer +- All on-by-default features of this library are covered by `SemVer` - MSRV is considered exempt from SemVer as noted above - The `pkcs8` module is exempted as it uses a pre-1.0 dependency, however, breaking changes to this module will be accompanied by a minor version bump. diff --git a/ed448/src/lib.rs b/ed448/src/lib.rs index 3f26546..2060668 100644 --- a/ed448/src/lib.rs +++ b/ed448/src/lib.rs @@ -123,10 +123,11 @@ pub struct Signature { } impl Signature { - /// Size of an encoded Ed448 signature in bytes. + /// Size of an encoded Ed448 signature in bytes (114-bytes). pub const BYTE_SIZE: usize = COMPONENT_SIZE * 2; /// Parse an Ed448 signature from a byte slice. + #[must_use] pub fn from_bytes(bytes: &SignatureBytes) -> Self { let mut R = [0; COMPONENT_SIZE]; let mut s = [0; COMPONENT_SIZE]; @@ -140,9 +141,8 @@ impl Signature { /// Parse an Ed448 signature from a byte slice. /// - /// # Returns - /// - `Ok` on success - /// - `Err` if the input byte slice is not 64-bytes + /// # Errors + /// - Returns [`Error`] if the input byte slice is not 114-bytes. pub fn from_slice(bytes: &[u8]) -> signature::Result { SignatureBytes::try_from(bytes) .map(Into::into) @@ -150,16 +150,19 @@ impl Signature { } /// Bytes for the `R` component of a signature. + #[must_use] pub fn r_bytes(&self) -> &ComponentBytes { &self.R } /// Bytes for the `s` component of a signature. + #[must_use] pub fn s_bytes(&self) -> &ComponentBytes { &self.s } /// Return the inner byte array. + #[must_use] pub fn to_bytes(&self) -> SignatureBytes { let mut ret = [0u8; Self::BYTE_SIZE]; let (R, s) = ret.split_at_mut(COMPONENT_SIZE); diff --git a/ed448/src/pkcs8.rs b/ed448/src/pkcs8.rs index c5443be..bde4682 100644 --- a/ed448/src/pkcs8.rs +++ b/ed448/src/pkcs8.rs @@ -80,7 +80,10 @@ impl KeypairBytes { const BYTE_SIZE: usize = 114; /// Parse raw keypair from a 114-byte input. + #[must_use] + #[allow(clippy::missing_panics_doc, reason = "MSRV TODO")] pub fn from_bytes(bytes: &[u8; Self::BYTE_SIZE]) -> Self { + // TODO(tarcieri): use `as_chunks` when MSRV is 1.88 let (sk, pk) = bytes.split_at(Self::BYTE_SIZE / 2); Self { @@ -94,9 +97,9 @@ impl KeypairBytes { /// Serialize as a 114-byte keypair. /// /// # Returns - /// /// - `Some(bytes)` if the `public_key` is present. /// - `None` if the `public_key` is absent (i.e. `None`). + #[must_use] pub fn to_bytes(&self) -> Option<[u8; Self::BYTE_SIZE]> { if let Some(public_key) = &self.public_key { let mut result = [0u8; Self::BYTE_SIZE]; @@ -113,7 +116,7 @@ impl KeypairBytes { impl Drop for KeypairBytes { fn drop(&mut self) { #[cfg(feature = "zeroize")] - self.secret_key.zeroize() + self.secret_key.zeroize(); } } @@ -213,6 +216,7 @@ impl PublicKeyBytes { const BYTE_SIZE: usize = 57; /// Returns the raw bytes of the public key. + #[must_use] pub fn to_bytes(&self) -> [u8; Self::BYTE_SIZE] { self.0 } diff --git a/ed448/tests/hex.rs b/ed448/tests/hex.rs index 107a10c..bc63865 100644 --- a/ed448/tests/hex.rs +++ b/ed448/tests/hex.rs @@ -1,8 +1,8 @@ //! Hexadecimal display/serialization tests. +use core::str::FromStr; use ed448::Signature; use hex_literal::hex; -use std::str::FromStr; /// Test 1 signature from RFC 8032 ยง 7.4 /// @@ -23,7 +23,7 @@ fn display() { assert_eq!( sig.to_string(), "533A37F6BBE457251F023C0D88F976AE2DFB504A843E34D2074FD823D41A591F2B233F034F628281F2FD7A22DDD47D7828C59BD0A21BFD3980FF0D2028D4B18A9DF63E006C5D1C2D345B925D8DC00B4104852DB99AC5C7CDDA8530A113A0F4DBB61149F05A7363268C71D95808FF2E652600" - ) + ); } #[test] @@ -32,7 +32,7 @@ fn lower_hex() { assert_eq!( format!("{:x}", sig), "533a37f6bbe457251f023c0d88f976ae2dfb504a843e34d2074fd823d41a591f2b233f034f628281f2fd7a22ddd47d7828c59bd0a21bfd3980ff0d2028d4b18a9df63e006c5d1c2d345b925d8dc00b4104852db99ac5c7cdda8530a113a0f4dbb61149f05a7363268c71d95808ff2e652600" - ) + ); } #[test] @@ -41,7 +41,7 @@ fn upper_hex() { assert_eq!( format!("{:X}", sig), "533A37F6BBE457251F023C0D88F976AE2DFB504A843E34D2074FD823D41A591F2B233F034F628281F2FD7A22DDD47D7828C59BD0A21BFD3980FF0D2028D4B18A9DF63E006C5D1C2D345B925D8DC00B4104852DB99AC5C7CDDA8530A113A0F4DBB61149F05A7363268C71D95808FF2E652600" - ) + ); } #[test]