Skip to content

Commit

Permalink
fix: recognize more digest algorithms while parsing Authenticode sign…
Browse files Browse the repository at this point in the history
…atures

Some files (like 1e435fea9ced78bd31ae8320a894df290cdf8a262ba1b50c9b116caa26983145) identify the digest signature with OID 1.2.840.113549.1.1.5, which corresponds to `sha1WithRSAEncryption`.
  • Loading branch information
plusvic committed May 1, 2024
1 parent 9ed45fe commit dc49fcc
Show file tree
Hide file tree
Showing 4 changed files with 774 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions lib/src/modules/pe/authenticode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,32 +809,32 @@ fn verify_signer_info(si: &SignerInfo, certs: &[Certificate<'_>]) -> bool {

// Verify that the signature in `SignerInfo` is correct.
match oid_to_object_identifier(si.digest_algorithm.oid()) {
rfc5912::ID_MD_2 => {
rfc5912::ID_MD_2 | rfc5912::MD_2_WITH_RSA_ENCRYPTION => {
let mut md2 = Md2::default();
attrs_set.write_der(&mut md2).unwrap();
key.verify_digest::<Md2>(md2.finalize(), si.signature)
}
rfc5912::ID_MD_5 => {
rfc5912::ID_MD_5 | rfc5912::MD_5_WITH_RSA_ENCRYPTION => {
let mut md5 = Md5::default();
attrs_set.write_der(&mut md5).unwrap();
key.verify_digest::<Md5>(md5.finalize(), si.signature)
}
rfc5912::ID_SHA_1 => {
rfc5912::ID_SHA_1 | rfc5912::SHA_1_WITH_RSA_ENCRYPTION => {
let mut sha1 = Sha1::default();
attrs_set.write_der(&mut sha1).unwrap();
key.verify_digest::<Sha1>(sha1.finalize(), si.signature)
}
rfc5912::ID_SHA_256 => {
rfc5912::ID_SHA_256 | rfc5912::SHA_256_WITH_RSA_ENCRYPTION => {
let mut sha256 = Sha256::default();
attrs_set.write_der(&mut sha256).unwrap();
key.verify_digest::<Sha256>(sha256.finalize(), si.signature)
}
rfc5912::ID_SHA_384 => {
rfc5912::ID_SHA_384 | rfc5912::SHA_384_WITH_RSA_ENCRYPTION => {
let mut sha384 = Sha384::default();
attrs_set.write_der(&mut sha384).unwrap();
key.verify_digest::<Sha384>(sha384.finalize(), si.signature)
}
rfc5912::ID_SHA_512 => {
rfc5912::ID_SHA_512 | rfc5912::SHA_512_WITH_RSA_ENCRYPTION => {
let mut sha512 = Sha512::default();
attrs_set.write_der(&mut sha512).unwrap();
key.verify_digest::<Sha512>(sha512.finalize(), si.signature)
Expand Down
Binary file not shown.
Loading

0 comments on commit dc49fcc

Please sign in to comment.