Skip to content

Commit

Permalink
Modify test for new certificate parser, use Oneline for subject/issue…
Browse files Browse the repository at this point in the history
…r and export the first error found
  • Loading branch information
HoundThe authored and PeterMatula committed Oct 25, 2021
1 parent 77182a0 commit 61cc543
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
11 changes: 1 addition & 10 deletions tools/fileinfo/bugs/certificate-segfault/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ def test_certificate_table_present(self):
# Malware - invalid signature
assert first_sig['signatureVerified'] == False
assert first_sig['warnings'][0] == "Signature digest doesn't match the file digest"
assert first_sig['warnings'][1] == "Signing cert is missing"
assert first_sig['warnings'][2] == "Signature isn't valid"

assert len(first_sig['allCertificates']) == 5

Expand All @@ -36,7 +34,6 @@ def test_certificate_table_present(self):
assert counter_sig['chain'][1]['sha256'] == '1C1983300C10FB262C0B2304B7BE15AABA10AE356EBBBB177583DC44774EB080'

assert counter_sig['warnings'][0] == "Couldn't decrypt the digest"
assert counter_sig['warnings'][1] == "Failed to verify the signature with counter-signature"


class Test2(Test):
Expand All @@ -56,8 +53,6 @@ def test_certificate_table_present(self):
# Malware - invalid signature
assert first_sig['signatureVerified'] == False
assert first_sig['warnings'][0] == "Signature digest doesn't match the file digest"
assert first_sig['warnings'][1] == "Signing cert is missing"
assert first_sig['warnings'][2] == "Signature isn't valid"

assert len(first_sig['allCertificates']) == 3

Expand Down Expand Up @@ -91,11 +86,7 @@ def test_certificate_table_present(self):
first_sig = self.fileinfo.output['digitalSignatures']['signatures'][0]

assert first_sig['signatureVerified'] == False
assert first_sig['warnings'][0] == "Wrong contentInfo contentType"
assert first_sig['warnings'][1] == "Couldn't get SpcSpOpusInfo"
assert first_sig['warnings'][2] == "Couldn't get SignerInfo message digest"
assert first_sig['warnings'][3] == "Missing correct SignerInfo contentType"
assert first_sig['warnings'][4] == "Signature isn't valid"
assert first_sig['warnings'][0] == "Couldn't get contentInfo"

assert first_sig['allCertificates'][0]['sha256'] == "A2219C3E44EE3748EAE12E5AA6C961AF47C185E25A8E59AFFD8FCAED641286CD"

Expand Down
2 changes: 1 addition & 1 deletion tools/fileinfo/bugs/sha1-hash-segfault/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ def test_has_certificate_table(self):
self.assertEqual(5, len(
self.fileinfo.output['digitalSignatures']['signatures'][0]['allCertificates']))

self.assertEqual('CN=Microsoft Corporation,O=Microsoft Corporation,L=Redmond,ST=Washington,C=US',
self.assertEqual('/C=US/ST=Washington/L=Redmond/O=Microsoft Corporation/CN=Microsoft Corporation',
self.fileinfo.output['digitalSignatures']['signatures'][0]['signer']['chain'][0]['subject'])
14 changes: 6 additions & 8 deletions tools/fileinfo/features/certificates-info/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ def test_certificates(self):
assert first_sig['signedDigest'] == 'F6B86E97AEB3E567F58901F799E18FC6F89CC92E'
assert first_sig['programName'] == "Broadband Download, Thunder in a Flash!"

assert first_sig['allCertificates'][0]['subject'] == "CN=Symantec Time Stamping Services CA - G2,O=Symantec Corporation,C=US"
assert first_sig['allCertificates'][0]['issuer'] == "CN=Thawte Timestamping CA,OU=Thawte Certification,O=Thawte,L=Durbanville,ST=Western Cape,C=ZA"
assert first_sig['allCertificates'][0]['subjectOneline'] == "/C=US/O=Symantec Corporation/CN=Symantec Time Stamping Services CA - G2"
assert first_sig['allCertificates'][0]['issuerOneline'] == "/C=ZA/ST=Western Cape/L=Durbanville/O=Thawte/OU=Thawte Certification/CN=Thawte Timestamping CA"
assert first_sig['allCertificates'][0]['subject'] == "/C=US/O=Symantec Corporation/CN=Symantec Time Stamping Services CA - G2"
assert first_sig['allCertificates'][0]['issuer'] == "/C=ZA/ST=Western Cape/L=Durbanville/O=Thawte/OU=Thawte Certification/CN=Thawte Timestamping CA"
assert first_sig['allCertificates'][0]['serialNumber'] == "7e:93:eb:fb:7c:c6:4e:59:ea:4b:9a:77:d4:06:fc:3b"
assert first_sig['allCertificates'][0]['publicKeyAlgorithm'] == "rsaEncryption"
assert first_sig['allCertificates'][0]['signatureAlgorithm'] == "sha1WithRSAEncryption"
Expand Down Expand Up @@ -137,8 +135,8 @@ def test_certificates(self):
assert first_sig['fileDigest'] == '3E7B33AB316770BD369BFADF5FB5354730C89991'
assert first_sig['signedDigest'] == '3E7B33AB316770BD369BFADF5FB5354730C89991'

assert first_sig['allCertificates'][0]['subject'] == "CN=Symantec Time Stamping Services CA - G2,O=Symantec Corporation,C=US"
assert first_sig['allCertificates'][0]['issuer'] == "CN=Thawte Timestamping CA,OU=Thawte Certification,O=Thawte,L=Durbanville,ST=Western Cape,C=ZA"
assert first_sig['allCertificates'][0]['subject'] == "/C=US/O=Symantec Corporation/CN=Symantec Time Stamping Services CA - G2"
assert first_sig['allCertificates'][0]['issuer'] == "/C=ZA/ST=Western Cape/L=Durbanville/O=Thawte/OU=Thawte Certification/CN=Thawte Timestamping CA"
assert first_sig['allCertificates'][0]['serialNumber'] == "7e:93:eb:fb:7c:c6:4e:59:ea:4b:9a:77:d4:06:fc:3b"
assert first_sig['allCertificates'][0]['publicKeyAlgorithm'] == "rsaEncryption"
assert first_sig['allCertificates'][0]['signatureAlgorithm'] == "sha1WithRSAEncryption"
Expand Down Expand Up @@ -537,7 +535,7 @@ def test_certificates(self):

second_sig_countersig = second_sig_signer['counterSigners'][0]
assert len(second_sig_countersig['warnings']) == 1
assert second_sig_countersig['warnings'][0] == "Couldn't parse signature"
assert second_sig_countersig['warnings'][0] == "Couldn't parse counter-signature"


class Test8(Test):
Expand Down Expand Up @@ -675,7 +673,7 @@ def test_certificates(self):

second_sig_countersig = second_sig_signer['counterSigners'][0]
assert len(second_sig_countersig['warnings']) == 1
assert second_sig_countersig['warnings'][0] == "Couldn't parse signature"
assert second_sig_countersig['warnings'][0] == "Couldn't parse counter-signature"


class TestEscaping(Test):
Expand Down

0 comments on commit 61cc543

Please sign in to comment.