Skip to content

Commit 3ac3dc6

Browse files
authored
x509-cert: impl hash for name (#1764)
* der: impl `Hash` for `SetOf` Fixes #1763 * x509-cert: impl `Hash` for `Name` Fixes #1763
1 parent 58fb944 commit 3ac3dc6

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

der/src/arrayvec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use crate::{ErrorKind, Result};
66

77
/// Array-backed append-only vector type.
8-
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
8+
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)]
99
pub(crate) struct ArrayVec<T, const N: usize> {
1010
/// Elements of the set.
1111
elements: [Option<T>; N],

der/src/asn1/set_of.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use {alloc::vec::Vec, core::slice};
2525
/// and does not depend on `alloc` support.
2626
// TODO(tarcieri): use `ArrayVec` when/if it's merged into `core`
2727
// See: https://github.com/rust-lang/rfcs/pull/2990
28-
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
28+
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)]
2929
pub struct SetOf<T, const N: usize>
3030
where
3131
T: DerOrd,
@@ -200,7 +200,7 @@ impl<T> ExactSizeIterator for SetOfIter<'_, T> {}
200200
/// This type implements an append-only `SET OF` type which is heap-backed
201201
/// and depends on `alloc` support.
202202
#[cfg(feature = "alloc")]
203-
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
203+
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)]
204204
pub struct SetOfVec<T>
205205
where
206206
T: DerOrd,

x509-cert/src/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub type Attributes = SetOfVec<Attribute>;
8585
///
8686
/// [RFC 5280 Appendix A.1]: https://datatracker.ietf.org/doc/html/rfc5280#appendix-A.1
8787
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
88-
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Sequence, ValueOrd)]
88+
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Sequence, ValueOrd, Hash)]
8989
#[allow(missing_docs)]
9090
pub struct AttributeTypeAndValue {
9191
pub oid: AttributeType,

x509-cert/src/name.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use der::{
5757
/// [RFC 4514 Section 3]: https://www.rfc-editor.org/rfc/rfc4514#section-3
5858
/// [RFC 5280 Section 4.1.2.4]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.4
5959
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
60-
#[derive(Clone, Debug, Default, PartialEq, Eq)]
60+
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
6161
pub struct Name(pub(crate) RdnSequence);
6262

6363
impl Name {
@@ -307,7 +307,7 @@ impl fmt::Display for Name {
307307
///
308308
/// [RFC 5280 Section 4.1.2.4]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.4
309309
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
310-
#[derive(Clone, Debug, Default, PartialEq, Eq)]
310+
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
311311
pub struct RdnSequence(Vec<RelativeDistinguishedName>);
312312

313313
impl RdnSequence {
@@ -437,7 +437,7 @@ pub type DistinguishedName = RdnSequence;
437437
///
438438
/// [RFC 5280 Section 4.1.2.4]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.4
439439
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
440-
#[derive(Clone, Debug, Default, PartialEq, Eq)]
440+
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
441441
pub struct RelativeDistinguishedName(pub(crate) SetOfVec<AttributeTypeAndValue>);
442442

443443
impl RelativeDistinguishedName {

0 commit comments

Comments
 (0)