mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-31 05:28:09 -06:00
Fix non-exhaustive match in Windows signing path (#646)
* Fix non-exhaustive match in Windows signing path The PublicKey enum gained P521, BrainpoolP256, BrainpoolP384, BrainpoolP512, and Ed25519 variants, but the Windows-specific match statements in windows.rs were not updated, causing a compile error on Windows builds. Add wildcard arms that return a clean error for unsupported key types. * Windows store: a key type it can't sign with is Unsupported, not a crypto failure --------- Co-authored-by: Brandon Thomas <echelon@gmail.com>
This commit is contained in:
co-authored by
Brandon Thomas
parent
c110c579a2
commit
a016f88a90
@@ -31,6 +31,8 @@ impl ExternalKey for WindowsKey {
|
||||
PublicKey::P384(_) => p384::ecdsa::Signature::from_slice(&raw)
|
||||
.map(|s| s.to_der().as_bytes().to_vec())
|
||||
.map_err(|e| SignError::Crypto(format!("CNG returned an invalid P-384 signature: {e}"))),
|
||||
// `identities` lists only RSA, P-256 and P-384 store keys; anything else can't sign here.
|
||||
_ => Err(SignError::Unsupported("signing with this key type through the Windows certificate store".into())),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,6 +69,7 @@ pub fn identities() -> Result<Vec<DigitalId>, SignError> {
|
||||
PublicKey::Rsa { .. } => key.algorithm_group().is_ok_and(|a| a == AlgorithmGroup::Rsa),
|
||||
PublicKey::P256(_) => key.algorithm_group().is_ok_and(|a| a == AlgorithmGroup::Ecdsa) && key.bits().is_ok_and(|bits| bits == 256),
|
||||
PublicKey::P384(_) => key.algorithm_group().is_ok_and(|a| a == AlgorithmGroup::Ecdsa) && key.bits().is_ok_and(|bits| bits == 384),
|
||||
_ => false,
|
||||
};
|
||||
if !supported {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user