ed448: apply and fix workspace-level lints (#1334)

Applies the workspace-level config added in #1323 to this crate and
fixes any failures.
This commit is contained in:
Tony Arcieri
2026-05-06 11:13:09 -06:00
committed by GitHub
parent 3f353f90ea
commit 668b85189c
9 changed files with 25 additions and 16 deletions
-1
View File
@@ -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"
+2 -2
View File
@@ -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.
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -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<E>(self, bytes: &[u8]) -> Result<Self::Value, E>
+3
View File
@@ -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
+1 -1
View File
@@ -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.
+7 -4
View File
@@ -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<Self> {
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);
+6 -2
View File
@@ -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
}
+4 -4
View File
@@ -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
/// <https://datatracker.ietf.org/doc/html/rfc8032#section-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]