feat: fix external_sign rsa1024

This commit is contained in:
2025-05-01 00:27:27 +08:00
parent c270c2e369
commit 0ac9300262

View File

@@ -76,13 +76,16 @@ fn sign(sub_arg_matches: &ArgMatches) -> XResult<Vec<u8>> {
_ => return simple_error!("Invalid alg: {}", alg), _ => return simple_error!("Invalid alg: {}", alg),
}; };
if key.algorithm == AlgorithmId::Rsa1024 {
return simple_error!("Invalid algorithm: RSA1024");
}
let is_p256_mismatch = let is_p256_mismatch =
key.algorithm == AlgorithmId::EccP256 && jwt_algorithm != AlgorithmType::Es256; key.algorithm == AlgorithmId::EccP256 && jwt_algorithm != AlgorithmType::Es256;
let is_p384_mismatch = let is_p384_mismatch =
key.algorithm == AlgorithmId::EccP384 && jwt_algorithm != AlgorithmType::Es384; key.algorithm == AlgorithmId::EccP384 && jwt_algorithm != AlgorithmType::Es384;
let is_rsa = let is_rsa_mismatch =
key.algorithm == AlgorithmId::Rsa1024 || key.algorithm == AlgorithmId::Rsa2048; key.algorithm == AlgorithmId::Rsa2048 && jwt_algorithm != AlgorithmType::Rs256;
let is_rsa_mismatch = is_rsa && jwt_algorithm != AlgorithmType::Rs256;
if is_p256_mismatch || is_p384_mismatch || is_rsa_mismatch { if is_p256_mismatch || is_p384_mismatch || is_rsa_mismatch {
return simple_error!("Invalid algorithm: {} vs {}", key.algorithm.to_str(), alg); return simple_error!("Invalid algorithm: {} vs {}", key.algorithm.to_str(), alg);