Additional pkcs12 test code

This commit is contained in:
Florian Bach 2022-05-16 08:32:36 +02:00
parent c485f4ed50
commit d5028c3cc8
2 changed files with 23 additions and 6 deletions

View File

@ -138,11 +138,15 @@ def buildInitLicenseServiceRequest(authURL):
return "<?xml version=\"1.0\"?>\n" + etree.tostring(req_xml, encoding="utf-8", pretty_print=True, xml_declaration=False).decode("utf-8")
def getDecryptedCert():
activationxml = etree.parse(get_activation_xml_path())
adNS = lambda tag: '{%s}%s' % ('http://ns.adobe.com/adept', tag)
def getDecryptedCert(pkcs12_b64_string = None):
if pkcs12_b64_string is None:
activationxml = etree.parse(get_activation_xml_path())
adNS = lambda tag: '{%s}%s' % ('http://ns.adobe.com/adept', tag)
user_pkcs12 = base64.b64decode(activationxml.find("./%s/%s" % (adNS("credentials"), adNS("pkcs12"))).text)
pkcs12_b64_string = activationxml.find("./%s/%s" % (adNS("credentials"), adNS("pkcs12"))).text
pkcs12_data = base64.b64decode(pkcs12_b64_string)
try:
from libadobe import devkey_bytes as devkey_adobe
@ -157,7 +161,7 @@ def getDecryptedCert():
f.close()
try:
return get_cert_from_pkcs12(user_pkcs12, base64.b64encode(devkey_bytes))
return get_cert_from_pkcs12(pkcs12_data, base64.b64encode(devkey_bytes))
except:
return None

View File

@ -24,6 +24,7 @@ except ImportError:
import libadobe # type: ignore
import libadobeAccount # type: ignore
import libadobeFulfill # type: ignore
from getEncryptionKeyLinux import unfuck as fix_wine_username # type: ignore
from libpdf import trim_encrypt_string, cleanup_encrypt_element, deflate_and_base64_encode # type: ignore
from customRSA import CustomRSA # type: ignore
@ -275,7 +276,19 @@ class TestAdobe(unittest.TestCase):
self.assertEqual(privkey, dummy_key_data, "p12 key invalid after extraction")
def test_pkcs12_extract_plugin_implementation(self):
'''Check if the plugin is capable of extracting pkcs12 key'''
mock_p12_data = "MIIG6wIBAzCCBqQGCSqGSIb3DQEHAaCCBpUEggaRMIIGjTCCA1QGCSqGSIb3DQEHAaCCA0UEggNBMIIDPTCCAzkGCyqG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kSh1wm2U6IAXb52rc7Fg6swWcn5/kB3oSE+zA+MCEwCQYFKw4DAhoFAAQUSVUxHMAy14F9ipUfmUIwA2ovshMEFB7KG3S0hy9noJTTTY9/aFpxPd0HAgMBhqA="
# Actual key password is "1234" base64-encoded = "MTIzNA=="
mock_p12_password = b"1234"
libadobe.devkey_bytes = mock_p12_password
decrypted = libadobeFulfill.getDecryptedCert(mock_p12_data)
self.assertIsNotNone(decrypted)
def test_Account_loginCredentialEncryption(self):