From 5662c4308d3758d68e34398c1a70a346e58eb5a1 Mon Sep 17 00:00:00 2001 From: Ilya Etingof Date: Thu, 23 Nov 2017 10:29:45 +0100 Subject: [PATCH] imports pep8'ed and optimized --- .travis.yml | 2 +- CHANGES.txt | 3 ++- pyasn1_modules/rfc1155.py | 5 ++++- pyasn1_modules/rfc1157.py | 6 +++++- pyasn1_modules/rfc1901.py | 4 +++- pyasn1_modules/rfc1902.py | 5 ++++- pyasn1_modules/rfc1905.py | 7 ++++++- pyasn1_modules/rfc2251.py | 6 +++++- pyasn1_modules/rfc2437.py | 5 ++++- pyasn1_modules/rfc2459.py | 9 ++++++++- pyasn1_modules/rfc2511.py | 2 +- pyasn1_modules/rfc2560.py | 7 ++++++- pyasn1_modules/rfc3279.py | 4 +++- pyasn1_modules/rfc3280.py | 8 +++++++- pyasn1_modules/rfc3281.py | 4 ++-- pyasn1_modules/rfc3412.py | 5 ++++- pyasn1_modules/rfc3414.py | 4 +++- pyasn1_modules/rfc3447.py | 4 +++- pyasn1_modules/rfc3852.py | 7 ++++++- pyasn1_modules/rfc4210.py | 13 +++++++++++-- pyasn1_modules/rfc4211.py | 7 ++++++- pyasn1_modules/rfc5208.py | 2 +- pyasn1_modules/rfc5280.py | 5 +++-- pyasn1_modules/rfc6402.py | 8 +++++++- tests/test_rfc2314.py | 5 ++++- tests/test_rfc2315.py | 5 ++++- tests/test_rfc2437.py | 5 ++++- tests/test_rfc2459.py | 5 ++++- tests/test_rfc2511.py | 5 ++++- tests/test_rfc2560.py | 5 ++++- tests/test_rfc4210.py | 5 ++++- tests/test_rfc5208.py | 5 ++++- tests/test_rfc5280.py | 5 ++++- tests/test_rfc5652.py | 6 +++++- tools/cmcdump.py | 13 +++++++++---- tools/cmpdump.py | 14 +++++++++----- tools/crldump.py | 8 ++++++-- tools/crmfdump.py | 12 ++++++++---- tools/ocspclient.py | 8 ++++++-- tools/ocspreqdump.py | 8 ++++++-- tools/ocsprspdump.py | 8 ++++++-- tools/pkcs10dump.py | 8 ++++++-- tools/pkcs1dump.py | 9 +++++++-- tools/pkcs7dump.py | 8 ++++++-- tools/pkcs8dump.py | 8 ++++++-- tools/snmpget.py | 9 ++++++--- tools/x509dump-rfc5280.py | 8 ++++++-- tools/x509dump.py | 8 ++++++-- 48 files changed, 239 insertions(+), 73 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9f6ea31..b806fe1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ python: install: - pip install codecov - pip install -r requirements.txt - - pip install --no-deps . + - pip install -e . script: - PYTHONPATH=.:$PYTHONPATH python tests/__main__.py after_success: diff --git a/CHANGES.txt b/CHANGES.txt index f74fcd4..83ad7b8 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,8 +1,9 @@ -Revision 0.2.1, released 21-11-2017 +Revision 0.2.1, released 23-11-2017 ----------------------------------- - Allow ANY DEFINED BY objects expanding automatically if requested +- Imports PEP8'ed Revision 0.1.5, released 10-10-2017 ----------------------------------- diff --git a/pyasn1_modules/rfc1155.py b/pyasn1_modules/rfc1155.py index 4980a38..69c160e 100644 --- a/pyasn1_modules/rfc1155.py +++ b/pyasn1_modules/rfc1155.py @@ -12,7 +12,10 @@ # Sample captures from: # http://wiki.wireshark.org/SampleCaptures/ # -from pyasn1.type import univ, namedtype, tag, constraint +from pyasn1.type import constraint +from pyasn1.type import namedtype +from pyasn1.type import tag +from pyasn1.type import univ class ObjectName(univ.ObjectIdentifier): diff --git a/pyasn1_modules/rfc1157.py b/pyasn1_modules/rfc1157.py index 1ad1d27..9e6527b 100644 --- a/pyasn1_modules/rfc1157.py +++ b/pyasn1_modules/rfc1157.py @@ -12,7 +12,11 @@ # Sample captures from: # http://wiki.wireshark.org/SampleCaptures/ # -from pyasn1.type import univ, namedtype, namedval, tag +from pyasn1.type import namedtype +from pyasn1.type import namedval +from pyasn1.type import tag +from pyasn1.type import univ + from pyasn1_modules import rfc1155 diff --git a/pyasn1_modules/rfc1901.py b/pyasn1_modules/rfc1901.py index eadf9aa..6e8d1f1 100644 --- a/pyasn1_modules/rfc1901.py +++ b/pyasn1_modules/rfc1901.py @@ -9,7 +9,9 @@ # ASN.1 source from: # http://www.ietf.org/rfc/rfc1901.txt # -from pyasn1.type import univ, namedtype, namedval +from pyasn1.type import namedtype +from pyasn1.type import namedval +from pyasn1.type import univ class Message(univ.Sequence): diff --git a/pyasn1_modules/rfc1902.py b/pyasn1_modules/rfc1902.py index 5e9307e..7e815d2 100644 --- a/pyasn1_modules/rfc1902.py +++ b/pyasn1_modules/rfc1902.py @@ -9,7 +9,10 @@ # ASN.1 source from: # http://www.ietf.org/rfc/rfc1902.txt # -from pyasn1.type import univ, namedtype, tag, constraint +from pyasn1.type import constraint +from pyasn1.type import namedtype +from pyasn1.type import tag +from pyasn1.type import univ class Integer(univ.Integer): diff --git a/pyasn1_modules/rfc1905.py b/pyasn1_modules/rfc1905.py index de5bb03..31e4203 100644 --- a/pyasn1_modules/rfc1905.py +++ b/pyasn1_modules/rfc1905.py @@ -9,7 +9,12 @@ # ASN.1 source from: # http://www.ietf.org/rfc/rfc1905.txt # -from pyasn1.type import univ, namedtype, namedval, tag, constraint +from pyasn1.type import constraint +from pyasn1.type import namedtype +from pyasn1.type import namedval +from pyasn1.type import tag +from pyasn1.type import univ + from pyasn1_modules import rfc1902 max_bindings = rfc1902.Integer(2147483647) diff --git a/pyasn1_modules/rfc2251.py b/pyasn1_modules/rfc2251.py index 94ba589..a4c07a0 100644 --- a/pyasn1_modules/rfc2251.py +++ b/pyasn1_modules/rfc2251.py @@ -12,7 +12,11 @@ # Sample captures from: # http://wiki.wireshark.org/SampleCaptures/ # -from pyasn1.type import tag, namedtype, namedval, univ, constraint +from pyasn1.type import constraint +from pyasn1.type import namedtype +from pyasn1.type import namedval +from pyasn1.type import tag +from pyasn1.type import univ maxInt = univ.Integer(2147483647) diff --git a/pyasn1_modules/rfc2437.py b/pyasn1_modules/rfc2437.py index 678d92d..4e4113f 100644 --- a/pyasn1_modules/rfc2437.py +++ b/pyasn1_modules/rfc2437.py @@ -11,7 +11,10 @@ # # Sample captures could be obtained with "openssl genrsa" command # -from pyasn1.type import tag, namedtype, univ +from pyasn1.type import namedtype +from pyasn1.type import tag +from pyasn1.type import univ + from pyasn1_modules.rfc2459 import AlgorithmIdentifier pkcs_1 = univ.ObjectIdentifier('1.2.840.113549.1.1') diff --git a/pyasn1_modules/rfc2459.py b/pyasn1_modules/rfc2459.py index 6855482..1f78185 100644 --- a/pyasn1_modules/rfc2459.py +++ b/pyasn1_modules/rfc2459.py @@ -13,7 +13,14 @@ # Sample captures from: # http://wiki.wireshark.org/SampleCaptures/ # -from pyasn1.type import tag, namedtype, namedval, opentype, univ, constraint, char, useful +from pyasn1.type import char +from pyasn1.type import constraint +from pyasn1.type import namedtype +from pyasn1.type import namedval +from pyasn1.type import opentype +from pyasn1.type import tag +from pyasn1.type import univ +from pyasn1.type import useful MAX = float('inf') diff --git a/pyasn1_modules/rfc2511.py b/pyasn1_modules/rfc2511.py index 4ae7db5..b42d1d9 100644 --- a/pyasn1_modules/rfc2511.py +++ b/pyasn1_modules/rfc2511.py @@ -11,8 +11,8 @@ # # Sample captures could be obtained with OpenSSL # -from pyasn1_modules.rfc2459 import * from pyasn1_modules import rfc2315 +from pyasn1_modules.rfc2459 import * MAX = float('inf') diff --git a/pyasn1_modules/rfc2560.py b/pyasn1_modules/rfc2560.py index 472099e..47ca4e1 100644 --- a/pyasn1_modules/rfc2560.py +++ b/pyasn1_modules/rfc2560.py @@ -21,7 +21,12 @@ # * dates are left as strings in GeneralizedTime format -- datetime.datetime # would be nicer # -from pyasn1.type import tag, namedtype, namedval, univ, useful +from pyasn1.type import namedtype +from pyasn1.type import namedval +from pyasn1.type import tag +from pyasn1.type import univ +from pyasn1.type import useful + from pyasn1_modules import rfc2459 diff --git a/pyasn1_modules/rfc3279.py b/pyasn1_modules/rfc3279.py index f69ff08..65a554d 100644 --- a/pyasn1_modules/rfc3279.py +++ b/pyasn1_modules/rfc3279.py @@ -6,7 +6,9 @@ # # Derived from RFC 3279 # -from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful +from pyasn1.type import namedtype +from pyasn1.type import namedval +from pyasn1.type import univ def _OID(*components): diff --git a/pyasn1_modules/rfc3280.py b/pyasn1_modules/rfc3280.py index 3614e6c..f49dcfb 100644 --- a/pyasn1_modules/rfc3280.py +++ b/pyasn1_modules/rfc3280.py @@ -12,7 +12,13 @@ # ASN.1 source from: # http://www.ietf.org/rfc/rfc3280.txt # -from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful +from pyasn1.type import char +from pyasn1.type import constraint +from pyasn1.type import namedtype +from pyasn1.type import namedval +from pyasn1.type import tag +from pyasn1.type import univ +from pyasn1.type import useful MAX = float('inf') diff --git a/pyasn1_modules/rfc3281.py b/pyasn1_modules/rfc3281.py index 8aa99d3..9ecc2cd 100644 --- a/pyasn1_modules/rfc3281.py +++ b/pyasn1_modules/rfc3281.py @@ -11,12 +11,12 @@ # ASN.1 source from: # http://www.ietf.org/rfc/rfc3281.txt # -from pyasn1.type import univ from pyasn1.type import char +from pyasn1.type import constraint from pyasn1.type import namedtype from pyasn1.type import namedval from pyasn1.type import tag -from pyasn1.type import constraint +from pyasn1.type import univ from pyasn1.type import useful from pyasn1_modules import rfc3280 diff --git a/pyasn1_modules/rfc3412.py b/pyasn1_modules/rfc3412.py index b3f5a92..1492e62 100644 --- a/pyasn1_modules/rfc3412.py +++ b/pyasn1_modules/rfc3412.py @@ -9,7 +9,10 @@ # ASN.1 source from: # http://www.ietf.org/rfc/rfc3412.txt # -from pyasn1.type import univ, namedtype, constraint +from pyasn1.type import constraint +from pyasn1.type import namedtype +from pyasn1.type import univ + from pyasn1_modules import rfc1905 diff --git a/pyasn1_modules/rfc3414.py b/pyasn1_modules/rfc3414.py index aeb82aa..cac18cf 100644 --- a/pyasn1_modules/rfc3414.py +++ b/pyasn1_modules/rfc3414.py @@ -9,7 +9,9 @@ # ASN.1 source from: # http://www.ietf.org/rfc/rfc3414.txt # -from pyasn1.type import univ, namedtype, constraint +from pyasn1.type import constraint +from pyasn1.type import namedtype +from pyasn1.type import univ class UsmSecurityParameters(univ.Sequence): diff --git a/pyasn1_modules/rfc3447.py b/pyasn1_modules/rfc3447.py index 57c99fa..a2950aa 100644 --- a/pyasn1_modules/rfc3447.py +++ b/pyasn1_modules/rfc3447.py @@ -11,7 +11,9 @@ # # Sample captures could be obtained with "openssl genrsa" command # -from pyasn1.type import constraint, namedval +from pyasn1.type import constraint +from pyasn1.type import namedval + from pyasn1_modules.rfc2437 import * diff --git a/pyasn1_modules/rfc3852.py b/pyasn1_modules/rfc3852.py index 872eb88..3b17fe5 100644 --- a/pyasn1_modules/rfc3852.py +++ b/pyasn1_modules/rfc3852.py @@ -11,7 +11,12 @@ # ASN.1 source from: # http://www.ietf.org/rfc/rfc3852.txt # -from pyasn1.type import univ, namedtype, namedval, tag, constraint, useful +from pyasn1.type import constraint +from pyasn1.type import namedtype +from pyasn1.type import namedval +from pyasn1.type import tag +from pyasn1.type import univ +from pyasn1.type import useful from pyasn1_modules import rfc3280 from pyasn1_modules import rfc3281 diff --git a/pyasn1_modules/rfc4210.py b/pyasn1_modules/rfc4210.py index d7e6db0..b93464f 100644 --- a/pyasn1_modules/rfc4210.py +++ b/pyasn1_modules/rfc4210.py @@ -8,8 +8,17 @@ # # Based on Alex Railean's work # -from pyasn1.type import tag, namedtype, namedval, univ, constraint, char, useful -from pyasn1_modules import rfc2459, rfc2511, rfc2314 +from pyasn1.type import char +from pyasn1.type import constraint +from pyasn1.type import namedtype +from pyasn1.type import namedval +from pyasn1.type import tag +from pyasn1.type import univ +from pyasn1.type import useful + +from pyasn1_modules import rfc2314 +from pyasn1_modules import rfc2459 +from pyasn1_modules import rfc2511 MAX = float('inf') diff --git a/pyasn1_modules/rfc4211.py b/pyasn1_modules/rfc4211.py index d20da78..9ff07f2 100644 --- a/pyasn1_modules/rfc4211.py +++ b/pyasn1_modules/rfc4211.py @@ -12,7 +12,12 @@ # ASN.1 source from: # http://www.ietf.org/rfc/rfc4211.txt # -from pyasn1.type import univ, char, namedtype, namedval, tag, constraint +from pyasn1.type import char +from pyasn1.type import constraint +from pyasn1.type import namedtype +from pyasn1.type import namedval +from pyasn1.type import tag +from pyasn1.type import univ from pyasn1_modules import rfc3280 from pyasn1_modules import rfc3852 diff --git a/pyasn1_modules/rfc5208.py b/pyasn1_modules/rfc5208.py index 6b6487d..7857d2f 100644 --- a/pyasn1_modules/rfc5208.py +++ b/pyasn1_modules/rfc5208.py @@ -11,8 +11,8 @@ # # Sample captures could be obtained with "openssl pkcs8 -topk8" command # -from pyasn1_modules.rfc2459 import * from pyasn1_modules import rfc2251 +from pyasn1_modules.rfc2459 import * class KeyEncryptionAlgorithms(AlgorithmIdentifier): diff --git a/pyasn1_modules/rfc5280.py b/pyasn1_modules/rfc5280.py index c750f28..2ecc627 100644 --- a/pyasn1_modules/rfc5280.py +++ b/pyasn1_modules/rfc5280.py @@ -12,17 +12,18 @@ # ASN.1 source from: # http://www.ietf.org/rfc/rfc5280.txt # -from pyasn1.type import univ from pyasn1.type import char +from pyasn1.type import constraint from pyasn1.type import namedtype from pyasn1.type import namedval from pyasn1.type import opentype from pyasn1.type import tag -from pyasn1.type import constraint +from pyasn1.type import univ from pyasn1.type import useful MAX = float('inf') + def _buildOid(*components): output = [] for x in tuple(components): diff --git a/pyasn1_modules/rfc6402.py b/pyasn1_modules/rfc6402.py index c35f855..faee07f 100644 --- a/pyasn1_modules/rfc6402.py +++ b/pyasn1_modules/rfc6402.py @@ -11,7 +11,13 @@ # ASN.1 source from: # http://www.ietf.org/rfc/rfc6402.txt # -from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful +from pyasn1.type import char +from pyasn1.type import constraint +from pyasn1.type import namedtype +from pyasn1.type import namedval +from pyasn1.type import tag +from pyasn1.type import univ +from pyasn1.type import useful from pyasn1_modules import rfc4211 from pyasn1_modules import rfc5280 diff --git a/tests/test_rfc2314.py b/tests/test_rfc2314.py index 6dd5c47..9ff3176 100644 --- a/tests/test_rfc2314.py +++ b/tests/test_rfc2314.py @@ -5,13 +5,16 @@ # License: http://pyasn1.sf.net/license.html # import sys + from pyasn1.codec.der import decoder as der_decoder from pyasn1.codec.der import encoder as der_encoder -from pyasn1_modules import rfc2314, pem +from pyasn1_modules import pem +from pyasn1_modules import rfc2314 try: import unittest2 as unittest + except ImportError: import unittest diff --git a/tests/test_rfc2315.py b/tests/test_rfc2315.py index 5dbdc4b..3a0c307 100644 --- a/tests/test_rfc2315.py +++ b/tests/test_rfc2315.py @@ -5,13 +5,16 @@ # License: http://pyasn1.sf.net/license.html # import sys + from pyasn1.codec.der import decoder as der_decoder from pyasn1.codec.der import encoder as der_encoder -from pyasn1_modules import rfc2315, pem +from pyasn1_modules import pem +from pyasn1_modules import rfc2315 try: import unittest2 as unittest + except ImportError: import unittest diff --git a/tests/test_rfc2437.py b/tests/test_rfc2437.py index 8d3539a..748a9df 100644 --- a/tests/test_rfc2437.py +++ b/tests/test_rfc2437.py @@ -5,13 +5,16 @@ # License: http://pyasn1.sf.net/license.html # import sys + from pyasn1.codec.der import decoder as der_decoder from pyasn1.codec.der import encoder as der_encoder -from pyasn1_modules import rfc2437, pem +from pyasn1_modules import pem +from pyasn1_modules import rfc2437 try: import unittest2 as unittest + except ImportError: import unittest diff --git a/tests/test_rfc2459.py b/tests/test_rfc2459.py index c3310d9..20a0d28 100644 --- a/tests/test_rfc2459.py +++ b/tests/test_rfc2459.py @@ -5,13 +5,16 @@ # License: http://pyasn1.sf.net/license.html # import sys + from pyasn1.codec.der import decoder as der_decoder from pyasn1.codec.der import encoder as der_encoder -from pyasn1_modules import rfc2459, pem +from pyasn1_modules import pem +from pyasn1_modules import rfc2459 try: import unittest2 as unittest + except ImportError: import unittest diff --git a/tests/test_rfc2511.py b/tests/test_rfc2511.py index ef4cc00..cd5e266 100644 --- a/tests/test_rfc2511.py +++ b/tests/test_rfc2511.py @@ -5,13 +5,16 @@ # License: http://pyasn1.sf.net/license.html # import sys + from pyasn1.codec.der import decoder as der_decoder from pyasn1.codec.der import encoder as der_encoder -from pyasn1_modules import rfc2511, pem +from pyasn1_modules import pem +from pyasn1_modules import rfc2511 try: import unittest2 as unittest + except ImportError: import unittest diff --git a/tests/test_rfc2560.py b/tests/test_rfc2560.py index 142284b..f96d36b 100644 --- a/tests/test_rfc2560.py +++ b/tests/test_rfc2560.py @@ -5,13 +5,16 @@ # License: http://pyasn1.sf.net/license.html # import sys + from pyasn1.codec.der import decoder as der_decoder from pyasn1.codec.der import encoder as der_encoder -from pyasn1_modules import rfc2560, pem +from pyasn1_modules import pem +from pyasn1_modules import rfc2560 try: import unittest2 as unittest + except ImportError: import unittest diff --git a/tests/test_rfc4210.py b/tests/test_rfc4210.py index 35451c8..5c63c2e 100644 --- a/tests/test_rfc4210.py +++ b/tests/test_rfc4210.py @@ -5,13 +5,16 @@ # License: http://pyasn1.sf.net/license.html # import sys + from pyasn1.codec.der import decoder as der_decoder from pyasn1.codec.der import encoder as der_encoder -from pyasn1_modules import rfc4210, pem +from pyasn1_modules import pem +from pyasn1_modules import rfc4210 try: import unittest2 as unittest + except ImportError: import unittest diff --git a/tests/test_rfc5208.py b/tests/test_rfc5208.py index 94d1d0e..285085d 100644 --- a/tests/test_rfc5208.py +++ b/tests/test_rfc5208.py @@ -5,13 +5,16 @@ # License: http://pyasn1.sf.net/license.html # import sys + from pyasn1.codec.der import decoder as der_decoder from pyasn1.codec.der import encoder as der_encoder -from pyasn1_modules import rfc5208, pem +from pyasn1_modules import pem +from pyasn1_modules import rfc5208 try: import unittest2 as unittest + except ImportError: import unittest diff --git a/tests/test_rfc5280.py b/tests/test_rfc5280.py index 49983ef..852f4ca 100644 --- a/tests/test_rfc5280.py +++ b/tests/test_rfc5280.py @@ -5,13 +5,16 @@ # License: http://pyasn1.sf.net/license.html # import sys + from pyasn1.codec.der import decoder as der_decoder from pyasn1.codec.der import encoder as der_encoder -from pyasn1_modules import rfc5280, pem +from pyasn1_modules import pem +from pyasn1_modules import rfc5280 try: import unittest2 as unittest + except ImportError: import unittest diff --git a/tests/test_rfc5652.py b/tests/test_rfc5652.py index 5fa4296..a2d1fc7 100644 --- a/tests/test_rfc5652.py +++ b/tests/test_rfc5652.py @@ -5,13 +5,17 @@ # License: http://pyasn1.sf.net/license.html # import sys + from pyasn1.codec.der import decoder as der_decoder from pyasn1.codec.der import encoder as der_encoder -from pyasn1_modules import rfc5652, rfc6402, pem +from pyasn1_modules import pem +from pyasn1_modules import rfc5652 +from pyasn1_modules import rfc6402 try: import unittest2 as unittest + except ImportError: import unittest diff --git a/tools/cmcdump.py b/tools/cmcdump.py index bce48b1..d16774d 100755 --- a/tools/cmcdump.py +++ b/tools/cmcdump.py @@ -3,15 +3,20 @@ # Read CMC certificate request with wrappers on stdin, parse each into # plain text, then build substrate from it # -from pyasn1.codec.der import decoder, encoder -from pyasn1_modules import rfc5652, rfc6402, pem import sys +from pyasn1.codec.der import decoder +from pyasn1.codec.der import encoder + +from pyasn1_modules import pem +from pyasn1_modules import rfc5652 +from pyasn1_modules import rfc6402 + if len(sys.argv) != 1: print("""Usage: $ cat cmc_request.pem | %s""" % (sys.argv[0],)) sys.exit(-1) - + reqCnt = 0 substrate = pem.readBase64FromFile(sys.stdin) @@ -26,7 +31,7 @@ layer, rest = decoder.decode(data, asn1Spec=rfc5652.ContentInfo()) assert encoder.encode(layer) == data, 'wrapper recode fails' assert not rest - + print(" * New layer (wrapper):") print(layer.prettyPrint()) diff --git a/tools/cmpdump.py b/tools/cmpdump.py index c89951a..ee8092b 100755 --- a/tools/cmpdump.py +++ b/tools/cmpdump.py @@ -8,24 +8,28 @@ # Read ASN.1/PEM CMP message on stdin, parse into # plain text, then build substrate from it # -from pyasn1.codec.der import decoder, encoder -from pyasn1_modules import rfc4210, pem -from pyasn1 import debug import sys +from pyasn1 import debug +from pyasn1.codec.der import decoder +from pyasn1.codec.der import encoder + +from pyasn1_modules import pem +from pyasn1_modules import rfc4210 + if len(sys.argv) == 2 and sys.argv[1] == '-d': debug.setLogger(debug.Debug('all')) elif len(sys.argv) != 1: print("""Usage: $ cat cmp.pem | %s [-d]""" % sys.argv[0]) sys.exit(-1) - + pkiMessage = rfc4210.PKIMessage() substrate = pem.readBase64FromFile(sys.stdin) if not substrate: sys.exit(0) - + pkiMsg, rest = decoder.decode(substrate, asn1Spec=pkiMessage) print(pkiMsg.prettyPrint()) diff --git a/tools/crldump.py b/tools/crldump.py index b871ddd..9731129 100755 --- a/tools/crldump.py +++ b/tools/crldump.py @@ -9,10 +9,14 @@ # original wire format. # CRL can be generated with "openssl openssl ca -gencrl ..." commands. # -from pyasn1_modules import rfc2459, pem -from pyasn1.codec.der import encoder, decoder import sys +from pyasn1.codec.der import decoder +from pyasn1.codec.der import encoder + +from pyasn1_modules import pem +from pyasn1_modules import rfc2459 + if len(sys.argv) != 1: print("""Usage: $ cat crl.pem | %s""" % sys.argv[0]) diff --git a/tools/crmfdump.py b/tools/crmfdump.py index efb0ffc..854bfec 100755 --- a/tools/crmfdump.py +++ b/tools/crmfdump.py @@ -8,21 +8,25 @@ # Read ASN.1/PEM X.509 CRMF request on stdin, parse into # plain text, then build substrate from it # -from pyasn1.codec.der import decoder, encoder -from pyasn1_modules import rfc2511, pem import sys +from pyasn1.codec.der import decoder +from pyasn1.codec.der import encoder + +from pyasn1_modules import pem +from pyasn1_modules import rfc2511 + if len(sys.argv) != 1: print("""Usage: $ cat crmf.pem | %s""" % sys.argv[0]) sys.exit(-1) - + certReq = rfc2511.CertReqMessages() substrate = pem.readBase64FromFile(sys.stdin) if not substrate: sys.exit(0) - + cr, rest = decoder.decode(substrate, asn1Spec=certReq) print(cr.prettyPrint()) diff --git a/tools/ocspclient.py b/tools/ocspclient.py index 07ff5ad..2827604 100755 --- a/tools/ocspclient.py +++ b/tools/ocspclient.py @@ -10,13 +10,17 @@ try: import urllib2 + except ImportError: import urllib.request as urllib2 -from pyasn1.codec.der import decoder, encoder +from pyasn1.codec.der import decoder +from pyasn1.codec.der import encoder from pyasn1.type import univ -from pyasn1_modules import rfc2560, rfc2459, pem +from pyasn1_modules import rfc2560 +from pyasn1_modules import rfc2459 +from pyasn1_modules import pem sha1oid = univ.ObjectIdentifier((1, 3, 14, 3, 2, 26)) diff --git a/tools/ocspreqdump.py b/tools/ocspreqdump.py index 40c088a..f613f3a 100755 --- a/tools/ocspreqdump.py +++ b/tools/ocspreqdump.py @@ -8,10 +8,14 @@ # Read ASN.1/PEM X.509 CRMF request on stdin, parse into # plain text, then build substrate from it # -from pyasn1.codec.der import decoder, encoder -from pyasn1_modules import rfc2560, pem import sys +from pyasn1.codec.der import decoder +from pyasn1.codec.der import encoder + +from pyasn1_modules import pem +from pyasn1_modules import rfc2560 + if len(sys.argv) != 1: print("""Usage: $ cat ocsp-request.pem | %s""" % sys.argv[0]) diff --git a/tools/ocsprspdump.py b/tools/ocsprspdump.py index ca52f64..3535795 100755 --- a/tools/ocsprspdump.py +++ b/tools/ocsprspdump.py @@ -8,10 +8,14 @@ # Read ASN.1/PEM OCSP response on stdin, parse into # plain text, then build substrate from it # -from pyasn1.codec.der import decoder, encoder -from pyasn1_modules import rfc2560, pem import sys +from pyasn1.codec.der import decoder +from pyasn1.codec.der import encoder + +from pyasn1_modules import pem +from pyasn1_modules import rfc2560 + if len(sys.argv) != 1: print("""Usage: $ cat ocsp-response.pem | %s""" % sys.argv[0]) diff --git a/tools/pkcs10dump.py b/tools/pkcs10dump.py index 56417ae..e8c6da5 100755 --- a/tools/pkcs10dump.py +++ b/tools/pkcs10dump.py @@ -8,10 +8,14 @@ # Read ASN.1/PEM X.509 certificate requests (PKCS#10 format) on stdin, # parse each into plain text, then build substrate from it # -from pyasn1.codec.der import decoder, encoder -from pyasn1_modules import rfc2314, pem import sys +from pyasn1.codec.der import decoder +from pyasn1.codec.der import encoder + +from pyasn1_modules import pem +from pyasn1_modules import rfc2314 + if len(sys.argv) != 1: print("""Usage: $ cat certificateRequest.pem | %s""" % sys.argv[0]) diff --git a/tools/pkcs1dump.py b/tools/pkcs1dump.py index f205d77..520fc4c 100755 --- a/tools/pkcs1dump.py +++ b/tools/pkcs1dump.py @@ -9,10 +9,15 @@ # stdin, print them pretty and encode back into original wire format. # Private keys can be generated with "openssl genrsa|gendsa" commands. # -from pyasn1_modules import rfc2459, rfc2437, pem -from pyasn1.codec.der import encoder, decoder import sys +from pyasn1.codec.der import decoder +from pyasn1.codec.der import encoder + +from pyasn1_modules import pem +from pyasn1_modules import rfc2437 +from pyasn1_modules import rfc2459 + if len(sys.argv) != 1: print("""Usage: $ cat rsakey.pem | %s""" % sys.argv[0]) diff --git a/tools/pkcs7dump.py b/tools/pkcs7dump.py index 72fe70d..c01e19c 100755 --- a/tools/pkcs7dump.py +++ b/tools/pkcs7dump.py @@ -8,10 +8,14 @@ # Read ASN.1/PEM PKCS#7 on stdin, parse it into plain text, # then build substrate from it # -from pyasn1_modules import rfc2315, pem -from pyasn1.codec.der import encoder, decoder import sys +from pyasn1.codec.der import decoder +from pyasn1.codec.der import encoder + +from pyasn1_modules import pem +from pyasn1_modules import rfc2315 + if len(sys.argv) != 1: print("""Usage: $ cat pkcs7Certificate.pem | %s""" % sys.argv[0]) diff --git a/tools/pkcs8dump.py b/tools/pkcs8dump.py index 2bb8388..d645a87 100755 --- a/tools/pkcs8dump.py +++ b/tools/pkcs8dump.py @@ -8,10 +8,14 @@ # Read bunch of ASN.1/PEM plain/encrypted private keys in PKCS#8 # format on stdin, parse each into plain text, then build substrate from it # -from pyasn1.codec.der import decoder, encoder -from pyasn1_modules import rfc5208, pem import sys +from pyasn1.codec.der import decoder +from pyasn1.codec.der import encoder + +from pyasn1_modules import pem +from pyasn1_modules import rfc5208 + if len(sys.argv) != 1: print("""Usage: $ cat pkcs8key.pem | %s""" % sys.argv[0]) diff --git a/tools/snmpget.py b/tools/snmpget.py index cd9fec2..877d521 100755 --- a/tools/snmpget.py +++ b/tools/snmpget.py @@ -7,10 +7,13 @@ # # Generate SNMPGET request, parse response # -from pyasn1.codec.ber import encoder, decoder -from pyasn1_modules import rfc1157 -import sys import socket +import sys + +from pyasn1.codec.ber import decoder +from pyasn1.codec.ber import encoder + +from pyasn1_modules import rfc1157 if len(sys.argv) != 4: print("""Usage: diff --git a/tools/x509dump-rfc5280.py b/tools/x509dump-rfc5280.py index 482df7e..d1ae38b 100755 --- a/tools/x509dump-rfc5280.py +++ b/tools/x509dump-rfc5280.py @@ -10,10 +10,14 @@ # Read ASN.1/PEM X.509 certificates on stdin, parse each into plain text, # then build substrate from it (using RFC5280) # -from pyasn1.codec.der import decoder, encoder -from pyasn1_modules import rfc5280, pem import sys +from pyasn1.codec.der import decoder +from pyasn1.codec.der import encoder + +from pyasn1_modules import pem +from pyasn1_modules import rfc5280 + if len(sys.argv) != 1: print("""Usage: $ cat CACertificate.pem | %s diff --git a/tools/x509dump.py b/tools/x509dump.py index 2c51c6a..5a36915 100755 --- a/tools/x509dump.py +++ b/tools/x509dump.py @@ -8,10 +8,14 @@ # Read ASN.1/PEM X.509 certificates on stdin, parse each into plain text, # then build substrate from it # -from pyasn1.codec.der import decoder, encoder -from pyasn1_modules import rfc2459, pem import sys +from pyasn1.codec.der import decoder +from pyasn1.codec.der import encoder + +from pyasn1_modules import pem +from pyasn1_modules import rfc2459 + if len(sys.argv) != 1: print("""Usage: $ cat CACertificate.pem | %s