diff options
author | Michał Górny <mgorny@gentoo.org> | 2023-01-21 14:18:18 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2023-01-21 14:18:18 +0100 |
commit | 73b13cbd50492b0a796b1d2704df227889e5e658 (patch) | |
tree | 9a2f0616766645042b42df45c20860c6aa3a7319 /tests/test_openpgp.py | |
parent | 8ee388c807e589d06b3526c17bfb34810001c1ee (diff) | |
download | gemato-73b13cbd50492b0a796b1d2704df227889e5e658.tar.gz |
tests: Move the combined keys to keydata
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'tests/test_openpgp.py')
-rw-r--r-- | tests/test_openpgp.py | 57 |
1 files changed, 8 insertions, 49 deletions
diff --git a/tests/test_openpgp.py b/tests/test_openpgp.py index e4f47e5..e594416 100644 --- a/tests/test_openpgp.py +++ b/tests/test_openpgp.py @@ -1,9 +1,8 @@ # gemato: OpenPGP signature support tests -# (c) 2017-2022 Michał Górny +# (c) 2017-2023 Michał Górny # Licensed under the terms of 2-clause BSD license import contextlib -import datetime import io import logging import os @@ -38,26 +37,18 @@ from gemato.openpgp import ( from gemato.recursiveloader import ManifestRecursiveLoader from tests.keydata import ( - PUBLIC_KEY, SECRET_KEY, PUBLIC_SUBKEY, UID, - UID_NOEMAIL, PUBLIC_KEY_NOEMAIL_SIG, - UID_NONUTF, PUBLIC_KEY_NONUTF_SIG, - PUBLIC_KEY_SIG, PUBLIC_SUBKEY_SIG, EXPIRED_KEY_SIG, REVOCATION_SIG, - OTHER_PUBLIC_KEY, OTHER_PUBLIC_KEY_UID, OTHER_PUBLIC_KEY_SIG, - UNEXPIRE_SIG, + PRIVATE_KEY_ID, KEY_FINGERPRINT, OTHER_KEY_FINGERPRINT, VALID_PUBLIC_KEY, + VALID_KEY_NOEMAIL, VALID_KEY_NONUTF, COMBINED_PUBLIC_KEYS, + VALID_KEY_SUBKEY, PRIVATE_KEY, EXPIRED_PUBLIC_KEY, REVOKED_PUBLIC_KEY, + OTHER_VALID_PUBLIC_KEY, UNSIGNED_PUBLIC_KEY, FORGED_PUBLIC_KEY, + UNSIGNED_SUBKEY, FORGED_SUBKEY, SIG_TIMESTAMP, SUBKEY_FINGERPRINT, + SUBKEY_SIG_TIMESTAMP, UNEXPIRE_PUBLIC_KEY, OLD_UNEXPIRE_PUBLIC_KEY, + FORGED_UNEXPIRE_KEY, ) from tests.test_recursiveloader import INSECURE_HASH_TESTS from tests.testutil import HKPServer -VALID_PUBLIC_KEY = PUBLIC_KEY + UID + PUBLIC_KEY_SIG -EXPIRED_PUBLIC_KEY = PUBLIC_KEY + UID + EXPIRED_KEY_SIG -REVOKED_PUBLIC_KEY = PUBLIC_KEY + REVOCATION_SIG + UID + PUBLIC_KEY_SIG -OLD_UNEXPIRE_PUBLIC_KEY = PUBLIC_KEY + UID + PUBLIC_KEY_SIG -UNEXPIRE_PUBLIC_KEY = PUBLIC_KEY + UID + UNEXPIRE_SIG - -PRIVATE_KEY = SECRET_KEY + UID + PUBLIC_KEY_SIG -PRIVATE_KEY_ID = b'0x136880E72A7B1384' - MALFORMED_PUBLIC_KEY = b''' -----BEGIN PGP PUBLIC KEY BLOCK----- @@ -185,21 +176,6 @@ t5pTRGhLWgdLUrs7vRB7wf7F8h4sci/YBKJRFA== -----END PGP SIGNATURE----- ''' -KEY_FINGERPRINT = '81E12C16BD8DCD60BE180845136880E72A7B1384' -SIG_TIMESTAMP = datetime.datetime(2017, 11, 8, 9, 1, 26) - -OTHER_VALID_PUBLIC_KEY = (OTHER_PUBLIC_KEY + OTHER_PUBLIC_KEY_UID + - OTHER_PUBLIC_KEY_SIG) -OTHER_KEY_FINGERPRINT = '4B8349B90C56EE7F054D52871822F5424EB6DA81' - -VALID_KEY_NOEMAIL = PUBLIC_KEY + UID_NOEMAIL + PUBLIC_KEY_NOEMAIL_SIG -VALID_KEY_NONUTF = PUBLIC_KEY + UID_NONUTF + PUBLIC_KEY_NONUTF_SIG - -VALID_KEY_SUBKEY = (PUBLIC_KEY + UID + PUBLIC_KEY_SIG + PUBLIC_SUBKEY + - PUBLIC_SUBKEY_SIG) -SUBKEY_FINGERPRINT = '7E9DDE3CBE47E437418DF74038B9D2F76CC833CC' -SUBKEY_SIG_TIMESTAMP = datetime.datetime(2020, 8, 25, 12, 40, 12) - SUBKEY_SIGNED_MANIFEST = ''' -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 @@ -225,23 +201,6 @@ n4XmpdPvu+UdAHpQIGzKoNOEDJpZ5CzPLhYa5KgZiJhpYsDXgg== ''' -def break_sig(sig): - """Return signature packet mangled to mismatch the signed key""" - return sig[:-1] + b'\x55' - - -FORGED_PUBLIC_KEY = PUBLIC_KEY + UID + break_sig(PUBLIC_KEY_SIG) -FORGED_SUBKEY = (PUBLIC_KEY + UID + PUBLIC_KEY_SIG + PUBLIC_SUBKEY + - break_sig(PUBLIC_SUBKEY_SIG)) -FORGED_UNEXPIRE_KEY = (PUBLIC_KEY + UID + EXPIRED_KEY_SIG + - break_sig(UNEXPIRE_SIG)) - -UNSIGNED_PUBLIC_KEY = PUBLIC_KEY + UID -UNSIGNED_SUBKEY = PUBLIC_KEY + UID + PUBLIC_KEY_SIG + PUBLIC_SUBKEY - -COMBINED_PUBLIC_KEYS = OTHER_VALID_PUBLIC_KEY + VALID_PUBLIC_KEY - - def strip_openpgp(text): lines = text.lstrip().splitlines() start = lines.index('') |