Skip to content

Commit 7264a5b

Browse files
committed
crypto: remove unsupported ecdsa signature algorithms
Signed-off-by: Jiaqi Gao <[email protected]>
1 parent 4e19941 commit 7264a5b

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

src/crypto/src/lib.rs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -233,40 +233,21 @@ fn verify_signature_with_algorithm(
233233
signature: &[u8],
234234
signature_algorithm: &x509::AlgorithmIdentifier,
235235
) -> Result<()> {
236-
// Match against known signature algorithm OIDs
237-
let algorithm_oid = &signature_algorithm.algorithm;
238-
239-
// ECDSA with SHA-256: 1.2.840.10045.4.3.2
240-
const ECDSA_WITH_SHA256: &[u32] = &[1, 2, 840, 10045, 4, 3, 2];
241236
// ECDSA with SHA-384: 1.2.840.10045.4.3.3
242237
const ECDSA_WITH_SHA384: &[u32] = &[1, 2, 840, 10045, 4, 3, 3];
243-
// ECDSA with SHA-512: 1.2.840.10045.4.3.4
244-
const ECDSA_WITH_SHA512: &[u32] = &[1, 2, 840, 10045, 4, 3, 4];
245238

239+
// Match against known signature algorithm OIDs
240+
let algorithm_oid = &signature_algorithm.algorithm;
246241
let oid_arcs: Vec<u32> = algorithm_oid.arcs().collect();
247242

248243
match oid_arcs.as_slice() {
249-
ECDSA_WITH_SHA256 => ecdsa::ecdsa_verify_with_algorithm(
250-
public_key,
251-
message,
252-
signature,
253-
&ecdsa::ECDSA_P256_SHA256_ASN1,
254-
)
255-
.map_err(|_| Error::SignatureVerification),
256244
ECDSA_WITH_SHA384 => ecdsa::ecdsa_verify_with_algorithm(
257245
public_key,
258246
message,
259247
signature,
260248
&ecdsa::ECDSA_P384_SHA384_ASN1,
261249
)
262250
.map_err(|_| Error::SignatureVerification),
263-
ECDSA_WITH_SHA512 => ecdsa::ecdsa_verify_with_algorithm(
264-
public_key,
265-
message,
266-
signature,
267-
&ecdsa::ECDSA_P384_SHA384_ASN1,
268-
)
269-
.map_err(|_| Error::SignatureVerification),
270251
_ => {
271252
// Unsupported algorithm
272253
Err(Error::UnsupportedAlgorithm)

0 commit comments

Comments
 (0)