[Git][reproducible-builds/diffoscope][master] 2 commits: Correct identify signed PGP files; file(1) returns "data". (Closes:...

Chris Lamb gitlab at salsa.debian.org
Wed Aug 19 11:03:30 UTC 2020



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
86afc94f by Chris Lamb at 2020-08-19T11:54:28+01:00
Correct identify signed PGP files; file(1) returns "data". (Closes: reproducible-builds/diffoscope#211)

Signed-off-by: Chris Lamb <lamby at debian.org>

- - - - -
4e61d0ae by Chris Lamb at 2020-08-19T11:54:28+01:00
Move to our assert_diff help entirely in our PGP tests.

- - - - -


6 changed files:

- diffoscope/comparators/pgp.py
- tests/comparators/test_pgp.py
- + tests/data/pgp_signed_expected_diff
- + tests/data/test1.pgp-signed
- + tests/data/test2.pgp-signed
- tests/test_source.py


Changes:

=====================================
diffoscope/comparators/pgp.py
=====================================
@@ -44,6 +44,7 @@ class Pgpdump(Command):
 class PgpFile(File):
     DESCRIPTION = "PGP signed/encrypted messages"
     FILE_TYPE_RE = re.compile(r"^PGP message\b")
+    FALLBACK_FILE_TYPE_HEADER_PREFIX = b"\xa3\x01"
 
     def compare_details(self, other, source=None):
         return [


=====================================
tests/comparators/test_pgp.py
=====================================
@@ -21,12 +21,14 @@ import pytest
 
 from diffoscope.comparators.pgp import PgpFile, PgpSignature
 
-from ..utils.data import load_fixture, get_data
+from ..utils.data import load_fixture, assert_diff
 from ..utils.tools import skip_unless_tools_exist
 from ..utils.nonexisting import assert_non_existing
 
 pgp1 = load_fixture("test1.pgp")
 pgp2 = load_fixture("test2.pgp")
+signed1 = load_fixture("test1.pgp-signed")
+signed2 = load_fixture("test2.pgp-signed")
 signature1 = load_fixture("test1.asc")
 signature2 = load_fixture("test2.asc")
 
@@ -47,8 +49,7 @@ def differences(pgp1, pgp2):
 
 @skip_unless_tools_exist("pgpdump")
 def test_diff(differences):
-    expected_diff = get_data("pgp_expected_diff")
-    assert differences[0].unified_diff == expected_diff
+    assert_diff(differences[0], "pgp_expected_diff")
 
 
 @skip_unless_tools_exist("pgpdump")
@@ -64,6 +65,20 @@ def test_pgp_signature_identification(signature1, signature2):
 @skip_unless_tools_exist("pgpdump")
 def test_pgp_signature(signature1, signature2):
     difference = signature1.compare(signature2)
-    assert difference.unified_diff == get_data("pgp_signature_expected_diff")
+    assert_diff(difference, "pgp_signature_expected_diff")
     assert difference.details[0].source1 == "pgpdump"
     assert len(difference.details) == 1
+
+
+def test_signed_identification(signed1):
+    assert isinstance(signed1, PgpFile)
+
+
+ at pytest.fixture
+def signed_differences(signed1, signed2):
+    return signed1.compare(signed2).details
+
+
+ at skip_unless_tools_exist("pgpdump")
+def test_signed_diff(signed_differences):
+    assert_diff(signed_differences[0], "pgp_signed_expected_diff")


=====================================
tests/data/pgp_signed_expected_diff
=====================================
@@ -0,0 +1,30 @@
+@@ -5,24 +5,24 @@
+ 	Sig type - Signature of a binary document(0x00).
+ 	Hash alg - SHA256(hash 8)
+ 	Pub alg - RSA Encrypt or Sign(pub 1)
+ 	Key ID - 0x1E953E27D4311E58
+ 	Next packet - other than one pass signature
+ New: Literal Data Packet(tag 11)(7 bytes)
+ 	Format - binary
+-	Filename - a
+-	File modified time - Wed Aug 19 10:45:54 UTC 2020
++	Filename - b
++	File modified time - Wed Aug 19 10:45:57 UTC 2020
+ 	Literal - 
+ Old: Signature Packet(tag 2)(563 bytes)
+ 	Ver 4 - new
+ 	Sig type - Signature of a binary document(0x00).
+ 	Pub alg - RSA Encrypt or Sign(pub 1)
+ 	Hash alg - SHA256(hash 8)
+ 	Hashed Sub: issuer fingerprint(sub 33)(21 bytes)
+ 	 v4 -	Fingerprint - c2 fe 4b d2 71 c1 39 b8 6c 53 3e 46 1e 95 3e 27 d4 31 1e 58 
+ 	Hashed Sub: signature creation time(sub 2)(4 bytes)
+-		Time - Wed Aug 19 10:45:54 UTC 2020
++		Time - Wed Aug 19 10:45:57 UTC 2020
+ 	Sub: issuer key ID(sub 16)(8 bytes)
+ 		Key ID - 0x1E953E27D4311E58
+-	Hash left 2 bytes - 48 80 
+-	RSA m^d mod n(4094 bits) - 23 dc ce ae ac fb 75 90 03 23 97 03 8a d1 cd a6 3f bd 81 30 d8 8a 11 03 b8 35 20 88 ec 71 f3 02 e1 1e 31 05 db 1a b3 85 60 dd 42 e3 46 4d 6f f5 5e 85 c1 2a 5f 4c a9 da fa 6a 5b f8 19 04 1a 6c ec 98 f4 97 f7 ca ac 6e 4c 88 c6 10 7b 2c 6f 4a a9 2a c1 6e c0 61 10 92 7f 03 f5 82 f3 9e ad 39 34 a3 86 f1 45 67 8c e7 92 80 69 20 c5 b3 78 dd 28 bb a0 9a 83 e3 29 80 5b 6f 55 f7 1d bc d4 a3 80 48 8a a3 86 e3 ba 1c c1 44 ec 07 7c c9 d6 d6 06 bc 21 ff a6 fd 8f 5b 37 c6 78 7f 6c 96 64 dc 7e 78 6a e2 9d 01 75 57 79 0d d8 53 54 8d 17 c0 45 3a 5a 25 c8 6a b6 39 c4 94 da d9 dc 55 85 4f 5e 99 f8 57 23 aa e3 4e 7f 65 f9 fc b2 cc b7 ff 29 46 cc 78 6b ae 6d 85 70 78 8a eb fa ba 15 7e 40 e8 e0 93 0b be e9 fe b8 3b bd 49 1f ac cd 28 ca ba 68 e6 e9 48 41 f6 7c f7 47 23 36 5e a7 03 08 9b 7e 13 a2 d1 72 36 2c ad b5 74 64 52 31 ca 32 46 fc 82 08 84 ed 32 ae d3 ec d2 c3 71 bc 27 e8 59 5e 90 86 37 65 f0 0a a6 e2 46 bf 10 f2 b5 f0 42 11 09 eb e7 b3 88 ac 36 90 1e be 22 0a fe b0 ce de 2a 16 cf ea 80 2c 97 ba 1d b0 52 47 09 d5 7d 1b 18 2f 01 d4 02 b6 b1 e9 93 64 03 30 b8 67 2c 34 5a 4b eb 26 2e a9 d9 23 cf 9b b6 88 0b e4 7b f9 6e 0f d1 fa 01 82 80 e9 4f c5 ac 51 6d 4a 19 52 b5 a1 5f f7 7c 7b 90 c7 57 bc eb b2 8b b5 18 7e 01 20 6a 81 8b c6 f5 11 aa a4 6e 93 4e a5 23 fe 5e af c1 86 26 bf 29 31 09 09 c8 16 62 73 48 b4 1b d9 72 89 f4 4a 13 37 00 0f 29 c3 56 0b 99 01 57 33 f5 97 f7 91 18 f1 86 36 11 37 e5 be d7 e4 d7 6b 1d 16 e3 04 71 68 5a 5e f4 6c 44 af 44 47 b7 ac 71 48 25 10 82 1f 74 d8 ae bf e8 c4 37 a5 47 cc 11 ca 05 fa 6f d3 4e 06 d0 45 aa 
++	Hash left 2 bytes - c6 c2 
++	RSA m^d mod n(4092 bits) - 0d 37 12 58 c3 ad 4a 6a e1 92 7f 3a 30 66 3a de 5a 72 09 09 40 39 7e 59 77 83 3b 1d 14 b0 2f 1f d2 50 a1 5f 7a 73 36 fe 76 96 76 62 b8 14 17 c8 db b3 78 c1 2b e0 6a 4a c1 b0 57 8a 72 12 34 45 ec cf 04 dd 4f cd 8f 80 a4 94 9a c0 cc b2 65 c4 ba 37 1b 31 c4 ec b8 34 4b f5 02 17 19 d5 93 b6 71 06 9d 20 e9 ee 39 65 1f 1f f3 40 4b 68 18 34 3b 8c 3c 1e 14 08 61 a8 65 18 5e 72 9a 7f 04 84 7f 7b b8 d3 d3 0b 75 4b 71 1f b7 c8 c8 b5 8f 36 ba 9b d6 46 ef 0d 1d 56 de 37 9d 17 d0 31 33 c7 a1 39 d0 a6 2e 12 83 1b 95 f7 70 0e ea c6 ad 0a de 7b c1 11 05 9b c5 a8 10 a2 0b 62 2b d7 72 11 ef 8a e3 e6 1d e0 13 18 69 16 0a 42 1e 9f 58 76 cd 57 f1 b5 98 fa ae 76 8e ed 12 67 5d 19 69 cc b2 c2 b9 61 a9 8f 4a 9a 40 9e 57 86 45 60 a1 e9 88 b3 b2 aa 9e 4e 02 64 e4 15 29 50 a1 be 09 e2 e0 80 cd a4 b9 39 96 4f 1f 62 2f 95 58 73 c5 f8 38 4a 0e 6e fa 09 0f 04 7c 63 a8 ae 21 57 0a a4 0a a0 f9 99 dd df 16 8f de bc 62 04 77 1e 0c 37 37 1e 1f 3d 16 43 2b a8 29 5e be 3f 87 20 41 57 ee d9 4d 37 3b 65 ff eb 13 4b 50 b2 9c a8 cf 04 84 bf d2 64 be 03 78 fb f0 85 c9 26 73 f1 c6 c9 76 20 0c 94 29 07 3a 86 72 0a 6f 0a 86 7f 10 1e 9d 5f 16 e6 2d cf f3 61 8f de 2e 12 1d 6f e1 0e 00 5a 2e ef 13 ff d4 74 ff 72 af 9e 13 46 0a 37 65 e0 b9 1b f0 34 86 ac 89 d7 09 3c f9 99 dc c0 55 be 9a bb b1 d2 90 a5 37 82 75 b0 c5 3f b8 92 24 e6 ff a8 39 3b 87 e7 9b 8a 0b bc 9e 51 a8 1f 7a 51 4e 2f 03 7d f6 df 86 f4 4f 41 9e 9f b9 e2 31 a4 f0 a7 8f 9a df 84 76 b0 0e 28 ec f9 50 02 7d 63 2f dc 7c 31 ac 37 ff 72 2b ae 50 60 1d 6b 6d 61 ac 29 0c cb 3b d4 fa ed 4d 35 d6 ed 68 3b 
+ 		-> PKCS-1


=====================================
tests/data/test1.pgp-signed
=====================================
Binary files /dev/null and b/tests/data/test1.pgp-signed differ


=====================================
tests/data/test2.pgp-signed
=====================================
Binary files /dev/null and b/tests/data/test2.pgp-signed differ


=====================================
tests/test_source.py
=====================================
@@ -127,6 +127,7 @@ ALLOWED_TEST_FILES = {
     "test1.pcap",
     "test1.pdf",
     "test1.pgp",
+    "test1.pgp-signed",
     "test1.png",
     "test1.ppu",
     "test1.ps",
@@ -186,6 +187,7 @@ ALLOWED_TEST_FILES = {
     "test2.pcap",
     "test2.pdf",
     "test2.pgp",
+    "test2.pgp-signed",
     "test2.png",
     "test2.ppu",
     "test2.ps",



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/8cb0e85a67646b76b2f96969a0764a5574ce6b26...4e61d0ae10bf1927e8edbddb84782c98772c9a06

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/8cb0e85a67646b76b2f96969a0764a5574ce6b26...4e61d0ae10bf1927e8edbddb84782c98772c9a06
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20200819/3092ffd0/attachment.htm>


More information about the rb-commits mailing list