diff --git a/ecdsa/src/der.rs b/ecdsa/src/der.rs index 2b1373c..5684e76 100644 --- a/ecdsa/src/der.rs +++ b/ecdsa/src/der.rs @@ -222,7 +222,6 @@ where } #[cfg(feature = "alloc")] -#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] impl From> for Box<[u8]> where C: PrimeCurve, @@ -235,7 +234,6 @@ where } #[cfg(feature = "alloc")] -#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] impl SignatureEncoding for Signature where C: PrimeCurve, @@ -250,7 +248,6 @@ where } #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl Serialize for Signature where C: PrimeCurve, @@ -266,7 +263,6 @@ where } #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl<'de, C> Deserialize<'de> for Signature where C: PrimeCurve, diff --git a/ecdsa/src/dev.rs b/ecdsa/src/dev.rs index ce00c7f..dd7ad02 100644 --- a/ecdsa/src/dev.rs +++ b/ecdsa/src/dev.rs @@ -29,7 +29,6 @@ pub struct TestVector { /// Define ECDSA signing test. #[macro_export] -#[cfg_attr(docsrs, doc(cfg(feature = "dev")))] macro_rules! new_signing_test { ($curve:path, $vectors:expr) => { use $crate::{ @@ -65,7 +64,6 @@ macro_rules! new_signing_test { /// Define ECDSA verification test. #[macro_export] -#[cfg_attr(docsrs, doc(cfg(feature = "dev")))] macro_rules! new_verification_test { ($curve:path, $vectors:expr) => { use $crate::{ @@ -133,7 +131,6 @@ macro_rules! new_verification_test { /// Define a Wycheproof verification test. #[macro_export] -#[cfg_attr(docsrs, doc(cfg(feature = "dev")))] macro_rules! new_wycheproof_test { ($name:ident, $test_name: expr, $curve:path) => { use $crate::{elliptic_curve::sec1::EncodedPoint, signature::Verifier, Signature}; diff --git a/ecdsa/src/hazmat.rs b/ecdsa/src/hazmat.rs index 940a94f..ed1b447 100644 --- a/ecdsa/src/hazmat.rs +++ b/ecdsa/src/hazmat.rs @@ -50,7 +50,6 @@ use elliptic_curve::ScalarCore; /// This trait is intended to be implemented on a type with access to the /// secret scalar via `&self`, such as particular curve's `Scalar` type. #[cfg(feature = "arithmetic")] -#[cfg_attr(docsrs, doc(cfg(feature = "arithmetic")))] pub trait SignPrimitive: Field + Into> + Reduce + Sized where C: PrimeCurve + ProjectiveArithmetic + ScalarArithmetic, @@ -113,7 +112,6 @@ where /// /// [RFC6979]: https://datatracker.ietf.org/doc/html/rfc6979 #[cfg(all(feature = "rfc6979"))] - #[cfg_attr(docsrs, doc(cfg(feature = "rfc6979")))] fn try_sign_prehashed_rfc6979( &self, z: FieldBytes, @@ -135,7 +133,6 @@ where /// /// [RFC6979]: https://datatracker.ietf.org/doc/html/rfc6979 #[cfg(all(feature = "rfc6979"))] - #[cfg_attr(docsrs, doc(cfg(feature = "rfc6979")))] fn try_sign_digest_rfc6979( &self, msg_digest: D, @@ -156,7 +153,6 @@ where /// the affine point represeting the public key via `&self`, such as a /// particular curve's `AffinePoint` type. #[cfg(feature = "arithmetic")] -#[cfg_attr(docsrs, doc(cfg(feature = "arithmetic")))] pub trait VerifyPrimitive: AffineXCoordinate + Copy + Sized where C: PrimeCurve + AffineArithmetic + ProjectiveArithmetic, @@ -194,7 +190,6 @@ where /// Verify message digest against the provided signature. #[cfg(feature = "digest")] - #[cfg_attr(docsrs, doc(cfg(feature = "digest")))] fn verify_digest(&self, msg_digest: D, sig: &Signature) -> Result<()> where D: FixedOutput>, @@ -214,7 +209,6 @@ where /// /// [1]: https://github.com/RustCrypto/traits/tree/master/signature/derive #[cfg(feature = "digest")] -#[cfg_attr(docsrs, doc(cfg(feature = "digest")))] pub trait DigestPrimitive: PrimeCurve { /// Preferred digest to use when computing ECDSA signatures for this /// elliptic curve. This is typically a member of the SHA-2 family. diff --git a/ecdsa/src/lib.rs b/ecdsa/src/lib.rs index d7d7325..3a44022 100644 --- a/ecdsa/src/lib.rs +++ b/ecdsa/src/lib.rs @@ -1,5 +1,5 @@ #![no_std] -#![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![doc = include_str!("../README.md")] #![doc( html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg", @@ -60,20 +60,13 @@ extern crate alloc; mod recovery; #[cfg(feature = "der")] -#[cfg_attr(docsrs, doc(cfg(feature = "der")))] pub mod der; - #[cfg(feature = "dev")] -#[cfg_attr(docsrs, doc(cfg(feature = "dev")))] pub mod dev; - #[cfg(feature = "hazmat")] -#[cfg_attr(docsrs, doc(cfg(feature = "hazmat")))] pub mod hazmat; - #[cfg(feature = "signing")] mod signing; - #[cfg(feature = "verifying")] mod verifying; @@ -86,11 +79,8 @@ pub use elliptic_curve::{self, sec1::EncodedPoint, PrimeCurve}; pub use signature::{self, Error, Result, SignatureEncoding}; #[cfg(feature = "signing")] -#[cfg_attr(docsrs, doc(cfg(feature = "signing")))] pub use crate::signing::SigningKey; - #[cfg(feature = "verifying")] -#[cfg_attr(docsrs, doc(cfg(feature = "verifying")))] pub use crate::verifying::VerifyingKey; use core::{ @@ -156,7 +146,6 @@ where { /// Parse a signature from ASN.1 DER #[cfg(feature = "der")] - #[cfg_attr(docsrs, doc(cfg(feature = "der")))] pub fn from_der(bytes: &[u8]) -> Result where der::MaxSize: ArrayLength, @@ -187,7 +176,6 @@ where /// Serialize this signature as ASN.1 DER. #[cfg(feature = "der")] - #[cfg_attr(docsrs, doc(cfg(feature = "der")))] pub fn to_der(&self) -> der::Signature where der::MaxSize: ArrayLength, @@ -199,14 +187,12 @@ where /// Convert this signature into a byte vector. #[cfg(feature = "alloc")] - #[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] pub fn to_vec(&self) -> Vec { self.to_bytes().to_vec() } } #[cfg(feature = "arithmetic")] -#[cfg_attr(docsrs, doc(cfg(feature = "arithmetic")))] impl Signature where C: PrimeCurve + ScalarArithmetic, @@ -347,7 +333,6 @@ where } #[cfg(feature = "arithmetic")] -#[cfg_attr(docsrs, doc(cfg(feature = "arithmetic")))] impl str::FromStr for Signature where C: PrimeCurve + ScalarArithmetic, @@ -384,7 +369,6 @@ where } #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl Serialize for Signature where C: PrimeCurve, @@ -399,7 +383,6 @@ where } #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl<'de, C> Deserialize<'de> for Signature where C: PrimeCurve, diff --git a/ecdsa/src/recovery.rs b/ecdsa/src/recovery.rs index c7fee32..01d099d 100644 --- a/ecdsa/src/recovery.rs +++ b/ecdsa/src/recovery.rs @@ -72,7 +72,6 @@ impl RecoveryId { } #[cfg(feature = "verifying")] -#[cfg_attr(docsrs, doc(cfg(feature = "verifying")))] impl RecoveryId { /// Given a public key, message, and signature, use trial recovery /// to determine if a suitable recovery ID exists, or return an error @@ -158,7 +157,6 @@ impl From for u8 { } #[cfg(feature = "verifying")] -#[cfg_attr(docsrs, doc(cfg(feature = "verifying")))] impl VerifyingKey where C: PrimeCurve + ProjectiveArithmetic, diff --git a/ecdsa/src/signing.rs b/ecdsa/src/signing.rs index b20f977..959dbe0 100644 --- a/ecdsa/src/signing.rs +++ b/ecdsa/src/signing.rs @@ -1,6 +1,4 @@ -//! ECDSA signing key. - -// TODO(tarcieri): support for hardware crypto accelerators +//! ECDSA signing: producing signatures using a [`SigningKey`]. use crate::{ hazmat::{bits2field, DigestPrimitive, SignPrimitive}, @@ -46,7 +44,6 @@ use {crate::VerifyingKey, elliptic_curve::PublicKey, signature::KeypairRef}; /// Requires an [`elliptic_curve::ProjectiveArithmetic`] impl on the curve, and a /// [`SignPrimitive`] impl on its associated `Scalar` type. #[derive(Clone)] -#[cfg_attr(docsrs, doc(cfg(feature = "signing")))] pub struct SigningKey where C: PrimeCurve + ProjectiveArithmetic, @@ -97,7 +94,6 @@ where /// Get the [`VerifyingKey`] which corresponds to this [`SigningKey`]. #[cfg(feature = "verifying")] - #[cfg_attr(docsrs, doc(cfg(feature = "verifying")))] pub fn verifying_key(&self) -> &VerifyingKey { &self.verifying_key } @@ -196,7 +192,6 @@ where } #[cfg(feature = "der")] -#[cfg_attr(docsrs, doc(cfg(feature = "der")))] impl PrehashSigner> for SigningKey where C: PrimeCurve + ProjectiveArithmetic + DigestPrimitive, @@ -213,7 +208,6 @@ where } #[cfg(feature = "der")] -#[cfg_attr(docsrs, doc(cfg(feature = "der")))] impl Signer> for SigningKey where Self: DigestSigner>, @@ -229,7 +223,6 @@ where } #[cfg(feature = "der")] -#[cfg_attr(docsrs, doc(cfg(feature = "der")))] impl RandomizedDigestSigner> for SigningKey where C: PrimeCurve + ProjectiveArithmetic, @@ -251,7 +244,6 @@ where } #[cfg(feature = "der")] -#[cfg_attr(docsrs, doc(cfg(feature = "der")))] impl RandomizedSigner> for SigningKey where Self: RandomizedDigestSigner>, @@ -275,7 +267,6 @@ where // #[cfg(feature = "verifying")] -#[cfg_attr(docsrs, doc(cfg(feature = "verifying")))] impl AsRef> for SigningKey where C: PrimeCurve + ProjectiveArithmetic, @@ -449,7 +440,6 @@ where } #[cfg(feature = "verifying")] -#[cfg_attr(docsrs, doc(cfg(feature = "verifying")))] impl KeypairRef for SigningKey where C: PrimeCurve + ProjectiveArithmetic, @@ -460,7 +450,6 @@ where } #[cfg(feature = "pkcs8")] -#[cfg_attr(docsrs, doc(cfg(feature = "pkcs8")))] impl TryFrom> for SigningKey where C: PrimeCurve + AssociatedOid + ProjectiveArithmetic, @@ -477,7 +466,6 @@ where } #[cfg(feature = "pem")] -#[cfg_attr(docsrs, doc(cfg(feature = "pem")))] impl EncodePrivateKey for SigningKey where C: AssociatedOid + PrimeCurve + ProjectiveArithmetic, @@ -492,7 +480,6 @@ where } #[cfg(feature = "pem")] -#[cfg_attr(docsrs, doc(cfg(feature = "pem")))] impl FromStr for SigningKey where C: PrimeCurve + AssociatedOid + ProjectiveArithmetic, @@ -509,7 +496,6 @@ where } #[cfg(feature = "pkcs8")] -#[cfg_attr(docsrs, doc(cfg(feature = "pkcs8")))] impl DecodePrivateKey for SigningKey where C: PrimeCurve + AssociatedOid + ProjectiveArithmetic, diff --git a/ecdsa/src/verifying.rs b/ecdsa/src/verifying.rs index 1683d65..436b190 100644 --- a/ecdsa/src/verifying.rs +++ b/ecdsa/src/verifying.rs @@ -1,4 +1,4 @@ -//! ECDSA verification key. +//! ECDSA verifying: checking signatures are authentic using a [`VerifyingKey`]. use crate::{ hazmat::{bits2field, DigestPrimitive, VerifyPrimitive}, @@ -30,7 +30,6 @@ use elliptic_curve::pkcs8::EncodePublicKey; use core::str::FromStr; #[cfg(all(feature = "pem", feature = "serde"))] -#[cfg_attr(docsrs, doc(cfg(all(feature = "pem", feature = "serde"))))] use serdect::serde::{de, ser, Deserialize, Serialize}; /// ECDSA verification key (i.e. public key). Generic over elliptic curves. @@ -46,7 +45,6 @@ use serdect::serde::{de, ser, Deserialize, Serialize}; /// /// The serialization leverages the encoding used by the [`PublicKey`] type, /// which is a binary-oriented ASN.1 DER encoding. -#[cfg_attr(docsrs, doc(cfg(feature = "verifying")))] #[derive(Clone, Debug)] pub struct VerifyingKey where @@ -141,7 +139,6 @@ where } #[cfg(feature = "der")] -#[cfg_attr(docsrs, doc(cfg(feature = "der")))] impl DigestVerifier> for VerifyingKey where C: PrimeCurve + ProjectiveArithmetic, @@ -159,7 +156,6 @@ where } #[cfg(feature = "der")] -#[cfg_attr(docsrs, doc(cfg(feature = "der")))] impl PrehashVerifier> for VerifyingKey where C: PrimeCurve + ProjectiveArithmetic + DigestPrimitive, @@ -176,7 +172,6 @@ where } #[cfg(feature = "der")] -#[cfg_attr(docsrs, doc(cfg(feature = "der")))] impl Verifier> for VerifyingKey where C: PrimeCurve + ProjectiveArithmetic + DigestPrimitive, @@ -304,7 +299,6 @@ where } #[cfg(feature = "pkcs8")] -#[cfg_attr(docsrs, doc(cfg(feature = "pkcs8")))] impl TryFrom> for VerifyingKey where C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression, @@ -319,7 +313,6 @@ where } #[cfg(feature = "pkcs8")] -#[cfg_attr(docsrs, doc(cfg(feature = "pkcs8")))] impl DecodePublicKey for VerifyingKey where C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression, @@ -329,7 +322,6 @@ where } #[cfg(feature = "pem")] -#[cfg_attr(docsrs, doc(cfg(feature = "pem")))] impl EncodePublicKey for VerifyingKey where C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression, @@ -342,7 +334,6 @@ where } #[cfg(feature = "pem")] -#[cfg_attr(docsrs, doc(cfg(feature = "pem")))] impl FromStr for VerifyingKey where C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression, @@ -357,7 +348,6 @@ where } #[cfg(all(feature = "pem", feature = "serde"))] -#[cfg_attr(docsrs, doc(cfg(all(feature = "pem", feature = "serde"))))] impl Serialize for VerifyingKey where C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression, @@ -373,7 +363,6 @@ where } #[cfg(all(feature = "pem", feature = "serde"))] -#[cfg_attr(docsrs, doc(cfg(all(feature = "pem", feature = "serde"))))] impl<'de, C> Deserialize<'de> for VerifyingKey where C: PrimeCurve + AssociatedOid + ProjectiveArithmetic + PointCompression, diff --git a/ed25519/src/lib.rs b/ed25519/src/lib.rs index 8e64f80..eb489cf 100644 --- a/ed25519/src/lib.rs +++ b/ed25519/src/lib.rs @@ -1,5 +1,5 @@ #![no_std] -#![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![doc = include_str!("../README.md")] #![doc(html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")] #![allow(non_snake_case)] @@ -261,7 +261,6 @@ extern crate alloc; #[cfg(feature = "pkcs8")] -#[cfg_attr(docsrs, doc(cfg(feature = "pkcs8")))] pub mod pkcs8; #[cfg(feature = "serde")] @@ -347,7 +346,6 @@ impl Signature { /// Convert this signature into a byte vector. #[cfg(feature = "alloc")] - #[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] pub fn to_vec(&self) -> Vec { self.to_bytes().to_vec() } diff --git a/ed25519/src/pkcs8.rs b/ed25519/src/pkcs8.rs index 1953f8d..4a7e83c 100644 --- a/ed25519/src/pkcs8.rs +++ b/ed25519/src/pkcs8.rs @@ -121,7 +121,6 @@ impl Drop for KeypairBytes { } #[cfg(feature = "alloc")] -#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] impl EncodePrivateKey for KeypairBytes { fn to_pkcs8_der(&self) -> Result { // Serialize private key as nested OCTET STRING @@ -198,7 +197,6 @@ impl fmt::Debug for KeypairBytes { } #[cfg(feature = "pem")] -#[cfg_attr(docsrs, doc(cfg(feature = "pem")))] impl str::FromStr for KeypairBytes { type Err = Error; @@ -245,7 +243,6 @@ impl AsRef<[u8; Self::BYTE_SIZE]> for PublicKeyBytes { impl DecodePublicKey for PublicKeyBytes {} #[cfg(feature = "alloc")] -#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] impl EncodePublicKey for PublicKeyBytes { fn to_public_key_der(&self) -> pkcs8::spki::Result { pkcs8::SubjectPublicKeyInfo { @@ -310,7 +307,6 @@ impl fmt::Debug for PublicKeyBytes { } #[cfg(feature = "pem")] -#[cfg_attr(docsrs, doc(cfg(feature = "pem")))] impl str::FromStr for PublicKeyBytes { type Err = pkcs8::spki::Error; @@ -320,7 +316,6 @@ impl str::FromStr for PublicKeyBytes { } #[cfg(feature = "pem")] -#[cfg_attr(docsrs, doc(cfg(feature = "pem")))] impl ToString for PublicKeyBytes { fn to_string(&self) -> String { self.to_public_key_pem(Default::default()) @@ -329,7 +324,6 @@ impl ToString for PublicKeyBytes { } #[cfg(feature = "pem")] -#[cfg_attr(docsrs, doc(cfg(feature = "pem")))] #[cfg(test)] mod tests { use super::{KeypairBytes, PublicKeyBytes}; diff --git a/ed25519/src/serde.rs b/ed25519/src/serde.rs index 614658a..2dbdc3f 100644 --- a/ed25519/src/serde.rs +++ b/ed25519/src/serde.rs @@ -7,7 +7,6 @@ use core::fmt; #[cfg(feature = "serde_bytes")] use serde_bytes_crate as serde_bytes; -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl Serialize for Signature { fn serialize(&self, serializer: S) -> Result { use ser::SerializeTuple; @@ -24,7 +23,6 @@ impl Serialize for Signature { // serde lacks support for deserializing arrays larger than 32-bytes // see: -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl<'de> Deserialize<'de> for Signature { fn deserialize>(deserializer: D) -> Result { struct ByteArrayVisitor; @@ -59,7 +57,6 @@ impl<'de> Deserialize<'de> for Signature { } #[cfg(feature = "serde_bytes")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde_bytes")))] impl serde_bytes::Serialize for Signature { fn serialize(&self, serializer: S) -> Result where @@ -70,7 +67,6 @@ impl serde_bytes::Serialize for Signature { } #[cfg(feature = "serde_bytes")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde_bytes")))] impl<'de> serde_bytes::Deserialize<'de> for Signature { fn deserialize(deserializer: D) -> Result where diff --git a/rfc6979/Cargo.toml b/rfc6979/Cargo.toml index 56a030c..087babf 100644 --- a/rfc6979/Cargo.toml +++ b/rfc6979/Cargo.toml @@ -21,7 +21,3 @@ zeroize = { version = "1", default-features = false } [dev-dependencies] sha2 = "0.10" - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = ["--cfg", "docsrs"] diff --git a/rfc6979/src/lib.rs b/rfc6979/src/lib.rs index 32df1e6..10e3a68 100644 --- a/rfc6979/src/lib.rs +++ b/rfc6979/src/lib.rs @@ -1,4 +1,11 @@ +#![no_std] #![doc = include_str!("../README.md")] +#![forbid(unsafe_code, clippy::unwrap_used)] +#![warn(missing_docs, rust_2018_idioms)] +#![doc( + html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg", + html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg" +)] //! ## Usage //! @@ -29,15 +36,6 @@ //! assert_eq!(&k.to_be_byte_array(), &RFC6979_EXPECTED_K.to_be_byte_array()); //! ``` -#![no_std] -#![cfg_attr(docsrs, feature(doc_cfg))] -#![forbid(unsafe_code, clippy::unwrap_used)] -#![warn(missing_docs, rust_2018_idioms)] -#![doc( - html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg", - html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg" -)] - use crypto_bigint::{ArrayEncoding, ByteArray, Integer}; use hmac::{ digest::{