Skip to content

Commit 9bf8f8e

Browse files
authored
chacha20: rename serde1 feature to serde (#459)
1 parent 4ac5538 commit 9bf8f8e

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

chacha20/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ cipher = { version = "0.5.0-rc.1", features = ["dev"] }
3535
hex-literal = "1"
3636
proptest = "1"
3737
rand_chacha = "0.9"
38-
serde_json = "1.0" # Only to test serde1
38+
serde_json = "1.0" # Only to test serde
3939

4040
[features]
4141
default = ["cipher"]
4242
legacy = ["cipher"]
4343
rng = ["rand_core"]
44-
serde1 = ["serde"]
4544
xchacha = ["cipher"]
4645

4746
[package.metadata.docs.rs]

chacha20/src/rng.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rand_core::{
1313
block::{BlockRng, BlockRngCore, CryptoBlockRng},
1414
};
1515

16-
#[cfg(feature = "serde1")]
16+
#[cfg(feature = "serde")]
1717
use serde::{Deserialize, Deserializer, Serialize, Serializer};
1818

1919
#[cfg(feature = "zeroize")]
@@ -32,7 +32,7 @@ pub(crate) const BLOCK_WORDS: u8 = 16;
3232
/// The seed for ChaCha20. Implements ZeroizeOnDrop when the
3333
/// zeroize feature is enabled.
3434
#[derive(PartialEq, Eq, Default, Clone)]
35-
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
35+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
3636
pub struct Seed([u8; 32]);
3737

3838
impl AsRef<[u8; 32]> for Seed {
@@ -500,7 +500,7 @@ macro_rules! impl_chacha_rng {
500500

501501
impl Eq for $ChaChaXRng {}
502502

503-
#[cfg(feature = "serde1")]
503+
#[cfg(feature = "serde")]
504504
impl Serialize for $ChaChaXRng {
505505
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
506506
where
@@ -509,7 +509,7 @@ macro_rules! impl_chacha_rng {
509509
$abst::$ChaChaXRng::from(self).serialize(s)
510510
}
511511
}
512-
#[cfg(feature = "serde1")]
512+
#[cfg(feature = "serde")]
513513
impl<'de> Deserialize<'de> for $ChaChaXRng {
514514
fn deserialize<D>(d: D) -> Result<Self, D::Error>
515515
where
@@ -528,14 +528,14 @@ macro_rules! impl_chacha_rng {
528528
}
529529

530530
mod $abst {
531-
#[cfg(feature = "serde1")]
531+
#[cfg(feature = "serde")]
532532
use serde::{Deserialize, Serialize};
533533

534534
// The abstract state of a ChaCha stream, independent of implementation choices. The
535535
// comparison and serialization of this object is considered a semver-covered part of
536536
// the API.
537537
#[derive(Debug, PartialEq, Eq)]
538-
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
538+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
539539
pub(crate) struct $ChaChaXRng {
540540
seed: crate::rng::Seed,
541541
stream: u64,
@@ -661,12 +661,12 @@ pub(crate) mod tests {
661661
assert_eq!(rng.get_word_pos(), 8888);
662662
}
663663

664-
#[cfg(feature = "serde1")]
664+
#[cfg(feature = "serde")]
665665
use super::{ChaCha8Rng, ChaCha12Rng, ChaCha20Rng};
666666

667667
type ChaChaRng = ChaCha20Rng;
668668

669-
#[cfg(feature = "serde1")]
669+
#[cfg(feature = "serde")]
670670
#[test]
671671
fn test_chacha_serde_roundtrip() {
672672
let seed = [
@@ -704,7 +704,7 @@ pub(crate) mod tests {
704704
// However testing for equivalence of serialized data is difficult, and there shouldn't be any
705705
// reason we need to violate the stronger-than-needed condition, e.g. by changing the field
706706
// definition order.
707-
#[cfg(feature = "serde1")]
707+
#[cfg(feature = "serde")]
708708
#[test]
709709
fn test_chacha_serde_format_stability() {
710710
let j = r#"{"seed":[4,8,15,16,23,42,4,8,15,16,23,42,4,8,15,16,23,42,4,8,15,16,23,42,4,8,15,16,23,42,4,8],"stream":27182818284,"word_pos":314159265359}"#;

0 commit comments

Comments
 (0)