summaryrefslogtreecommitdiffstats
path: root/openpgp/src/packet/user_attribute.rs
diff options
context:
space:
mode:
Diffstat (limited to 'openpgp/src/packet/user_attribute.rs')
-rw-r--r--openpgp/src/packet/user_attribute.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/openpgp/src/packet/user_attribute.rs b/openpgp/src/packet/user_attribute.rs
index 851e3126..57d93e82 100644
--- a/openpgp/src/packet/user_attribute.rs
+++ b/openpgp/src/packet/user_attribute.rs
@@ -20,6 +20,7 @@ use crate::packet::{
header::BodyLength,
};
use crate::Packet;
+use crate::policy::HashAlgoSecurity;
use crate::serialize::Marshal;
use crate::serialize::MarshalInto;
@@ -74,6 +75,35 @@ impl UserAttribute {
})
}
+ /// The security requirements of the hash algorithm for
+ /// self-signatures.
+ ///
+ /// A cryptographic hash algorithm usually has [three security
+ /// properties]: pre-image resistance, second pre-image
+ /// resistance, and collision resistance. If an attacker can
+ /// influence the signed data, then the hash algorithm needs to
+ /// have both second pre-image resistance, and collision
+ /// resistance. If not, second pre-image resistance is
+ /// sufficient.
+ ///
+ /// [three security properties]: https://en.wikipedia.org/wiki/Cryptographic_hash_function#Properties
+ ///
+ /// In general, an attacker may be able to influence third-party
+ /// signatures. But direct key signatures, and binding signatures
+ /// are only over data fully determined by signer. And, an
+ /// attacker's control over self signatures over User IDs is
+ /// limited due to their structure.
+ ///
+ /// These observations can be used to extend the life of a hash
+ /// algorithm after its collision resistance has been partially
+ /// compromised, but not completely broken. For more details,
+ /// please refer to the documentation for [HashAlgoSecurity].
+ ///
+ /// [HashAlgoSecurity]: ../policy/enum.HashAlgoSecurity.html
+ pub fn hash_algo_security(&self) -> HashAlgoSecurity {
+ HashAlgoSecurity::CollisionResistance
+ }
+
/// Gets the user attribute packet's raw, unparsed value.
///
/// Most likely you will want to use [`subpackets()`] to iterate