aboutsummaryrefslogtreecommitdiff
path: root/unit-tests.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2017-05-10 19:10:05 -0400
committerRob Austein <sra@hactrn.net>2017-05-10 19:10:05 -0400
commit052a0781ec41780b534aca749540ed5b939a721a (patch)
treedd8fc87d8ddf77d46eb1c2d1b5f6952c4e7c9e51 /unit-tests.py
parenta49b53463451d9f78b5e7fc6331fcad6faf754ff (diff)
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.
Diffstat (limited to 'unit-tests.py')
-rw-r--r--unit-tests.py14
1 files 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])
+ # <kludge>
+ # 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])
+ # </kludge>
if algorithm.payload != oid:
raise ValueError
return encryptedData.payload