Skip to content
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

Migrate to doc_auto_cfg #1370

Merged
merged 1 commit into from
Oct 31, 2023
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
1 change: 0 additions & 1 deletion aead/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pub use blobby;

/// Define AEAD test
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "dev")))]
macro_rules! new_test {
($name:ident, $test_name:expr, $cipher:ty $(,)?) => {
#[test]
Expand Down
13 changes: 1 addition & 12 deletions aead/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//! [RustCrypto/AEADs]: https://github.com/RustCrypto/AEADs

#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![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"
Expand All @@ -29,34 +29,27 @@ extern crate alloc;
extern crate std;

#[cfg(feature = "dev")]
#[cfg_attr(docsrs, doc(cfg(feature = "dev")))]
pub mod dev;

#[cfg(feature = "stream")]
#[cfg_attr(docsrs, doc(cfg(feature = "stream")))]
pub mod stream;

pub use crypto_common::{Key, KeyInit, KeySizeUser};
pub use generic_array::{self, typenum::consts};

#[cfg(feature = "arrayvec")]
#[cfg_attr(docsrs, doc(cfg(feature = "arrayvec")))]
pub use arrayvec;

#[cfg(feature = "bytes")]
#[cfg_attr(docsrs, doc(cfg(feature = "bytes")))]
pub use bytes;

#[cfg(feature = "getrandom")]
#[cfg_attr(docsrs, doc(cfg(feature = "getrandom")))]
pub use crypto_common::rand_core::OsRng;

#[cfg(feature = "heapless")]
#[cfg_attr(docsrs, doc(cfg(feature = "heapless")))]
pub use heapless;

#[cfg(feature = "rand_core")]
#[cfg_attr(docsrs, doc(cfg(feature = "rand_core")))]
pub use crypto_common::rand_core;

use core::fmt;
Expand Down Expand Up @@ -147,7 +140,6 @@ pub trait AeadCore {
///
/// [NIST SP 800-38D]: https://csrc.nist.gov/publications/detail/sp/800-38d/final
#[cfg(feature = "rand_core")]
#[cfg_attr(docsrs, doc(cfg(feature = "rand_core")))]
fn generate_nonce(mut rng: impl CryptoRng + RngCore) -> Nonce<Self>
where
Nonce<Self>: Default,
Expand All @@ -163,7 +155,6 @@ pub trait AeadCore {
/// This trait is intended for use with stateless AEAD algorithms. The
/// [`AeadMut`] trait provides a stateful interface.
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub trait Aead: AeadCore {
/// Encrypt the given plaintext payload, and return the resulting
/// ciphertext as a vector of bytes.
Expand Down Expand Up @@ -220,7 +211,6 @@ pub trait Aead: AeadCore {

/// Stateful Authenticated Encryption with Associated Data algorithm.
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub trait AeadMut: AeadCore {
/// Encrypt the given plaintext slice, and return the resulting ciphertext
/// as a vector of bytes.
Expand Down Expand Up @@ -480,7 +470,6 @@ impl<Alg: AeadInPlace> AeadMutInPlace for Alg {
/// If you don't care about AAD, you can pass a `&[u8]` as the payload to
/// `encrypt`/`decrypt` and it will automatically be coerced to this type.
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub struct Payload<'msg, 'aad> {
/// Message to be encrypted/decrypted
pub msg: &'msg [u8],
Expand Down
4 changes: 0 additions & 4 deletions aead/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ where
/// Encrypt the given plaintext payload, and return the resulting
/// ciphertext as a vector of bytes.
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
fn encrypt<'msg, 'aad>(
&self,
position: Self::Counter,
Expand All @@ -148,7 +147,6 @@ where
/// Decrypt the given ciphertext slice, and return the resulting plaintext
/// as a vector of bytes.
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
fn decrypt<'msg, 'aad>(
&self,
position: Self::Counter,
Expand Down Expand Up @@ -259,7 +257,6 @@ macro_rules! impl_stream_object {
#[doc = "the next AEAD message in this STREAM, returning the"]
#[doc = "result as a [`Vec`]."]
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub fn $next_method<'msg, 'aad>(
&mut self,
payload: impl Into<Payload<'msg, 'aad>>,
Expand Down Expand Up @@ -308,7 +305,6 @@ macro_rules! impl_stream_object {
#[doc = $obj_desc]
#[doc = "object in order to prevent further use."]
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub fn $last_method<'msg, 'aad>(
self,
payload: impl Into<Payload<'msg, 'aad>>,
Expand Down
16 changes: 0 additions & 16 deletions cipher/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ pub trait BlockEncrypt: BlockSizeUser + Sized {
///
/// Returns [`PadError`] if length of output buffer is not sufficient.
#[cfg(feature = "block-padding")]
#[cfg_attr(docsrs, doc(cfg(feature = "block-padding")))]
#[inline]
fn encrypt_padded_inout<'out, P: Padding<Self::BlockSize>>(
&self,
Expand All @@ -151,7 +150,6 @@ pub trait BlockEncrypt: BlockSizeUser + Sized {
///
/// Returns [`PadError`] if length of output buffer is not sufficient.
#[cfg(feature = "block-padding")]
#[cfg_attr(docsrs, doc(cfg(feature = "block-padding")))]
#[inline]
fn encrypt_padded<'a, P: Padding<Self::BlockSize>>(
&self,
Expand All @@ -166,7 +164,6 @@ pub trait BlockEncrypt: BlockSizeUser + Sized {
///
/// Returns [`PadError`] if length of output buffer is not sufficient.
#[cfg(feature = "block-padding")]
#[cfg_attr(docsrs, doc(cfg(feature = "block-padding")))]
#[inline]
fn encrypt_padded_b2b<'a, P: Padding<Self::BlockSize>>(
&self,
Expand All @@ -179,7 +176,6 @@ pub trait BlockEncrypt: BlockSizeUser + Sized {

/// Pad input and encrypt into a newly allocated Vec. Returns resulting ciphertext Vec.
#[cfg(all(feature = "block-padding", feature = "alloc"))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "block-padding", feature = "alloc"))))]
#[inline]
fn encrypt_padded_vec<P: Padding<Self::BlockSize>>(&self, msg: &[u8]) -> Vec<u8> {
let mut out = allocate_out_vec::<Self>(msg.len());
Expand Down Expand Up @@ -249,7 +245,6 @@ pub trait BlockDecrypt: BlockSizeUser {
/// Returns [`UnpadError`] if padding is malformed or if input length is
/// not multiple of `Self::BlockSize`.
#[cfg(feature = "block-padding")]
#[cfg_attr(docsrs, doc(cfg(feature = "block-padding")))]
#[inline]
fn decrypt_padded_inout<'out, P: Padding<Self::BlockSize>>(
&self,
Expand All @@ -268,7 +263,6 @@ pub trait BlockDecrypt: BlockSizeUser {
/// Returns [`UnpadError`] if padding is malformed or if input length is
/// not multiple of `Self::BlockSize`.
#[cfg(feature = "block-padding")]
#[cfg_attr(docsrs, doc(cfg(feature = "block-padding")))]
#[inline]
fn decrypt_padded<'a, P: Padding<Self::BlockSize>>(
&self,
Expand All @@ -283,7 +277,6 @@ pub trait BlockDecrypt: BlockSizeUser {
/// Returns [`UnpadError`] if padding is malformed or if input length is
/// not multiple of `Self::BlockSize`.
#[cfg(feature = "block-padding")]
#[cfg_attr(docsrs, doc(cfg(feature = "block-padding")))]
#[inline]
fn decrypt_padded_b2b<'a, P: Padding<Self::BlockSize>>(
&self,
Expand All @@ -305,7 +298,6 @@ pub trait BlockDecrypt: BlockSizeUser {
/// Returns [`UnpadError`] if padding is malformed or if input length is
/// not multiple of `Self::BlockSize`.
#[cfg(all(feature = "block-padding", feature = "alloc"))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "block-padding", feature = "alloc"))))]
#[inline]
fn decrypt_padded_vec<P: Padding<Self::BlockSize>>(
&self,
Expand Down Expand Up @@ -378,7 +370,6 @@ pub trait BlockEncryptMut: BlockSizeUser + Sized {
///
/// Returns [`PadError`] if length of output buffer is not sufficient.
#[cfg(feature = "block-padding")]
#[cfg_attr(docsrs, doc(cfg(feature = "block-padding")))]
#[inline]
fn encrypt_padded_inout_mut<'out, P: Padding<Self::BlockSize>>(
mut self,
Expand All @@ -396,7 +387,6 @@ pub trait BlockEncryptMut: BlockSizeUser + Sized {
///
/// Returns [`PadError`] if length of output buffer is not sufficient.
#[cfg(feature = "block-padding")]
#[cfg_attr(docsrs, doc(cfg(feature = "block-padding")))]
#[inline]
fn encrypt_padded_mut<P: Padding<Self::BlockSize>>(
self,
Expand All @@ -411,7 +401,6 @@ pub trait BlockEncryptMut: BlockSizeUser + Sized {
///
/// Returns [`PadError`] if length of output buffer is not sufficient.
#[cfg(feature = "block-padding")]
#[cfg_attr(docsrs, doc(cfg(feature = "block-padding")))]
#[inline]
fn encrypt_padded_b2b_mut<'a, P: Padding<Self::BlockSize>>(
self,
Expand All @@ -424,7 +413,6 @@ pub trait BlockEncryptMut: BlockSizeUser + Sized {

/// Pad input and encrypt into a newly allocated Vec. Returns resulting ciphertext Vec.
#[cfg(all(feature = "block-padding", feature = "alloc"))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "block-padding", feature = "alloc"))))]
#[inline]
fn encrypt_padded_vec_mut<P: Padding<Self::BlockSize>>(self, msg: &[u8]) -> Vec<u8> {
let mut out = allocate_out_vec::<Self>(msg.len());
Expand Down Expand Up @@ -498,7 +486,6 @@ pub trait BlockDecryptMut: BlockSizeUser + Sized {
/// Returns [`UnpadError`] if padding is malformed or if input length is
/// not multiple of `Self::BlockSize`.
#[cfg(feature = "block-padding")]
#[cfg_attr(docsrs, doc(cfg(feature = "block-padding")))]
#[inline]
fn decrypt_padded_inout_mut<'out, P: Padding<Self::BlockSize>>(
mut self,
Expand All @@ -517,7 +504,6 @@ pub trait BlockDecryptMut: BlockSizeUser + Sized {
/// Returns [`UnpadError`] if padding is malformed or if input length is
/// not multiple of `Self::BlockSize`.
#[cfg(feature = "block-padding")]
#[cfg_attr(docsrs, doc(cfg(feature = "block-padding")))]
#[inline]
fn decrypt_padded_mut<P: Padding<Self::BlockSize>>(
self,
Expand All @@ -532,7 +518,6 @@ pub trait BlockDecryptMut: BlockSizeUser + Sized {
/// Returns [`UnpadError`] if padding is malformed or if input length is
/// not multiple of `Self::BlockSize`.
#[cfg(feature = "block-padding")]
#[cfg_attr(docsrs, doc(cfg(feature = "block-padding")))]
#[inline]
fn decrypt_padded_b2b_mut<'a, P: Padding<Self::BlockSize>>(
self,
Expand All @@ -554,7 +539,6 @@ pub trait BlockDecryptMut: BlockSizeUser + Sized {
/// Returns [`UnpadError`] if padding is malformed or if input length is
/// not multiple of `Self::BlockSize`.
#[cfg(all(feature = "block-padding", feature = "alloc"))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "block-padding", feature = "alloc"))))]
#[inline]
fn decrypt_padded_vec_mut<P: Padding<Self::BlockSize>>(
self,
Expand Down
6 changes: 0 additions & 6 deletions cipher/src/dev/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub use blobby;

/// Define block cipher test
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "dev")))]
macro_rules! block_cipher_test {
($name:ident, $test_name:expr, $cipher:ty $(,)?) => {
#[test]
Expand Down Expand Up @@ -99,7 +98,6 @@ macro_rules! block_cipher_test {

/// Define block mode encryption test
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "dev")))]
macro_rules! block_mode_enc_test {
($name:ident, $test_name:expr, $cipher:ty $(,)?) => {
#[test]
Expand Down Expand Up @@ -158,7 +156,6 @@ macro_rules! block_mode_enc_test {

/// Define block mode decryption test
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "dev")))]
macro_rules! block_mode_dec_test {
($name:ident, $test_name:expr, $cipher:ty $(,)?) => {
#[test]
Expand Down Expand Up @@ -217,7 +214,6 @@ macro_rules! block_mode_dec_test {

/// Define `IvState` test
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "dev")))]
macro_rules! iv_state_test {
($name:ident, $cipher:ty, encrypt $(,)?) => {
$crate::iv_state_test!($name, $cipher, encrypt_blocks_mut);
Expand Down Expand Up @@ -266,7 +262,6 @@ macro_rules! iv_state_test {

/// Define block encryptor benchmark
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "dev")))]
macro_rules! block_encryptor_bench {
(Key: $cipher:ty, $block_name:ident, $blocks_name:ident $(,)? ) => {
$crate::block_encryptor_bench!(
Expand Down Expand Up @@ -328,7 +323,6 @@ macro_rules! block_encryptor_bench {

/// Define block decryptor benchmark
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "dev")))]
macro_rules! block_decryptor_bench {
(Key: $cipher:ty, $block_name:ident, $blocks_name:ident $(,)? ) => {
$crate::block_decryptor_bench!(
Expand Down
3 changes: 0 additions & 3 deletions cipher/src/dev/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

/// Test core functionality of synchronous stream cipher
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "dev")))]
macro_rules! stream_cipher_test {
($name:ident, $test_name:expr, $cipher:ty $(,)?) => {
#[test]
Expand Down Expand Up @@ -38,7 +37,6 @@ macro_rules! stream_cipher_test {

/// Test stream synchronous stream cipher seeking capabilities
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "dev")))]
macro_rules! stream_cipher_seek_test {
($name:ident, $cipher:ty) => {
#[test]
Expand Down Expand Up @@ -91,7 +89,6 @@ macro_rules! stream_cipher_seek_test {

/// Create stream cipher benchmarks
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "dev")))]
macro_rules! stream_cipher_bench {
(
$cipher:ty;
Expand Down
2 changes: 0 additions & 2 deletions cipher/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ impl fmt::Display for StreamCipherError {
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for StreamCipherError {}

/// The error type returned when a cipher position can not be represented
Expand All @@ -39,5 +38,4 @@ impl From<OverflowError> for StreamCipherError {
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for OverflowError {}
5 changes: 1 addition & 4 deletions cipher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! [3]: https://en.wikipedia.org/wiki/Stream_cipher

#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg",
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg"
Expand All @@ -23,15 +23,12 @@ extern crate alloc;
extern crate std;

#[cfg(feature = "rand_core")]
#[cfg_attr(docsrs, doc(cfg(feature = "rand_core")))]
pub use crypto_common::rand_core;

#[cfg(feature = "block-padding")]
#[cfg_attr(docsrs, doc(cfg(feature = "block-padding")))]
pub use inout::block_padding;

#[cfg(feature = "zeroize")]
#[cfg_attr(docsrs, doc(cfg(feature = "zeroize")))]
pub use zeroize;

#[cfg(feature = "dev")]
Expand Down
Loading