Commit 05b3d02f authored by Chris Lamb's avatar Chris Lamb 💬

Add support for PGP files via pgpdump. (Closes: #859034)

Signed-off-by: Chris Lamb's avatarChris Lamb <lamby@debian.org>
parent 5dcb2a1c
......@@ -35,6 +35,7 @@ Build-Depends:
mono-utils <!nocheck>,
openssh-client <!nocheck>,
pdftk <!nocheck>,
pgpdump <!nocheck>,
poppler-utils <!nocheck>,
python-argcomplete,
python3-all,
......
......@@ -79,6 +79,7 @@ class ComparatorManager(object):
('openssh.PublicKeyFile',),
('gif.GifFile',),
('pcap.PcapFile',),
('pgp.PgpFile',),
)
_singleton = {}
......
# -*- coding: utf-8 -*-
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2017 Chris Lamb <lamby@debian.org>
#
# diffoscope is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# diffoscope is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import re
from diffoscope.tools import tool_required
from diffoscope.difference import Difference
from .utils.file import File
from .utils.command import Command
class Pgpdump(Command):
@tool_required('pgpdump')
def cmdline(self):
return (
'pgpdump',
'-i', # Dump integer packets
'-l', # Dump literal packets
'-m', # Dump marker packets
'-p', # Dump private packets
'-u', # Display UTC time
self.path,
)
class PgpFile(File):
RE_FILE_TYPE = re.compile(r'^PGP message\b')
def compare_details(self, other, source=None):
return [Difference.from_command(
Pgpdump,
self.path,
other.path,
source='pgpdump',
)]
......@@ -136,6 +136,9 @@ EXTERNAL_TOOLS = {
'debian': 'binutils-multiarch',
'arch': 'binutils',
},
'pgpdump': {
'debian': 'pgpdump',
},
'pdftk': {
'debian': 'pdftk',
'FreeBSD': 'pdftk',
......
# -*- coding: utf-8 -*-
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2017 Chris Lamb <lamby@debian.org>
#
# diffoscope is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# diffoscope is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import pytest
from diffoscope.comparators.pgp import PgpFile
from utils.data import load_fixture, get_data
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')
def test_identification(pgp1):
assert isinstance(pgp1, PgpFile)
def test_no_differences(pgp1):
difference = pgp1.compare(pgp1)
assert difference is None
@pytest.fixture
def differences(pgp1, pgp2):
return pgp1.compare(pgp2).details
@skip_unless_tools_exist('pgpdump')
def test_diff(differences):
expected_diff = get_data('pgp_expected_diff')
assert differences[0].unified_diff == expected_diff
@skip_unless_tools_exist('pgpdump')
def test_compare_non_existing(monkeypatch, pgp1):
assert_non_existing(monkeypatch, pgp1, has_null_source=False)
@@ -1,11 +1,11 @@
Old: Public-Key Encrypted Session Key Packet(tag 1)(526 bytes)
New version(3)
Key ID - 0xF956ADF011DACB92
Pub alg - ElGamal Encrypt-Only(pub 16)
- ElGamal g^k mod p(2047 bits) - 49 47 8d 67 f1 be 15 11 ea 42 bc c9 4b c4 56 4f 3c 36 9d c5 a7 ad d1 6e a4 3c 04 36 5e bb dc 05 bb 2a 5e ab 5d a0 8f 0f 2b 2a 29 23 be c5 3f 86 1b 55 51 7b ec ca 91 78 25 df 4c c2 6c d0 63 b0 b9 37 b9 ba 88 e3 ab af 88 b3 e4 57 ae 87 fe 49 7e 38 38 b0 4b 35 36 7b d6 68 ae 2a c8 f0 05 33 6d 07 db 04 b4 5e 6c 3c a5 d1 ca b1 6a 23 96 0f ae cf 2a 39 ce cd 4b 14 fe 34 81 9d 43 52 c9 f5 1c a1 a7 0f 50 89 54 5e 2e 2d 57 e7 87 35 38 60 53 f8 e9 29 36 db b0 57 5a 83 d1 5f 27 cc 59 78 4d 55 02 89 11 c0 e8 f9 ff 35 a9 1b ed 6f 2d f0 80 27 8f dd 6a 16 38 f9 07 b6 c7 af 18 37 44 bd 51 2a 58 88 74 20 94 8a 44 7e ad 87 1a d2 41 df a3 43 94 c8 99 54 a4 70 c9 68 e6 32 12 1e 91 22 a3 64 40 f5 37 45 b4 13 ad 25 65 23 26 b5 02 1c b8 22 66 b4 53 74 34 5f 7d 33 e1 28 d3 37 b6 64
- ElGamal m * y^k mod p(2046 bits) - 3f 37 5a ea 82 f1 f0 43 06 2f 4d 08 a2 0f ba 11 14 ab 7a b6 9a a6 ae 14 ca 7c a8 af eb 3c 57 b4 1b 02 09 a6 f5 b4 e5 44 34 bf b5 f3 a7 09 02 ec e0 6b 43 ec 9b 28 b2 fe 2b 58 26 8a 0c 04 c1 c7 2b b0 f2 90 b9 0e f6 14 40 63 31 b1 3f 6f ec 6e 5b 5c c8 b4 2e c6 58 73 3b 09 24 38 66 2e 99 cf 74 f1 40 07 af 09 91 fa 72 54 08 cc f7 9e 65 83 d3 5d 13 6f f6 96 be 9d 02 6a 37 b1 0a 3b c0 c8 58 60 4e fb f9 6d 39 c6 30 a8 70 db eb 3a 3d 42 b1 1d 2f 13 4a 0a 15 ef cc 10 1b 88 0d 7e a5 03 d6 67 18 29 5e 3c 99 23 25 22 f6 eb e9 81 3d 41 3d 28 08 66 93 f1 7e c9 5c 94 a3 eb 36 fd a4 fe 08 6b 51 10 7d 2b 87 a3 e4 61 f6 4d 3b a8 44 38 c9 31 33 8f cf d7 77 4b 16 6a 90 b0 bd fa db ca 8a ea af 96 3c 84 03 13 40 23 48 91 57 44 44 f0 21 b9 f5 6c 48 03 aa 0b 91 10 f5 be 5a 4a 5c fd
+ ElGamal g^k mod p(2048 bits) - 8a ea 29 42 74 8d 02 48 47 8c 17 27 59 49 0b 02 97 25 4b d5 11 39 fa 84 1d 45 f4 5f 96 9e fa 17 2f 5e 64 c8 7c 25 d4 8a d2 47 f4 4c fc a3 53 3c 86 95 5a 34 4c 74 15 ff 45 98 20 55 17 73 b1 5e a1 fa a9 14 bd 95 5b e4 93 d9 5f 5a 28 56 18 94 38 e8 43 57 fd 50 ff c2 39 94 6e a8 5c 41 47 5f 7b d1 16 01 e9 dc 32 3b 70 c4 ef 82 cd 4e d1 e3 22 d1 d9 75 1b b9 21 48 c2 71 cf d4 33 bf 7c 51 5a 5a 10 c8 7d cb c7 19 16 74 23 47 72 d0 d8 27 d5 17 04 83 72 a0 c7 83 4d 03 bc 5d c5 c0 9d 31 00 fe 2e 66 d7 e6 0d c2 1f ab 74 07 0e 25 cd 1a ff 7f a7 ae 2c 1d 78 cb ee 7d b0 08 63 f9 90 be 52 7a 78 4f 2a a6 b5 75 df 18 dc 92 bf f2 04 98 3e 42 33 93 d4 8f 4b bb 5e 63 3c 11 34 49 63 19 ec a5 0b 9a 25 23 3b fe bc 29 53 1b bd cf 59 2b 8d 20 a8 46 fa ed ec 19 11 b5 3e 2d a6 c2 bf f7
+ ElGamal m * y^k mod p(2044 bits) - 0c 48 0c 47 66 45 5c 02 1a 3b 8a 00 25 95 24 1e 7d 38 af 29 4a 0f 69 cb c9 c6 57 1b d2 6c 8d f8 d4 ac de 0f dc 84 4d 82 1b 72 b6 22 ea 5a 53 61 82 75 d3 52 52 39 6d 49 c9 72 2a 9f b0 90 59 26 eb 85 0b 9b 65 b1 1a 30 f9 35 5e 51 0d 45 77 e0 64 da 87 07 c6 fc 9f a2 0a 18 46 80 05 28 36 91 b2 a8 58 23 db 2b b1 50 35 51 31 29 68 14 87 d7 b5 a8 49 6e ec b5 eb 3f 6a 65 de bb c0 90 6d 3f 86 85 d5 39 3b 48 43 be 85 84 12 25 4f 74 14 2d db 7b 9f 1e 1b 94 21 70 c0 71 ec 1c aa 75 af c0 1e af 3a 2f ea 44 81 68 4a 13 31 7e 8f b4 60 5f 83 6c 63 fa 06 b7 2a d0 81 98 54 7d a3 e3 45 2d 05 d1 0c 1f 7d 05 3f 42 2a 01 03 d5 c2 b5 1b d6 2c 0f a0 b9 10 e3 d3 d3 d6 70 14 4e df cb d6 fe 61 73 ea 65 9d 96 24 f3 99 2a ff 71 22 51 03 d3 66 73 e3 1f 50 7c 29 65 96 d7 f6 8c 3f 6e 9b 57
-> m = sym alg(1 byte) + checksum(2 bytes) + PKCS-1 block type 02
New: Symmetrically Encrypted and MDC Packet(tag 18)(61 bytes)
Ver 1
Encrypted data [sym alg is specified in pub-key encrypted session key]
(plain text + MDC SHA1(20 bytes))
-----BEGIN PGP MESSAGE-----
hQIOA/lWrfAR2suSEAf/SUeNZ/G+FRHqQrzJS8RWTzw2ncWnrdFupDwENl673AW7
Kl6rXaCPDysqKSO+xT+GG1VRe+zKkXgl30zCbNBjsLk3ubqI46uviLPkV66H/kl+
ODiwSzU2e9ZorirI8AUzbQfbBLRebDyl0cqxaiOWD67PKjnOzUsU/jSBnUNSyfUc
oacPUIlUXi4tV+eHNThgU/jpKTbbsFdag9FfJ8xZeE1VAokRwOj5/zWpG+1vLfCA
J4/dahY4+Qe2x68YN0S9USpYiHQglIpEfq2HGtJB36NDlMiZVKRwyWjmMhIekSKj
ZED1N0W0E60lZSMmtQIcuCJmtFN0NF99M+Eo0ze2ZAf+Pzda6oLx8EMGL00Iog+6
ERSreraapq4Uynyor+s8V7QbAgmm9bTlRDS/tfOnCQLs4GtD7Jsosv4rWCaKDATB
xyuw8pC5DvYUQGMxsT9v7G5bXMi0LsZYczsJJDhmLpnPdPFAB68JkfpyVAjM955l
g9NdE2/2lr6dAmo3sQo7wMhYYE77+W05xjCocNvrOj1CsR0vE0oKFe/MEBuIDX6l
A9ZnGClePJkjJSL26+mBPUE9KAhmk/F+yVyUo+s2/aT+CGtREH0rh6PkYfZNO6hE
OMkxM4/P13dLFmqQsL3628qK6q+WPIQDE0AjSJFXRETwIbn1bEgDqguREPW+Wkpc
/dI9Ad3/VTFGUZ6VolwBXzE3vl16ooM4QZW1BqY6yK9iY4neoKq7DrSH0YvvbqGc
bVfsZ5d1wfrKO9vctydgDw==
=p4W1
-----END PGP MESSAGE-----
-----BEGIN PGP MESSAGE-----
hQIOA/lWrfAR2suSEAgAiuopQnSNAkhHjBcnWUkLApclS9UROfqEHUX0X5ae+hcv
XmTIfCXUitJH9Ez8o1M8hpVaNEx0Ff9FmCBVF3OxXqH6qRS9lVvkk9lfWihWGJQ4
6ENX/VD/wjmUbqhcQUdfe9EWAencMjtwxO+CzU7R4yLR2XUbuSFIwnHP1DO/fFFa
WhDIfcvHGRZ0I0dy0Ngn1RcEg3Kgx4NNA7xdxcCdMQD+LmbX5g3CH6t0Bw4lzRr/
f6euLB14y+59sAhj+ZC+Unp4TyqmtXXfGNySv/IEmD5CM5PUj0u7XmM8ETRJYxns
pQuaJSM7/rwpUxu9z1krjSCoRvrt7BkRtT4tpsK/9wf8DEgMR2ZFXAIaO4oAJZUk
Hn04rylKD2nLycZXG9JsjfjUrN4P3IRNghtytiLqWlNhgnXTUlI5bUnJciqfsJBZ
JuuFC5tlsRow+TVeUQ1Fd+Bk2ocHxvyfogoYRoAFKDaRsqhYI9srsVA1UTEpaBSH
17WoSW7stes/amXeu8CQbT+GhdU5O0hDvoWEEiVPdBQt23ufHhuUIXDAcewcqnWv
wB6vOi/qRIFoShMxfo+0YF+DbGP6Brcq0IGYVH2j40UtBdEMH30FP0IqAQPVwrUb
1iwPoLkQ49PT1nAUTt/L1v5hc+plnZYk85kq/3EiUQPTZnPjH1B8KWWW1/aMP26b
V9I9AcNefSTHXkwXArx0n3l6Gy4ui5a++vsL6uq6Krw9R+uKF4Puytdh4kZMi4Oh
Xrh4qwzrfT0P8c63wLtrLQ==
=Lc/2
-----END PGP MESSAGE-----
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment