@@ -8,11 +8,32 @@ use anyhow::Result;
8
8
9
9
use sequoia_openpgp:: {
10
10
parse:: { stream:: * , Parse } ,
11
- policy, Cert , KeyHandle ,
11
+ policy:: { HashAlgoSecurity , StandardPolicy } ,
12
+ types:: HashAlgorithm ,
13
+ Cert , KeyHandle ,
12
14
} ;
13
15
14
16
use crate :: config:: PgpPublicKey ;
15
17
18
+ pub ( crate ) fn sequoia_policy ( ) -> StandardPolicy < ' static > {
19
+ let mut policy = StandardPolicy :: new ( ) ;
20
+
21
+ // The builtin Rust signature key uses SHA-1 for its own signature, even though the individual
22
+ // signatures generated by it nowadays use SHA-512. Sequoia added a cutoff date for SHA1,
23
+ // 2023-02-01, which caused warnings to be displayed to rustup users from that day onwards.
24
+ //
25
+ // To keep supporting the Rust signature key, we allow the SHA-1 algorithm in rustup without a
26
+ // cutoff date when verifying the signature key bindings. SHA-1 data signatures are still
27
+ // disallowed.
28
+ policy. reject_hash_property_at (
29
+ HashAlgorithm :: SHA1 ,
30
+ HashAlgoSecurity :: SecondPreImageResistance ,
31
+ None ,
32
+ ) ;
33
+
34
+ policy
35
+ }
36
+
16
37
/// Returns the index of the cert in `certs` that verifies a
17
38
/// signature.
18
39
///
@@ -26,7 +47,8 @@ pub(crate) fn verify_signature<T: Read + Send + Sync>(
26
47
signature : & str ,
27
48
certs : & [ PgpPublicKey ] ,
28
49
) -> Result < Option < usize > > {
29
- let p = policy:: StandardPolicy :: new ( ) ;
50
+ let p = sequoia_policy ( ) ;
51
+
30
52
let helper = Helper :: new ( certs) ;
31
53
let mut v = DetachedVerifierBuilder :: from_reader ( signature. as_bytes ( ) ) ?
32
54
. with_policy ( & p, None , helper) ?;
0 commit comments