diff options
author | Neal H. Walfield <neal@pep.foundation> | 2022-10-31 20:38:02 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2022-11-15 19:46:48 +0100 |
commit | 095eed89ee4e6b4f924ff2f43aaadb5fd30c20a7 (patch) | |
tree | 8f04100e20aeb8209bfb2bf939f9d91cd97870a6 /openpgp/src/policy | |
parent | be2de85d31674b6790b2f02bdac9bf7e7b4810aa (diff) |
openpgp: Simplify using a good list with a StandardPolicy.
- To use a good list, we need to reject all options by default and
then only enable those on the good list.
- Add a mechanism to reject all options in a particular
category (hash algorithms, critical subpackets, asymmetric
algorithms, symmetric algorithms, AEAD algorithms, and packet
tags).
- See #941.
Diffstat (limited to 'openpgp/src/policy')
-rw-r--r-- | openpgp/src/policy/cutofflist.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/openpgp/src/policy/cutofflist.rs b/openpgp/src/policy/cutofflist.rs index d21d83a5..d745ae7d 100644 --- a/openpgp/src/policy/cutofflist.rs +++ b/openpgp/src/policy/cutofflist.rs @@ -120,7 +120,7 @@ impl<A> Default for CutoffList<A> { impl<A> CutoffList<A> { // Rejects all algorithms. - const fn reject_all() -> Self { + pub(super) const fn reject_all() -> Self { Self { cutoffs: VecOrSlice::empty(), _a: std::marker::PhantomData, @@ -192,6 +192,7 @@ macro_rules! a_cutoff_list { Custom(CutoffList<$algo>), } + #[allow(unused)] impl $name { const DEFAULTS : [ Option<Timestamp>; $values_count ] = $values; @@ -217,6 +218,15 @@ macro_rules! a_cutoff_list { self.force().set(a, cutoff) } + // Reset the cutoff list to its defaults. + fn defaults(&mut self) { + *self = Self::Default(); + } + + fn reject_all(&mut self) { + *self = Self::Custom(CutoffList::reject_all()); + } + fn cutoff(&self, a: $algo) -> Option<Timestamp> { use crate::policy::cutofflist::DEFAULT_POLICY; |