Skip to content

Commit d9769b8

Browse files
committed
allow sha1 signing keys without a cutoff date
1 parent bb60b1e commit d9769b8

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/config.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ use std::str::FromStr;
77
use std::sync::Arc;
88

99
use anyhow::{anyhow, bail, Context, Result};
10-
use sequoia_openpgp::{parse::Parse, policy, Cert};
10+
use sequoia_openpgp::{parse::Parse, Cert};
1111
use serde::Deserialize;
1212
use thiserror::Error as ThisError;
1313

1414
use crate::cli::self_update::SelfUpdateMode;
1515
use crate::dist::download::DownloadCfg;
16+
use crate::dist::signatures::sequoia_policy;
1617
use crate::dist::{
1718
dist::{self, Profile},
1819
temp,
@@ -198,7 +199,8 @@ impl PgpPublicKey {
198199
let keyid = format_hex(cert.keyid().as_bytes(), "-", 4)?;
199200
let algo = cert.primary_key().pk_algo();
200201
let fpr = format_hex(cert.fingerprint().as_bytes(), " ", 2)?;
201-
let p = policy::StandardPolicy::new();
202+
let p = sequoia_policy();
203+
202204
let uid0 = cert
203205
.with_policy(&p, None)?
204206
.primary_userid()

src/dist/signatures.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,32 @@ use anyhow::Result;
88

99
use sequoia_openpgp::{
1010
parse::{stream::*, Parse},
11-
policy, Cert, KeyHandle,
11+
policy::{HashAlgoSecurity, StandardPolicy},
12+
types::HashAlgorithm,
13+
Cert, KeyHandle,
1214
};
1315

1416
use crate::config::PgpPublicKey;
1517

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+
1637
/// Returns the index of the cert in `certs` that verifies a
1738
/// signature.
1839
///
@@ -26,7 +47,8 @@ pub(crate) fn verify_signature<T: Read + Send + Sync>(
2647
signature: &str,
2748
certs: &[PgpPublicKey],
2849
) -> Result<Option<usize>> {
29-
let p = policy::StandardPolicy::new();
50+
let p = sequoia_policy();
51+
3052
let helper = Helper::new(certs);
3153
let mut v = DetachedVerifierBuilder::from_reader(signature.as_bytes())?
3254
.with_policy(&p, None, helper)?;

0 commit comments

Comments
 (0)