From 2d3265302498ef84eaac286bb8e8747a11d321f1 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Wed, 16 Apr 2025 04:47:24 +0000 Subject: [PATCH 1/2] der: impl `Hash` for `SetOf` Fixes #1763 --- der/src/arrayvec.rs | 2 +- der/src/asn1/set_of.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/der/src/arrayvec.rs b/der/src/arrayvec.rs index 7391c9ae7..58cd83a97 100644 --- a/der/src/arrayvec.rs +++ b/der/src/arrayvec.rs @@ -5,7 +5,7 @@ use crate::{ErrorKind, Result}; /// Array-backed append-only vector type. -#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] +#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)] pub(crate) struct ArrayVec { /// Elements of the set. elements: [Option; N], diff --git a/der/src/asn1/set_of.rs b/der/src/asn1/set_of.rs index 6293bf7d0..c3c1581b8 100644 --- a/der/src/asn1/set_of.rs +++ b/der/src/asn1/set_of.rs @@ -25,7 +25,7 @@ use {alloc::vec::Vec, core::slice}; /// and does not depend on `alloc` support. // TODO(tarcieri): use `ArrayVec` when/if it's merged into `core` // See: https://github.com/rust-lang/rfcs/pull/2990 -#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] +#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)] pub struct SetOf where T: DerOrd, @@ -200,7 +200,7 @@ impl ExactSizeIterator for SetOfIter<'_, T> {} /// This type implements an append-only `SET OF` type which is heap-backed /// and depends on `alloc` support. #[cfg(feature = "alloc")] -#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] +#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)] pub struct SetOfVec where T: DerOrd, From be73d39d803555e7375b182c3e184920808c60a9 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Wed, 16 Apr 2025 04:47:24 +0000 Subject: [PATCH 2/2] x509-cert: impl `Hash` for `Name` Fixes #1763 --- x509-cert/src/attr.rs | 2 +- x509-cert/src/name.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x509-cert/src/attr.rs b/x509-cert/src/attr.rs index daa64628f..9cbabda5b 100644 --- a/x509-cert/src/attr.rs +++ b/x509-cert/src/attr.rs @@ -85,7 +85,7 @@ pub type Attributes = SetOfVec; /// /// [RFC 5280 Appendix A.1]: https://datatracker.ietf.org/doc/html/rfc5280#appendix-A.1 #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] -#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Sequence, ValueOrd)] +#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Sequence, ValueOrd, Hash)] #[allow(missing_docs)] pub struct AttributeTypeAndValue { pub oid: AttributeType, diff --git a/x509-cert/src/name.rs b/x509-cert/src/name.rs index de09156ae..fb97a1731 100644 --- a/x509-cert/src/name.rs +++ b/x509-cert/src/name.rs @@ -57,7 +57,7 @@ use der::{ /// [RFC 4514 Section 3]: https://www.rfc-editor.org/rfc/rfc4514#section-3 /// [RFC 5280 Section 4.1.2.4]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.4 #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] -#[derive(Clone, Debug, Default, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] pub struct Name(pub(crate) RdnSequence); impl Name { @@ -307,7 +307,7 @@ impl fmt::Display for Name { /// /// [RFC 5280 Section 4.1.2.4]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.4 #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] -#[derive(Clone, Debug, Default, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] pub struct RdnSequence(Vec); impl RdnSequence { @@ -437,7 +437,7 @@ pub type DistinguishedName = RdnSequence; /// /// [RFC 5280 Section 4.1.2.4]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.4 #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] -#[derive(Clone, Debug, Default, PartialEq, Eq)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] pub struct RelativeDistinguishedName(pub(crate) SetOfVec); impl RelativeDistinguishedName {