From 052a0781ec41780b534aca749540ed5b939a721a Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Wed, 10 May 2017 19:10:05 -0400 Subject: Work around known bugs in PyCrypto ASN.1 code. Turns out there are a couple of known minor bugs in PyCrypto's ASN.1 decoder, simple dumb things that never could have worked. Debian's packaging includes a patch for these bugs, but for some reason the patch is marked as not needing to be sent upstream, dunno why. So these methods work fine, but only on Debian. Feh. Simplest approach is to work around the bugs on all platforms, particularly given that this is just unit test support code. --- unit-tests.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/unit-tests.py b/unit-tests.py index f0f5fb2..a3e4282 100644 --- a/unit-tests.py +++ b/unit-tests.py @@ -905,11 +905,19 @@ class TestPKeyBackup(TestCaseLoggedIn): encryptedPrivateKeyInfo = DerSequence() encryptedPrivateKeyInfo.decode(der) encryptionAlgorithm = DerSequence() - encryptionAlgorithm.decode(encryptedPrivateKeyInfo[0]) algorithm = DerObjectId() - algorithm.decode(encryptionAlgorithm[0]) encryptedData = DerOctetString() - encryptedData.decode(encryptedPrivateKeyInfo[1]) + encryptionAlgorithm.decode(encryptedPrivateKeyInfo[0]) + # + # Sigh, bugs in PyCrypto ASN.1 code. Should do: + # + #algorithm.decode(encryptionAlgorithm[0]) + #encryptedData.decode(encryptedPrivateKeyInfo[1]) + # + # but due to bugs in those methods we must instead do: + DerObject.decode(algorithm, encryptionAlgorithm[0]) + DerObject.decode(encryptedData, encryptedPrivateKeyInfo[1]) + # if algorithm.payload != oid: raise ValueError return encryptedData.payload -- cgit v1.2.3