Replace pylint with flake8, improve exception class specificity
diff --git a/.pep8 b/.pep8
new file mode 100644
index 0000000..6deafc2
--- /dev/null
+++ b/.pep8
@@ -0,0 +1,2 @@
+[flake8]
+max-line-length = 120
diff --git a/.pylintrc b/.pylintrc
deleted file mode 100644
index c59352d..0000000
--- a/.pylintrc
+++ /dev/null
@@ -1,17 +0,0 @@
-[MASTER]
-
-ignore=.git
-
-[MESSAGES CONTROL]
-
-enable=W1619,R0401,W1602,W0211,E1604,W0622,W1605,C0204,W0123,E0236,E0701,W0142,W0234,E1306,W0222,E0202,W0612,C0202,W0199,W1628,W0611,W1614,C0328,F0401,C0303,W0122,W0104,W1623,W0640,W0108,E0602,E0105,E0211,W1601,W0120,E0235,E0108,W1300,W1608,F0202,E0222,W1302,W0403,E1601,E0239,W1621,W0101,E1302,C0203,E0104,W0410,W1616,W0109,E1305,E0238,E0603,C0327,C0326,W0621,E0109,E0101,W0404,W0102,W1612,W1607,W1304,W1613,E1606,E0221,W0150,W0613,E0611,E0100,E1304,C0103,E1608,E0213,F0220,W0223,W1622,C0121,W1617,W0231,W0105,W0106,W1501,W0711,E1605,W0604,W0602,W1627,W0212,W1503,E1301,W0301,W0311,W1606,W1305,W0233,W1306,W1618,W0402,W1626,E0106,E0102,W0632,W0401,W1615,W0633,E0601,W0702,W0704,W0614,W1604,E1602,W1624,W0406,E0203,W0623,C0102,E1300,E0111,E0711,C0321,W1603,E0237,W1401,W1632,E0604,W1303,E1310,W0232,W1631,C0330,E0107,W0601,W1307,W1611,E1607,W0603,W0107,W0221,W0312,W0710,W1629,W1402,C0112,W0703,W1630,E0103,W1610,W0631,E0710,W1502,W0110,E0712,C0304,E0703,E1303,E1603,W1301,W1609,E0110,W1620,W1625,W1633,E0702,E0001
-
-disable=E1200,R0901,I0020,I0013,R0914,E1120,I0001,W0512,C1001,F0001,R0923,C0301,E1127,R0922,R0915,I0011,E1102,E1002,F0010,E1123,E1111,C0103,C0302,E1121,R0921,F0002,W0511,W1201,R0903,R0902,I0010,C0401,R0904,I0021,I0022,E1126,R0913,E1205,E1001,E1004,E0012,R0801,C0402,R0911,E1125,E1101,E0011,W0332,W1001,W1111,I0012,E1003,R0912,E1206,E1124,E1201,F0003,W1202,R0201,C0111,C0325,W0141,W0201
-
-[FORMAT]
-
-expected-line-ending-format=LF
-
-[IMPORTS]
-
-deprecated-modules=optparse
diff --git a/asn1crypto/_elliptic_curve.py b/asn1crypto/_elliptic_curve.py
index bd18c67..7e41cc5 100644
--- a/asn1crypto/_elliptic_curve.py
+++ b/asn1crypto/_elliptic_curve.py
@@ -48,19 +48,8 @@
from __future__ import unicode_literals, division, absolute_import, print_function
-import sys
-
from ._int import inverse_mod
-if sys.version_info < (3,):
- byte_cls = str
- int_types = (int, long) #pylint: disable=E0602
-
-else:
- byte_cls = bytes
- int_types = int
-
-
class PrimeCurve():
"""
@@ -297,7 +286,7 @@
# NIST Curve P-384:
SECP384R1_CURVE = PrimeCurve(
- 39402006196394479212279040100143613805079739270465446667948293404245721771496870329047266088258938001861606973112319,
+ 39402006196394479212279040100143613805079739270465446667948293404245721771496870329047266088258938001861606973112319, # noqa
-3,
0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef
)
@@ -311,13 +300,13 @@
# NIST Curve P-521:
SECP521R1_CURVE = PrimeCurve(
- 6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151,
+ 6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151, # noqa
-3,
- 0x051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00
+ 0x051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00 # noqa
)
SECP521R1_BASE_POINT = PrimePoint(
SECP521R1_CURVE,
- 0xc6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66,
- 0x11839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650,
- 6864797660130609714981900799081393217269435300143305409394463459185543183397655394245057746333217197532963996371363321113864768612440380340372808892707005449
+ 0xc6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66, # noqa
+ 0x11839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650, # noqa
+ 6864797660130609714981900799081393217269435300143305409394463459185543183397655394245057746333217197532963996371363321113864768612440380340372808892707005449 # noqa
)
diff --git a/asn1crypto/_errors.py b/asn1crypto/_errors.py
index 6b38315..a96fcaa 100644
--- a/asn1crypto/_errors.py
+++ b/asn1crypto/_errors.py
@@ -1,24 +1,45 @@
# coding: utf-8
"""
-Helpers for creating exceptions. Exports the following items:
+Helper for formatting exception messages. Exports the following items:
- - object_name()
+ - single_line()
"""
from __future__ import unicode_literals, division, absolute_import, print_function
+import re
+import textwrap
-def object_name(value):
+
+def unwrap(string, *params):
"""
- :param value:
- A value to get the object name of
+ Takes a multi-line string and does the following:
+
+ - dedents
+ - converts newlines with text before and after into a single line
+ - strips leading and trailing whitespace
+
+ :param string:
+ The string to format
+
+ :param *params:
+ Params to interpolate into the string
:return:
- A unicode string of the object name
+ The formatted string
"""
- cls = value.__class__
- if cls.__module__ == 'builtins':
- return cls.__name__
- return '%s.%s' % (cls.__module__, cls.__name__)
+ output = textwrap.dedent(string)
+
+ # Unwrap lines, taking into account bulleted lists, ordered lists and
+ # underlines consisting of = signs
+ if output.find('\n') != -1:
+ output = re.sub('(?<=\\S)\n(?=[^ \n\t\\d\\*\\-=])', ' ', output)
+
+ if params:
+ output = output % params
+
+ output = output.strip()
+
+ return output
diff --git a/asn1crypto/_ffi.py b/asn1crypto/_ffi.py
index 375aeb3..d484195 100644
--- a/asn1crypto/_ffi.py
+++ b/asn1crypto/_ffi.py
@@ -53,7 +53,7 @@
def unicode_buffer(initializer):
return create_unicode_buffer(initializer)
- def bytes_from_buffer(buffer, maxlen=None): #pylint: disable=W0613
+ def bytes_from_buffer(buffer, maxlen=None):
return buffer.raw
def null():
diff --git a/asn1crypto/_int.py b/asn1crypto/_int.py
index 1011c5f..62adc21 100644
--- a/asn1crypto/_int.py
+++ b/asn1crypto/_int.py
@@ -39,7 +39,6 @@
from .util import int_to_bytes, int_from_bytes
-
# First try to use ctypes or cffi with OpenSSL for better performance
try:
try:
@@ -117,7 +116,7 @@
uc, vc, ud, vd = 1, 0, 0, 1
while c != 0:
q, c, d = divmod(d, c) + (c,)
- uc, vc, ud, vd = ud - q*uc, vd - q*vc, uc, vc
+ uc, vc, ud, vd = ud - q * uc, vd - q * vc, uc, vc
# At this point, d is the GCD, and ud*a+vd*p = d.
# If d == 1, this means that ud is a inverse.
diff --git a/asn1crypto/_ordereddict.py b/asn1crypto/_ordereddict.py
index 69af2c3..d4c107b 100644
--- a/asn1crypto/_ordereddict.py
+++ b/asn1crypto/_ordereddict.py
@@ -25,14 +25,12 @@
if not sys.version_info < (2, 7):
from collections import OrderedDict
-
else:
- from UserDict import DictMixin #pylint: disable=F0401
-
+ from UserDict import DictMixin
class OrderedDict(dict, DictMixin):
- def __init__(self, *args, **kwds): #pylint: disable=W0231
+ def __init__(self, *args, **kwds):
if len(args) > 1:
raise TypeError('expected at most 1 arguments, got %d' % len(args))
try:
@@ -78,7 +76,7 @@
if not self:
raise KeyError('dictionary is empty')
if last:
- key = reversed(self).next() #pylint: disable=E0111
+ key = reversed(self).next()
else:
key = iter(self).next()
value = self.pop(key)
@@ -125,7 +123,7 @@
if isinstance(other, OrderedDict):
if len(self) != len(other):
return False
- for p, q in zip(self.items(), other.items()):
+ for p, q in zip(self.items(), other.items()):
if p != q:
return False
return True
diff --git a/asn1crypto/_types.py b/asn1crypto/_types.py
new file mode 100644
index 0000000..30816c7
--- /dev/null
+++ b/asn1crypto/_types.py
@@ -0,0 +1,36 @@
+# coding: utf-8
+from __future__ import unicode_literals, division, absolute_import, print_function
+
+import sys
+import inspect
+
+
+if sys.version_info < (3,):
+ str_cls = unicode # noqa
+ byte_cls = str
+ int_types = (int, long) # noqa
+
+else:
+ str_cls = str
+ byte_cls = bytes
+ int_types = int
+
+
+def type_name(value):
+ """
+ Returns a user-readable name for the type of an object
+
+ :param value:
+ A value to get the type name of
+
+ :return:
+ A unicode string of the object's type name
+ """
+
+ if inspect.isclass(value):
+ cls = value
+ else:
+ cls = value.__class__
+ if cls.__module__ in set(['builtins', '__builtin__']):
+ return cls.__name__
+ return '%s.%s' % (cls.__module__, cls.__name__)
diff --git a/asn1crypto/_win/_ws2_32.py b/asn1crypto/_win/_ws2_32.py
index 51de74a..bba48dc 100644
--- a/asn1crypto/_win/_ws2_32.py
+++ b/asn1crypto/_win/_ws2_32.py
@@ -3,10 +3,18 @@
import socket
-from .._ffi import FFIEngineError, buffer_from_bytes, bytes_from_buffer, cast_void_p, is_null, unicode_buffer, string_from_buffer
+from .._ffi import (
+ buffer_from_bytes,
+ bytes_from_buffer,
+ cast_void_p,
+ FFIEngineError,
+ is_null,
+ string_from_buffer,
+ unicode_buffer,
+)
try:
- from ._ws2_32_cffi import ws2_32 #pylint: disable=W0611
+ from ._ws2_32_cffi import ws2_32
except (FFIEngineError):
from ._ws2_32_ctypes import ws2_32
diff --git a/asn1crypto/algos.py b/asn1crypto/algos.py
index a003d7e..b90bf30 100644
--- a/asn1crypto/algos.py
+++ b/asn1crypto/algos.py
@@ -18,6 +18,7 @@
from __future__ import unicode_literals, division, absolute_import, print_function
+from ._errors import unwrap
from .core import Any, Choice, Integer, ObjectIdentifier, OctetString, Sequence
@@ -225,7 +226,12 @@
if algorithm in algo_map:
return algo_map[algorithm]
- raise ValueError('Signature algorithm not known for %s' % algorithm)
+ raise ValueError(unwrap(
+ '''
+ Signature algorithm not known for %s
+ ''',
+ algorithm
+ ))
@property
def hash_algo(self):
@@ -260,7 +266,12 @@
if algorithm == 'rsassa_pss':
return self['parameters']['hash_algorithm']['algorithm'].native
- raise ValueError('Hash algorithm not known for %s' % algorithm)
+ raise ValueError(unwrap(
+ '''
+ Hash algorithm not known for %s
+ ''',
+ algorithm
+ ))
class Pbkdf2Salt(Choice):
@@ -450,7 +461,8 @@
Returns the name of the key derivation function to use.
:return:
- A unicode from of one of the following: "pbkdf1", "pbkdf2", "pkcs12_kdf"
+ A unicode from of one of the following: "pbkdf1", "pbkdf2",
+ "pkcs12_kdf"
"""
encryption_algo = self['algorithm'].native
@@ -468,9 +480,21 @@
if encryption_algo == 'pkcs12':
return 'pkcs12_kdf'
- raise ValueError('Encryption algorithm "%s" does not have a registered key derivation function' % encryption_algo)
+ raise ValueError(unwrap(
+ '''
+ Encryption algorithm "%s" does not have a registered key
+ derivation function
+ ''',
+ encryption_algo
+ ))
- raise ValueError('Unrecognized encryption algorithm "%s", can not determine key derivation function' % encryption_algo)
+ raise ValueError(unwrap(
+ '''
+ Unrecognized encryption algorithm "%s", can not determine key
+ derivation function
+ ''',
+ encryption_algo
+ ))
@property
def kdf_hmac(self):
@@ -478,7 +502,8 @@
Returns the HMAC algorithm to use with the KDF.
:return:
- A unicode string of one of the following: "md2", "md5", "sha1", "sha224", "sha256", "sha384", "sha512"
+ A unicode string of one of the following: "md2", "md5", "sha1",
+ "sha224", "sha256", "sha384", "sha512"
"""
encryption_algo = self['algorithm'].native
@@ -491,9 +516,21 @@
_, hmac_algo, _ = encryption_algo.split('_', 2)
return hmac_algo
- raise ValueError('Encryption algorithm "%s" does not have a registered key derivation function' % encryption_algo)
+ raise ValueError(unwrap(
+ '''
+ Encryption algorithm "%s" does not have a registered key
+ derivation function
+ ''',
+ encryption_algo
+ ))
- raise ValueError('Unrecognized encryption algorithm "%s", can not determine key derivation hmac algorithm' % encryption_algo)
+ raise ValueError(unwrap(
+ '''
+ Unrecognized encryption algorithm "%s", can not determine key
+ derivation hmac algorithm
+ ''',
+ encryption_algo
+ ))
@property
def kdf_salt(self):
@@ -510,7 +547,13 @@
salt = self['parameters']['key_derivation_func']['parameters']['salt']
if salt.name == 'other_source':
- raise ValueError('Can not determine key derivation salt - the reversed-for-future-use other source salt choice was specified in the PBKDF2 params structure')
+ raise ValueError(unwrap(
+ '''
+ Can not determine key derivation salt - the
+ reserved-for-future-use other source salt choice was
+ specified in the PBKDF2 params structure
+ '''
+ ))
return salt.native
@@ -518,9 +561,21 @@
if encryption_algo.find('_') != -1:
return self['parameters']['salt'].native
- raise ValueError('Encryption algorithm "%s" does not have a registered key derivation function' % encryption_algo)
+ raise ValueError(unwrap(
+ '''
+ Encryption algorithm "%s" does not have a registered key
+ derivation function
+ ''',
+ encryption_algo
+ ))
- raise ValueError('Unrecognized encryption algorithm "%s", can not determine key derivation salt' % encryption_algo)
+ raise ValueError(unwrap(
+ '''
+ Unrecognized encryption algorithm "%s", can not determine key
+ derivation salt
+ ''',
+ encryption_algo
+ ))
@property
def kdf_iterations(self):
@@ -540,9 +595,21 @@
if encryption_algo.find('_') != -1:
return self['parameters']['iterations'].native
- raise ValueError('Encryption algorithm "%s" does not have a registered key derivation function' % encryption_algo)
+ raise ValueError(unwrap(
+ '''
+ Encryption algorithm "%s" does not have a registered key
+ derivation function
+ ''',
+ encryption_algo
+ ))
- raise ValueError('Unrecognized encryption algorithm "%s", can not determine key derivation iterations' % encryption_algo)
+ raise ValueError(unwrap(
+ '''
+ Unrecognized encryption algorithm "%s", can not determine key
+ derivation iterations
+ ''',
+ encryption_algo
+ ))
@property
def key_length(self):
@@ -577,11 +644,12 @@
rc2_params = self['parameters'].parsed['encryption_scheme']['parameters'].parsed
rc2_parameter_version = rc2_params['rc2_parameter_version'].native
- # See page 24 of http://www.emc.com/collateral/white-papers/h11302-pkcs5v2-1-password-based-cryptography-standard-wp.pdf
+ # See page 24 of
+ # http://www.emc.com/collateral/white-papers/h11302-pkcs5v2-1-password-based-cryptography-standard-wp.pdf
encoded_key_bits_map = {
160: 5, # 40-bit
120: 8, # 64-bit
- 58: 16, # 128-bit
+ 58: 16, # 128-bit
}
if rc2_parameter_version in encoded_key_bits_map:
@@ -593,7 +661,12 @@
if rc2_parameter_version is None:
return 4 # 32-bit default
- raise ValueError('Invalid RC2 parameter version found in EncryptionAlgorithm parameters')
+ raise ValueError(unwrap(
+ '''
+ Invalid RC2 parameter version found in EncryptionAlgorithm
+ parameters
+ '''
+ ))
if encryption_algo == 'pbes2':
key_length = self['parameters']['key_derivation_func']['parameters']['key_length'].native
@@ -623,7 +696,12 @@
'pkcs12_sha1_rc2_40': 5,
}[encryption_algo]
- raise ValueError('Unrecognized encryption algorithm "%s"' % encryption_algo)
+ raise ValueError(unwrap(
+ '''
+ Unrecognized encryption algorithm "%s"
+ ''',
+ encryption_algo
+ ))
@property
def encryption_cipher(self):
@@ -633,7 +711,8 @@
between different variations of TripleDES, AES, and the RC* ciphers.
:return:
- A unicode string from one of the following: "rc2", "rc5", "des", "tripledes", "aes"
+ A unicode string from one of the following: "rc2", "rc5", "des",
+ "tripledes", "aes"
"""
encryption_algo = self['algorithm'].native
@@ -669,7 +748,12 @@
'pkcs12_sha1_rc2_40': 'rc2',
}[encryption_algo]
- raise ValueError('Unrecognized encryption algorithm "%s"' % encryption_algo)
+ raise ValueError(unwrap(
+ '''
+ Unrecognized encryption algorithm "%s"
+ ''',
+ encryption_algo
+ ))
@property
def encryption_block_size(self):
@@ -715,7 +799,12 @@
'pkcs12_sha1_rc2_40': 8,
}[encryption_algo]
- raise ValueError('Unrecognized encryption algorithm "%s"' % encryption_algo)
+ raise ValueError(unwrap(
+ '''
+ Unrecognized encryption algorithm "%s"
+ ''',
+ encryption_algo
+ ))
@property
def encryption_iv(self):
@@ -748,7 +837,12 @@
if encryption_algo.find('.') == -1:
return None
- raise ValueError('Unrecognized encryption algorithm "%s"' % encryption_algo)
+ raise ValueError(unwrap(
+ '''
+ Unrecognized encryption algorithm "%s"
+ ''',
+ encryption_algo
+ ))
class Pbes2Params(Sequence):
@@ -783,4 +877,4 @@
}
-EncryptionAlgorithm._oid_specs['pbes2'] = Pbes2Params #pylint: disable=W0212
+EncryptionAlgorithm._oid_specs['pbes2'] = Pbes2Params
diff --git a/asn1crypto/cms.py b/asn1crypto/cms.py
index a0c503a..2fbb646 100644
--- a/asn1crypto/cms.py
+++ b/asn1crypto/cms.py
@@ -52,7 +52,6 @@
from .x509 import Attributes, Certificate, Extensions, GeneralNames, Name
-
# These structures are taken from
# ftp://ftp.rsasecurity.com/pub/pkcs/ascii/pkcs-6.asc
@@ -63,6 +62,7 @@
('attributes', Attributes),
]
+
class ExtendedCertificate(Sequence):
_fields = [
('extended_certificate_info', ExtendedCertificateInfo),
@@ -661,7 +661,7 @@
return self._decompressed
-ContentInfo._oid_specs = { #pylint: disable=W0212
+ContentInfo._oid_specs = {
'data': OctetString,
'signed_data': SignedData,
'enveloped_data': EnvelopedData,
@@ -674,7 +674,7 @@
}
-EncapsulatedContentInfo._oid_specs = { #pylint: disable=W0212
+EncapsulatedContentInfo._oid_specs = {
'signed_data': SignedData,
'enveloped_data': EnvelopedData,
'signed_and_enveloped_data': SignedAndEnvelopedData,
@@ -686,7 +686,7 @@
}
-CMSAttribute._oid_specs = { #pylint: disable=W0212
+CMSAttribute._oid_specs = {
'content_type': SetOfContentType,
'message_digest': SetOfOctetString,
'signing_time': SetOfTime,
diff --git a/asn1crypto/core.py b/asn1crypto/core.py
index b55c42e..754306d 100644
--- a/asn1crypto/core.py
+++ b/asn1crypto/core.py
@@ -54,25 +54,20 @@
from . import _teletex_codec
from ._ordereddict import OrderedDict
+from ._errors import unwrap
+from ._types import type_name, str_cls, byte_cls, int_types
from .util import int_to_bytes, int_from_bytes, timezone
-from ._errors import object_name
# Python 2
if sys.version_info <= (3,):
- str_cls = unicode #pylint: disable=E0602
- byte_cls = str
- int_types = (int, long) #pylint: disable=E0602
py2 = True
chr_cls = chr
- range = xrange #pylint: disable=E0602,W0622
+ range = xrange # noqa
from datetime import timedelta
- from cStringIO import StringIO as BytesIO #pylint: disable=F0401
+ from cStringIO import StringIO as BytesIO
# Python 3
else:
- str_cls = str
- byte_cls = bytes
- int_types = int
py2 = False
from io import BytesIO
@@ -80,7 +75,6 @@
return bytes([num])
-
_teletex_codec.register()
@@ -115,7 +109,6 @@
_SETUP_CLASSES = {}
-
class Asn1Value(object):
"""
The basis of all ASN.1 values
@@ -169,7 +162,6 @@
value, _ = _parse_build(encoded_data, spec=spec, spec_params=kwargs)
return value
- #pylint: disable=W0613
def __init__(self, tag_type=None, class_=None, tag=None, optional=None, default=None, contents=None):
"""
The optional parameter is not used, but rather included so we don't
@@ -214,18 +206,34 @@
if tag_type is not None:
if tag_type not in ('implicit', 'explicit'):
- raise ValueError('tag_type must be one of "implicit", "explicit", not %s' % repr(tag_type))
+ raise ValueError(unwrap(
+ '''
+ tag_type must be one of "implicit", "explicit", not %s
+ ''',
+ repr(tag_type)
+ ))
self.tag_type = tag_type
if class_ is None:
class_ = 'context'
if class_ not in CLASS_NAME_TO_NUM_MAP:
- raise ValueError('class_ must be one of "universal", "application", "context", "private", not %s' % repr(class_))
+ raise ValueError(unwrap(
+ '''
+ class_ must be one of "universal", "application",
+ "context", "private", not %s
+ ''',
+ repr(class_)
+ ))
class_ = CLASS_NAME_TO_NUM_MAP[class_]
if tag is not None:
if not isinstance(tag, int_types):
- raise ValueError('tag must be an integer, not %s' % object_name(tag))
+ raise TypeError(unwrap(
+ '''
+ tag must be an integer, not %s
+ ''',
+ type_name(tag)
+ ))
if tag_type == 'implicit':
self.class_ = class_
@@ -236,7 +244,13 @@
else:
if class_ is not None:
if class_ not in CLASS_NUM_TO_NAME_MAP:
- raise ValueError('class_ must be one of "universal", "application", "context", "private", not %s' % repr(class_))
+ raise ValueError(unwrap(
+ '''
+ class_ must be one of "universal", "application",
+ "context", "private", not %s
+ ''',
+ repr(class_)
+ ))
self.class_ = CLASS_NAME_TO_NUM_MAP[class_]
if tag is not None:
@@ -248,9 +262,9 @@
elif default is not None:
self.set(default)
- except (ValueError) as e:
+ except (ValueError, TypeError) as e:
args = e.args[1:]
- e.args = (e.args[0] + '\n while constructing %s' % object_name(self),) + args
+ e.args = (e.args[0] + '\n while constructing %s' % type_name(self),) + args
raise e
def __str__(self):
@@ -273,7 +287,7 @@
A unicode string
"""
- return '<%s %s %s>' % (object_name(self), id(self), repr(self.contents or b''))
+ return '<%s %s %s>' % (type_name(self), id(self), repr(self.contents or b''))
def copy(self):
"""
@@ -288,7 +302,7 @@
new_obj.tag = self.tag
new_obj.explicit_class = self.explicit_class
new_obj.explicit_tag = self.explicit_tag
- new_obj._copy(self) #pylint: disable=W0212
+ new_obj._copy(self)
return new_obj
def retag(self, tag_type, tag):
@@ -306,7 +320,7 @@
"""
new_obj = self.__class__(tag_type=tag_type, tag=tag)
- new_obj._copy(self) #pylint: disable=W0212
+ new_obj._copy(self)
return new_obj
def untag(self):
@@ -318,10 +332,9 @@
"""
new_obj = self.__class__()
- new_obj._copy(self) #pylint: disable=W0212
+ new_obj._copy(self)
return new_obj
- #pylint: disable=W0212
def _copy(self, other):
"""
Copies the contents of another Asn1Value object to itself
@@ -331,7 +344,13 @@
"""
if self.__class__ != other.__class__:
- raise ValueError('Can not copy values from %s object to %s object' % (object_name(other), object_name(self)))
+ raise TypeError(unwrap(
+ '''
+ Can not copy values from %s object to %s object
+ ''',
+ type_name(other),
+ type_name(self)
+ ))
self.contents = other.contents
self._native = other._native
@@ -401,7 +420,6 @@
# from _map the first time it is needed
_reverse_map = None
- #pylint: disable=W0212
def _setup(self):
"""
Generates _reverse_map from _map
@@ -453,7 +471,6 @@
return b''
-
class Any(Asn1Value):
"""
A value class that can contain any value, and allows for easy parsing of
@@ -478,14 +495,19 @@
try:
if value is not None:
if not isinstance(value, Asn1Value):
- raise ValueError('value must be an instance of Ans1Value, not %s' % object_name(value))
+ raise TypeError(unwrap(
+ '''
+ value must be an instance of Ans1Value, not %s
+ ''',
+ type_name(value)
+ ))
self._parsed = (value, value.__class__, None)
self.contents = value.dump()
- except (ValueError) as e:
+ except (ValueError, TypeError) as e:
args = e.args[1:]
- e.args = (e.args[0] + '\n while constructing %s' % object_name(self),) + args
+ e.args = (e.args[0] + '\n while constructing %s' % type_name(self),) + args
raise e
@property
@@ -541,11 +563,15 @@
passed_params = {} if not spec_params else spec_params.copy()
passed_params['tag_type'] = self.tag_type
passed_params['tag'] = self.tag
- parsed_value, _ = _parse_build(self._header + self.contents + self._trailer, spec=spec, spec_params=passed_params)
+ parsed_value, _ = _parse_build(
+ self._header + self.contents + self._trailer,
+ spec=spec,
+ spec_params=passed_params
+ )
self._parsed = (parsed_value, spec, spec_params)
- except (ValueError) as e:
+ except (ValueError, TypeError) as e:
args = e.args[1:]
- e.args = (e.args[0] + '\n while parsing %s' % object_name(self),) + args
+ e.args = (e.args[0] + '\n while parsing %s' % type_name(self),) + args
raise e
return self._parsed[0]
@@ -598,7 +624,6 @@
# A dict that maps alternative names to an index in _alternatives
_name_map = None
- #pylint: disable=W0212
def _setup(self):
"""
Generates _id_map from _alternatives to allow validating contents
@@ -636,11 +661,24 @@
try:
if tag_type == 'implicit':
- raise ValueError('The Choice type can not be implicitly tagged even if in an implicit module - due to its nature any tagging must be explicit')
+ raise ValueError(unwrap(
+ '''
+ The Choice type can not be implicitly tagged even if in an
+ implicit module - due to its nature any tagging must be
+ explicit
+ '''
+ ))
if name is not None:
if name not in self._name_map:
- raise ValueError('The name specified, "%s", is not a valid alternative for %s' % (name, object_name(self)))
+ raise ValueError(unwrap(
+ '''
+ The name specified, "%s", is not a valid alternative
+ for %s
+ ''',
+ name,
+ type_name(self)
+ ))
self._choice = self._name_map[name]
info = self._alternatives[self._choice]
@@ -653,9 +691,9 @@
value = _fix_tagging(value, params)
self._parsed = value
- except (ValueError) as e:
+ except (ValueError, TypeError) as e:
args = e.args[1:]
- e.args = (e.args[0] + '\n while constructing %s' % object_name(self),) + args
+ e.args = (e.args[0] + '\n while constructing %s' % type_name(self),) + args
raise e
@property
@@ -683,9 +721,9 @@
info = self._alternatives[self._choice]
params = info[2] if len(info) > 2 else {}
self._parsed, _ = _parse_build(self.contents, spec=info[1], spec_params=params)
- except (ValueError) as e:
+ except (ValueError, TypeError) as e:
args = e.args[1:]
- e.args = (e.args[0] + '\n while parsing %s' % object_name(self),) + args
+ e.args = (e.args[0] + '\n while parsing %s' % type_name(self),) + args
raise e
@property
@@ -731,15 +769,29 @@
# This means the Choice was implicitly tagged
if self.class_ is not None and self.tag is not None:
if len(self._alternatives) > 1:
- raise ValueError('%s was implicitly tagged, but more than one alternative exists' % object_name(self))
+ raise ValueError(unwrap(
+ '''
+ %s was implicitly tagged, but more than one alternative
+ exists
+ ''',
+ type_name(self)
+ ))
if id_ == (self.class_, self.tag):
self._choice = 0
return
asn1 = self._format_class_tag(class_, tag)
- asn1s = [self._format_class_tag(id_[0], id_[1]) for id_ in self._id_map]
+ asn1s = [self._format_class_tag(pair[0], pair[1]) for pair in self._id_map]
- raise ValueError('Value %s did not match the class and tag of any of the alternatives in %s: %s' % (asn1, object_name(self), '. '.join(asn1s)))
+ raise ValueError(unwrap(
+ '''
+ Value %s did not match the class and tag of any of the alternatives
+ in %s: %s
+ ''',
+ asn1,
+ type_name(self),
+ '. '.join(asn1s)
+ ))
def _format_class_tag(self, class_, tag):
"""
@@ -749,7 +801,6 @@
return '[%s %s]' % (CLASS_NUM_TO_NAME_MAP[class_].upper(), tag)
- #pylint: disable=W0212
def _copy(self, other):
"""
Copies the contents of another Asn1Value object to itself
@@ -759,7 +810,13 @@
"""
if self.__class__ != other.__class__:
- raise ValueError('Can not copy values from %s object to %s object' % (object_name(other), object_name(self)))
+ raise TypeError(unwrap(
+ '''
+ Can not copy values from %s object to %s object
+ ''',
+ type_name(other),
+ type_name(self)
+ ))
self.contents = other.contents
self._native = other._native
@@ -823,9 +880,9 @@
elif default is not None:
self.set(default)
- except (ValueError) as e:
+ except (ValueError, TypeError) as e:
args = e.args[1:]
- e.args = (e.args[0] + '\n while constructing %s' % object_name(self),) + args
+ e.args = (e.args[0] + '\n while constructing %s' % type_name(self),) + args
raise e
def set(self, value):
@@ -837,7 +894,13 @@
"""
if not isinstance(value, byte_cls):
- raise ValueError('%s value must be a byte string, not %s' % (object_name(self), object_name(value)))
+ raise TypeError(unwrap(
+ '''
+ %s value must be a byte string, not %s
+ ''',
+ type_name(self),
+ type_name(value)
+ ))
self._native = value
self.contents = value
@@ -924,7 +987,13 @@
"""
if not isinstance(value, str_cls):
- raise ValueError('%s value must be a unicode string, not %s' % (object_name(self), object_name(value)))
+ raise TypeError(unwrap(
+ '''
+ %s value must be a unicode string, not %s
+ ''',
+ type_name(self),
+ type_name(value)
+ ))
self._native = value
self.contents = value.encode(self._encoding)
@@ -1030,15 +1099,33 @@
if isinstance(value, str_cls):
if self._map is None:
- raise ValueError('%s value is a unicode string, but no _map provided' % object_name(self))
+ raise ValueError(unwrap(
+ '''
+ %s value is a unicode string, but no _map provided
+ ''',
+ type_name(self)
+ ))
if value not in self._reverse_map:
- raise ValueError('%s value, %s, is not present in the _map' % (object_name(self), value))
+ raise ValueError(unwrap(
+ '''
+ %s value, %s, is not present in the _map
+ ''',
+ type_name(self),
+ value
+ ))
value = self._reverse_map[value]
elif not isinstance(value, int_types):
- raise ValueError('%s value must be an integer or unicode string when a name_map is provided, not %s' % (object_name(self), object_name(value)))
+ raise TypeError(unwrap(
+ '''
+ %s value must be an integer or unicode string when a name_map
+ is provided, not %s
+ ''',
+ type_name(self),
+ type_name(value)
+ ))
self._native = self._map[value] if self._map and value in self._map else value
@@ -1082,7 +1169,6 @@
_size = None
- #pylint: disable=W0212
def _setup(self):
"""
Generates _reverse_map from _map
@@ -1107,7 +1193,12 @@
if isinstance(value, set):
if self._map is None:
- raise ValueError('%s _map has not been defined' % object_name(self))
+ raise ValueError(unwrap(
+ '''
+ %s _map has not been defined
+ ''',
+ type_name(self)
+ ))
bits = [0] * self._size
self._native = value
@@ -1132,12 +1223,26 @@
value = ''.join(map(str_cls, value))
else:
- raise ValueError('%s value must be a tuple of ones and zeros or a set of unicode strings, not %s' % (object_name(self), object_name(value)))
+ raise TypeError(unwrap(
+ '''
+ %s value must be a tuple of ones and zeros or a set of unicode
+ strings, not %s
+ ''',
+ type_name(self),
+ type_name(value)
+ ))
if self._map is not None:
size = self._size
if len(value) > size:
- raise ValueError('%s value must be at most %s bits long, specified was %s long' % (object_name(self), size, len(value)))
+ raise ValueError(unwrap(
+ '''
+ %s value must be at most %s bits long, specified was %s long
+ ''',
+ type_name(self),
+ size,
+ len(value)
+ ))
value += '0' * (size - len(value))
else:
size = len(value)
@@ -1185,13 +1290,24 @@
is_int = isinstance(key, int_types)
if not is_int:
if not isinstance(self._map, dict):
- raise ValueError('%s _map has not been defined' % object_name(self))
+ raise ValueError(unwrap(
+ '''
+ %s _map has not been defined
+ ''',
+ type_name(self)
+ ))
if key not in self._reverse_map:
- raise ValueError('%s _map does not contain an entry for "%s"' % (object_name(self), key))
+ raise ValueError(unwrap(
+ '''
+ %s _map does not contain an entry for "%s"
+ ''',
+ type_name(self),
+ key
+ ))
if self._native is None:
- _ = self.native
+ self.native
if self._map is None:
if len(self._native) >= key + 1:
@@ -1220,13 +1336,24 @@
is_int = isinstance(key, int_types)
if not is_int:
if self._map is None:
- raise ValueError('%s _map has not been defined' % object_name(self))
+ raise ValueError(unwrap(
+ '''
+ %s _map has not been defined
+ ''',
+ type_name(self)
+ ))
if key not in self._reverse_map:
- raise ValueError('%s _map does not contain an entry for "%s"' % (object_name(self), key))
+ raise ValueError(unwrap(
+ '''
+ %s _map does not contain an entry for "%s"
+ ''',
+ type_name(self),
+ key
+ ))
if self._native is None:
- _ = self.native
+ self.native
if self._map is None:
new_native = list(self._native)
@@ -1278,7 +1405,7 @@
# Trim off the extra bits on the right used to fill the last byte
if extra_bits > 0:
- bit_string = bit_string[0:0-extra_bits]
+ bit_string = bit_string[0:0 - extra_bits]
bits = tuple(map(int, tuple(bit_string)))
if self._map:
@@ -1311,7 +1438,13 @@
"""
if not isinstance(value, byte_cls):
- raise ValueError('%s value must be a byte string, not %s' % (object_name(self), object_name(value)))
+ raise TypeError(unwrap(
+ '''
+ %s value must be a byte string, not %s
+ ''',
+ type_name(self),
+ type_name(value)
+ ))
self._native = value
# Set the unused bits to 0
@@ -1368,7 +1501,13 @@
"""
if not isinstance(value, int_types):
- raise ValueError('%s value must be an integer, not %s' % (object_name(self), object_name(value)))
+ raise TypeError(unwrap(
+ '''
+ %s value must be an integer, not %s
+ ''',
+ type_name(self),
+ type_name(value)
+ ))
self._native = value
# Set the unused bits to 0
@@ -1393,7 +1532,7 @@
extra_bits = int_from_bytes(self.contents[0:1])
if extra_bits > 0:
bit_string = '{0:b}'.format(int_from_bytes(self.contents[1:]))
- bit_string = bit_string[0:0-extra_bits]
+ bit_string = bit_string[0:0 - extra_bits]
self._native = int(bit_string, 2)
else:
self._native = int_from_bytes(self.contents[1:])
@@ -1451,7 +1590,13 @@
"""
if not isinstance(value, int_types):
- raise ValueError('%s value must be an integer, not %s' % (object_name(self), object_name(value)))
+ raise TypeError(unwrap(
+ '''
+ %s value must be an integer, not %s
+ ''',
+ type_name(self),
+ type_name(value)
+ ))
self._native = value
# Set the unused bits to 0
@@ -1572,7 +1717,6 @@
return self._parsed[0]
- #pylint: disable=W0212
def _copy(self, other):
"""
Copies the contents of another ParsableOctetString object to itself
@@ -1582,7 +1726,13 @@
"""
if self.__class__ != other.__class__:
- raise ValueError('Can not copy values from %s object to %s object' % (object_name(other), object_name(self)))
+ raise TypeError(unwrap(
+ '''
+ Can not copy values from %s object to %s object
+ ''',
+ type_name(other),
+ type_name(self)
+ ))
self.contents = other.contents
self._native = other._native
@@ -1627,7 +1777,13 @@
"""
if not isinstance(value, byte_cls):
- raise ValueError('%s value must be a byte string, not %s' % (object_name(self), object_name(value)))
+ raise TypeError(unwrap(
+ '''
+ %s value must be a byte string, not %s
+ ''',
+ type_name(self),
+ type_name(value)
+ ))
self._native = value
# Set the unused bits to 0
@@ -1701,7 +1857,13 @@
"""
if not isinstance(value, str_cls):
- raise ValueError('%s value must be a unicode string, not %s' % (object_name(self), object_name(value)))
+ raise TypeError(unwrap(
+ '''
+ %s value must be a unicode string, not %s
+ ''',
+ type_name(self),
+ type_name(value)
+ ))
self._native = value
@@ -1821,16 +1983,34 @@
"""
if not isinstance(value, int_types) and not isinstance(value, str_cls):
- raise ValueError('%s value must be an integer or a unicode string, not %s' % (object_name(self), object_name(value)))
+ raise TypeError(unwrap(
+ '''
+ %s value must be an integer or a unicode string, not %s
+ ''',
+ type_name(self),
+ type_name(value)
+ ))
if isinstance(value, str_cls):
if value not in self._reverse_map:
- raise ValueError('%s value "%s" is not a valid value' % (object_name(self), value))
+ raise ValueError(unwrap(
+ '''
+ %s value "%s" is not a valid value
+ ''',
+ type_name(self),
+ value
+ ))
value = self._reverse_map[value]
elif value not in self._map:
- raise ValueError('%s value %s is not a valid value' % (object_name(self), value))
+ raise ValueError(unwrap(
+ '''
+ %s value %s is not a valid value
+ ''',
+ type_name(self),
+ value
+ ))
Integer.set(self, value)
@@ -1968,9 +2148,9 @@
if key in value:
self.__setitem__(key, value[key])
- except (ValueError) as e:
+ except (ValueError, TypeError) as e:
args = e.args[1:]
- e.args = (e.args[0] + '\n while constructing %s' % object_name(self),) + args
+ e.args = (e.args[0] + '\n while constructing %s' % type_name(self),) + args
raise e
@property
@@ -2008,7 +2188,7 @@
if self.children is not None:
for child in self.children:
if isinstance(child, Sequence) or isinstance(child, SequenceOf):
- mutated = mutated or child._is_mutated() #pylint: disable=W0212
+ mutated = mutated or child._is_mutated()
return mutated
@@ -2054,11 +2234,23 @@
if not isinstance(key, int_types):
if key not in self._field_map:
- raise KeyError('No field named "%s" defined for %s' % (key, object_name(self)))
+ raise KeyError(unwrap(
+ '''
+ No field named "%s" defined for %s
+ ''',
+ key,
+ type_name(self)
+ ))
key = self._field_map[key]
if key >= len(self.children):
- raise KeyError('No field numbered %s is present in this %s' % (key, object_name(self)))
+ raise KeyError(unwrap(
+ '''
+ No field numbered %s is present in this %s
+ ''',
+ key,
+ type_name(self)
+ ))
return self._lazy_child(key)
@@ -2083,7 +2275,13 @@
if not isinstance(key, int_types):
if key not in self._field_map:
- raise KeyError('No field named "%s" defined for %s' % (key, object_name(self)))
+ raise KeyError(unwrap(
+ '''
+ No field named "%s" defined for %s
+ ''',
+ key,
+ type_name(self)
+ ))
key = self._field_map[key]
field_name, field_spec, value_spec, field_params, _ = self._determine_spec(key)
@@ -2099,7 +2297,13 @@
invalid_value = new_value.contents is None
if invalid_value:
- raise ValueError('Value for field "%s" of %s is not set' % (field_name, object_name(self)))
+ raise ValueError(unwrap(
+ '''
+ Value for field "%s" of %s is not set
+ ''',
+ field_name,
+ type_name(self)
+ ))
self.children[key] = new_value
@@ -2124,12 +2328,25 @@
if not isinstance(key, int_types):
if key not in self._field_map:
- raise KeyError('No field named "%s" defined for %s' % (key, object_name(self)))
+ raise KeyError(unwrap(
+ '''
+ No field named "%s" defined for %s
+ ''',
+ key,
+ type_name(self)
+ ))
key = self._field_map[key]
info = self._fields[key]
if len(info) < 3 or ('default' not in info[2] and 'optional' not in info[2]):
- raise ValueError('Can not delete the value for the field "%s" of %s since it is not optional or defaulted' % (info[0], object_name(self)))
+ raise ValueError(unwrap(
+ '''
+ Can not delete the value for the field "%s" of %s since it is
+ not optional or defaulted
+ ''',
+ info[0],
+ type_name(self)
+ ))
if 'optional' in info[2]:
self.children[key] = NoValue()
@@ -2139,7 +2356,7 @@
self.__setitem__(key, None)
self._mutated = True
- def __iter__(self): #pylint: disable=W0234
+ def __iter__(self):
"""
:return:
An iterator of field key names
@@ -2185,7 +2402,6 @@
if self._trailer != b'':
self._trailer = b''
- #pylint: disable=W0212
def _setup(self):
"""
Generates _field_map, _field_ids and _oid_nums for use in parsing
@@ -2232,7 +2448,7 @@
# Allow a spec callback to specify both the base spec and
# the override, for situations such as OctetString and parse_as
if isinstance(spec_override, tuple) and len(spec_override) == 2:
- field_spec, value_spec = spec_override #pylint: disable=W0633
+ field_spec, value_spec = spec_override
if value_spec is None:
value_spec = field_spec
spec_override = None
@@ -2275,11 +2491,18 @@
if issubclass(value_spec, Choice):
if not isinstance(value, Asn1Value):
- raise ValueError('Can not set a native python value to %s, which has the choice type of %s – value must be an instance of Asn1Value' % (field_name, value_spec.__name__))
+ raise ValueError(unwrap(
+ '''
+ Can not set a native python value to %s, which has the
+ choice type of %s – value must be an instance of Asn1Value
+ ''',
+ field_name,
+ type_name(value_spec)
+ ))
if not isinstance(value, value_spec):
wrapper = value_spec()
wrapper.validate(value.class_, value.tag)
- wrapper._parsed = value #pylint: disable=W0212
+ wrapper._parsed = value
new_value = wrapper
else:
new_value = value
@@ -2303,7 +2526,7 @@
# appropriate encoded value.
if specs_different and not is_any:
wrapper = field_spec(value=new_value.dump(), **field_params)
- wrapper._parsed = (new_value, new_value.__class__, None) #pylint: disable=W0212
+ wrapper._parsed = (new_value, new_value.__class__, None)
new_value = wrapper
new_value = _fix_tagging(new_value, field_params)
@@ -2360,7 +2583,7 @@
tester = field_spec(**field_params)
tester.validate(*id_)
choice_match = True
- except (ValueError): #pylint: disable=W0704
+ except (ValueError):
pass
if not choice_match:
@@ -2393,17 +2616,18 @@
prev_field -= 1
plural = 's' if len(missed_fields) > 1 else ''
missed_field_names = ', '.join(missed_fields)
- raise ValueError(
- 'Data for field %s (%s class, %s method, tag %s) does not match the field definition%s of %s' %
- (
- seen_field,
- CLASS_NUM_TO_NAME_MAP.get(parts[0]),
- METHOD_NUM_TO_NAME_MAP.get(parts[1]),
- parts[2],
- plural,
- missed_field_names
- )
- )
+ raise ValueError(unwrap(
+ '''
+ Data for field %s (%s class, %s method, tag %s) does
+ not match the field definition%s of %s
+ ''',
+ seen_field,
+ CLASS_NUM_TO_NAME_MAP.get(parts[0]),
+ METHOD_NUM_TO_NAME_MAP.get(parts[1]),
+ parts[2],
+ plural,
+ missed_field_names
+ ))
else:
child = parts
@@ -2411,7 +2635,7 @@
if recurse:
child = _build(*child)
if isinstance(child, (Sequence, SequenceOf)):
- child._parse_children(recurse=True) #pylint: disable=W0212
+ child._parse_children(recurse=True)
self.children.append(child)
child_pointer += num_bytes
@@ -2429,12 +2653,17 @@
elif 'optional' in field_params:
self.children.append(NoValue())
else:
- raise ValueError('Field "%s" is missing from structure' % field_info[0])
+ raise ValueError(unwrap(
+ '''
+ Field "%s" is missing from structure
+ ''',
+ field_info[0]
+ ))
index += 1
- except (ValueError) as e:
+ except (ValueError, TypeError) as e:
args = e.args[1:]
- e.args = (e.args[0] + '\n while parsing %s' % object_name(self),) + args
+ e.args = (e.args[0] + '\n while parsing %s' % type_name(self),) + args
raise e
def spec(self, field_name):
@@ -2454,10 +2683,22 @@
"""
if not isinstance(field_name, str_cls):
- raise ValueError('field_name must be a unicode string, not %s' % object_name(field_name))
+ raise TypeError(unwrap(
+ '''
+ field_name must be a unicode string, not %s
+ ''',
+ type_name(field_name)
+ ))
if self._fields is None:
- raise ValueError('Unable to retrieve spec for field %s in the class %s because _fields has not been set' % (repr(field_name), object_name(self)))
+ raise ValueError(unwrap(
+ '''
+ Unable to retrieve spec for field %s in the class %s because
+ _fields has not been set
+ ''',
+ repr(field_name),
+ type_name(self)
+ ))
index = self._field_map[field_name]
info = self._determine_spec(index)
@@ -2492,7 +2733,6 @@
self._native[name] = child.native
return self._native
- #pylint: disable=W0212
def _copy(self, other):
"""
Copies the contents of another Asn1Value object to itself
@@ -2502,7 +2742,13 @@
"""
if self.__class__ != other.__class__:
- raise ValueError('Can not copy values from %s object to %s object' % (object_name(other), object_name(self)))
+ raise TypeError(unwrap(
+ '''
+ Can not copy values from %s object to %s object
+ ''',
+ type_name(other),
+ type_name(self)
+ ))
self.contents = other.contents
self._native = other._native
@@ -2610,9 +2856,9 @@
if self.contents is None:
self._set_contents()
- except (ValueError) as e:
+ except (ValueError, TypeError) as e:
args = e.args[1:]
- e.args = (e.args[0] + '\n while constructing %s' % object_name(self),) + args
+ e.args = (e.args[0] + '\n while constructing %s' % type_name(self),) + args
raise e
@property
@@ -2650,7 +2896,7 @@
if self.children is not None:
for child in self.children:
if isinstance(child, Sequence) or isinstance(child, SequenceOf):
- mutated = mutated or child._is_mutated() #pylint: disable=W0212
+ mutated = mutated or child._is_mutated()
return mutated
@@ -2684,15 +2930,29 @@
if isinstance(value, Asn1Value):
new_value = value
else:
- raise ValueError('Can not set a native python value to %s where the _child_spec is Any – value must be an instance of Asn1Value' % object_name(self))
+ raise ValueError(unwrap(
+ '''
+ Can not set a native python value to %s where the
+ _child_spec is Any – value must be an instance of Asn1Value
+ ''',
+ type_name(self)
+ ))
elif issubclass(self._child_spec, Choice):
if not isinstance(value, Asn1Value):
- raise ValueError('Can not set a native python value to %s where the _child_spec is the choice type %s – value must be an instance of Asn1Value' % (object_name(self), self._child_spec.__name__))
+ raise ValueError(unwrap(
+ '''
+ Can not set a native python value to %s where the
+ _child_spec is the choice type %s – value must be an
+ instance of Asn1Value
+ ''',
+ type_name(self),
+ self._child_spec.__name__
+ ))
if not isinstance(value, self._child_spec):
wrapper = self._child_spec()
wrapper.validate(value.class_, value.tag)
- wrapper._parsed = value #pylint: disable=W0212
+ wrapper._parsed = value
value = wrapper
new_value = value
@@ -2783,7 +3043,7 @@
self._mutated = True
- def __iter__(self): #pylint: disable=W0234
+ def __iter__(self):
"""
:return:
An iter() of child objects
@@ -2864,12 +3124,12 @@
if recurse:
child = _build(*child)
if isinstance(child, (Sequence, SequenceOf)):
- child._parse_children(recurse=True) #pylint: disable=W0212
+ child._parse_children(recurse=True)
self.children.append(child)
child_pointer += num_bytes
- except (ValueError) as e:
+ except (ValueError, TypeError) as e:
args = e.args[1:]
- e.args = (e.args[0] + '\n while parsing %s' % object_name(self),) + args
+ e.args = (e.args[0] + '\n while parsing %s' % type_name(self),) + args
raise e
def spec(self):
@@ -2902,7 +3162,6 @@
self._native = [child.native for child in self]
return self._native
- #pylint: disable=W0212
def _copy(self, other):
"""
Copies the contents of another Asn1Value object to itself
@@ -2912,7 +3171,13 @@
"""
if self.__class__ != other.__class__:
- raise ValueError('Can not copy values from %s object to %s object' % (object_name(other), object_name(self)))
+ raise TypeError(unwrap(
+ '''
+ Can not copy values from %s object to %s object
+ ''',
+ type_name(other),
+ type_name(self)
+ ))
self.contents = other.contents
self._native = other._native
@@ -2969,7 +3234,6 @@
# as values that are the index of the field in _fields
_field_ids = None
- #pylint: disable=W0212
def _setup(self):
"""
Generates _field_map, _field_ids and _oid_nums for use in parsing
@@ -3030,7 +3294,7 @@
if recurse:
child = _build(*child)
if isinstance(child, (Sequence, SequenceOf)):
- child._parse_children(recurse=True) #pylint: disable=W0212
+ child._parse_children(recurse=True)
child_map[field] = child
child_pointer += num_bytes
@@ -3054,15 +3318,21 @@
child_map[index] = field_info[1](**field_info[2])
if missing:
- raise ValueError('Missing required field "%s" from %s' % (field_info[0], object_name(self)))
+ raise ValueError(unwrap(
+ '''
+ Missing required field "%s" from %s
+ ''',
+ field_info[0],
+ type_name(self)
+ ))
self.children = []
for index in range(0, total_fields):
self.children.append(child_map[index])
- except (ValueError) as e:
+ except (ValueError, TypeError) as e:
args = e.args[1:]
- e.args = (e.args[0] + '\n while parsing %s' % object_name(self),) + args
+ e.args = (e.args[0] + '\n while parsing %s' % type_name(self),) + args
raise e
@@ -3222,6 +3492,7 @@
return string
+
class GeneralizedTime(AbstractTime):
"""
Represents a generalized time from ASN.1 as a Python datetime.datetime
@@ -3348,9 +3619,9 @@
The object to print the debugging information about
"""
- print('%s%s Object #%s' % (prefix, object_name(self), id(self)))
- if self._header: #pylint: disable=W0212
- print('%s Header: 0x%s' % (prefix, binascii.hexlify(self._header or b'').decode('utf-8'))) #pylint: disable=W0212
+ print('%s%s Object #%s' % (prefix, type_name(self), id(self)))
+ if self._header:
+ print('%s Header: 0x%s' % (prefix, binascii.hexlify(self._header or b'').decode('utf-8')))
has_header = self.method is not None and self.class_ is not None and self.tag is not None
if has_header:
@@ -3358,12 +3629,21 @@
class_name = CLASS_NUM_TO_NAME_MAP.get(self.class_)
if self.tag_type == 'explicit':
- print('%s %s tag %s (explicitly tagged)' % (prefix, CLASS_NUM_TO_NAME_MAP.get(self.explicit_class), self.explicit_tag))
+ print(
+ '%s %s tag %s (explicitly tagged)' %
+ (
+ prefix,
+ CLASS_NUM_TO_NAME_MAP.get(self.explicit_class),
+ self.explicit_tag
+ )
+ )
if has_header:
print('%s %s %s %s' % (prefix, method_name, class_name, self.tag))
+
elif self.tag_type == 'implicit':
if has_header:
print('%s %s %s tag %s (implicitly tagged)' % (prefix, method_name, class_name, self.tag))
+
elif has_header:
print('%s %s %s tag %s' % (prefix, method_name, class_name, self.tag))
@@ -3485,7 +3765,7 @@
original_pointer = pointer
- first_octet = ord(encoded_data[pointer:pointer+1])
+ first_octet = ord(encoded_data[pointer:pointer + 1])
pointer += 1
class_ = first_octet >> 6
@@ -3496,7 +3776,7 @@
if tag == 31:
tag = 0
while True:
- num = ord(encoded_data[pointer:pointer+1])
+ num = ord(encoded_data[pointer:pointer + 1])
pointer += 1
tag *= 128
tag += num & 127
@@ -3564,64 +3844,68 @@
elif value.tag_type == 'explicit':
if class_ != value.explicit_class:
- raise ValueError(
- 'Error parsing %s - explicitly-tagged class should have been %s, but %s was found' %
- (
- object_name(value),
- CLASS_NUM_TO_NAME_MAP.get(value.explicit_class),
- CLASS_NUM_TO_NAME_MAP.get(class_, class_)
- )
- )
+ raise ValueError(unwrap(
+ '''
+ Error parsing %s - explicitly-tagged class should have been
+ %s, but %s was found
+ ''',
+ type_name(value),
+ CLASS_NUM_TO_NAME_MAP.get(value.explicit_class),
+ CLASS_NUM_TO_NAME_MAP.get(class_, class_)
+ ))
if method != 1:
- raise ValueError(
- 'Error parsing %s - explicitly-tagged method should have been %s, but %s was found' %
- (
- object_name(value),
- METHOD_NUM_TO_NAME_MAP.get(1),
- METHOD_NUM_TO_NAME_MAP.get(method, method)
- )
- )
+ raise ValueError(unwrap(
+ '''
+ Error parsing %s - explicitly-tagged method should have
+ been %s, but %s was found
+ ''',
+ type_name(value),
+ METHOD_NUM_TO_NAME_MAP.get(1),
+ METHOD_NUM_TO_NAME_MAP.get(method, method)
+ ))
if tag != value.explicit_tag:
- raise ValueError(
- 'Error parsing %s - explicitly-tagged tag should have been %s, but %s was found' %
- (
- object_name(value),
- value.explicit_tag,
- tag
- )
- )
+ raise ValueError(unwrap(
+ '''
+ Error parsing %s - explicitly-tagged tag should have been
+ %s, but %s was found
+ ''',
+ type_name(value),
+ value.explicit_tag,
+ tag
+ ))
elif isinstance(value, Choice):
value.validate(class_, tag)
else:
if class_ != value.class_:
- raise ValueError(
- 'Error parsing %s - class should have been %s, but %s was found' %
- (
- object_name(value),
- CLASS_NUM_TO_NAME_MAP.get(value.class_),
- CLASS_NUM_TO_NAME_MAP.get(class_, class_)
- )
- )
+ raise ValueError(unwrap(
+ '''
+ Error parsing %s - class should have been %s, but %s was
+ found
+ ''',
+ type_name(value),
+ CLASS_NUM_TO_NAME_MAP.get(value.class_),
+ CLASS_NUM_TO_NAME_MAP.get(class_, class_)
+ ))
if method != value.method:
- raise ValueError(
- 'Error parsing %s - method should have been %s, but %s was found' %
- (
- object_name(value),
- METHOD_NUM_TO_NAME_MAP.get(value.method),
- METHOD_NUM_TO_NAME_MAP.get(method, method)
- )
- )
+ raise ValueError(unwrap(
+ '''
+ Error parsing %s - method should have been %s, but %s was found
+ ''',
+ type_name(value),
+ METHOD_NUM_TO_NAME_MAP.get(value.method),
+ METHOD_NUM_TO_NAME_MAP.get(method, method)
+ ))
if tag != value.tag:
- raise ValueError(
- 'Error parsing %s - tag should have been %s, but %s was found' %
- (
- object_name(value),
- value.tag,
- tag
- )
- )
+ raise ValueError(unwrap(
+ '''
+ Error parsing %s - tag should have been %s, but %s was found
+ ''',
+ type_name(value),
+ value.tag,
+ tag
+ ))
# For explicitly tagged, un-speced parsings, we use a generic container
# since we will be parsing the contents and discarding the outer object
@@ -3663,39 +3947,39 @@
30: BMPString
}
if tag not in universal_specs:
- raise ValueError(
- 'Unknown element - %s class, %s method, tag %s' %
- (
- CLASS_NUM_TO_NAME_MAP.get(class_),
- METHOD_NUM_TO_NAME_MAP.get(method),
- tag,
- )
- )
+ raise ValueError(unwrap(
+ '''
+ Unknown element - %s class, %s method, tag %s
+ ''',
+ CLASS_NUM_TO_NAME_MAP.get(class_),
+ METHOD_NUM_TO_NAME_MAP.get(method),
+ tag
+ ))
spec = universal_specs[tag]
value = spec(contents=contents, class_=class_)
- value._header = header #pylint: disable=W0212
+ value._header = header
if trailer is not None and trailer != b'':
- value._trailer = trailer #pylint: disable=W0212
+ value._trailer = trailer
# Destroy any default value that our contents have overwritten
- value._native = None #pylint: disable=W0212
+ value._native = None
# For explicitly tagged values, parse the inner value and pull it out
if value.tag_type == 'explicit':
original_value = value
(class_, method, tag, header, contents, trailer), _ = _parse(value.contents)
value = _build(class_, method, tag, header, contents, trailer, spec=spec)
- value._header = original_value._header + header #pylint: disable=W0212
- value._trailer += original_value._trailer #pylint: disable=W0212
+ value._header = original_value._header + header
+ value._trailer += original_value._trailer
value.tag_type = 'explicit'
value.explicit_class = original_value.explicit_class
value.explicit_tag = original_value.explicit_tag
elif isinstance(value, Choice):
- value.contents = value._header + value.contents #pylint: disable=W0212
- value._header = b'' #pylint: disable=W0212
+ value.contents = value._header + value.contents
+ value._header = b''
try:
# Force parsing the Choice now
@@ -3704,9 +3988,9 @@
if nested_spec:
value.parse(nested_spec)
- except (ValueError) as e:
+ except (ValueError, TypeError) as e:
args = e.args[1:]
- e.args = (e.args[0] + '\n while parsing %s' % object_name(value),) + args
+ e.args = (e.args[0] + '\n while parsing %s' % type_name(value),) + args
raise e
return value
@@ -3732,9 +4016,16 @@
return ((None, None, None, None, None, None), 0)
encoded_length = len(encoded_data)
+
def _slice(start, end):
if end > encoded_length:
- raise ValueError('Insufficient data - %s bytes requested but only %s available' % (end, encoded_length))
+ raise ValueError(unwrap(
+ '''
+ Insufficient data - %s bytes requested but only %s available
+ ''',
+ end,
+ encoded_length
+ ))
return encoded_data[start:end]
start = pointer
@@ -3742,7 +4033,7 @@
class_, method, tag, num_bytes = _parse_id(encoded_data, pointer)
pointer += num_bytes
- length_octet = ord(_slice(pointer, pointer+1))
+ length_octet = ord(_slice(pointer, pointer + 1))
pointer += 1
length_type = length_octet >> 7
if length_type == 1:
@@ -3750,7 +4041,7 @@
remaining_length_octets = length_octet & 127
while remaining_length_octets > 0:
length *= 256
- length += ord(_slice(pointer, pointer+1))
+ length += ord(_slice(pointer, pointer + 1))
pointer += 1
remaining_length_octets -= 1
else:
@@ -3765,7 +4056,7 @@
pointer = end_token + 2
trailer = b'\x00\x00'
else:
- contents = _slice(pointer, pointer+length)
+ contents = _slice(pointer, pointer + length)
pointer += length
trailer = b''
diff --git a/asn1crypto/crl.py b/asn1crypto/crl.py
index a2be5bf..c017aa2 100644
--- a/asn1crypto/crl.py
+++ b/asn1crypto/crl.py
@@ -35,7 +35,6 @@
)
-
# The structures in this file are taken from https://tools.ietf.org/html/rfc5280
diff --git a/asn1crypto/csr.py b/asn1crypto/csr.py
index 05085cf..511675c 100644
--- a/asn1crypto/csr.py
+++ b/asn1crypto/csr.py
@@ -17,7 +17,6 @@
from .x509 import DirectoryString, Extensions, Name
-
# The structures in this file are taken from https://tools.ietf.org/html/rfc2986
# and https://tools.ietf.org/html/rfc2985
diff --git a/asn1crypto/keys.py b/asn1crypto/keys.py
index e6e39b2..a44a4fc 100644
--- a/asn1crypto/keys.py
+++ b/asn1crypto/keys.py
@@ -45,19 +45,9 @@
PrimeCurve,
PrimePoint,
)
+from ._errors import unwrap
from .util import int_from_bytes, int_to_bytes
-from ._errors import object_name
-
-try:
- # Python 2
- str_cls = unicode #pylint: disable=E0602
- byte_cls = str
-
-except NameError:
- # Python 3
- str_cls = str
- byte_cls = bytes
-
+from ._types import type_name, str_cls, byte_cls
class OtherPrimeInfo(Sequence):
@@ -198,9 +188,18 @@
return (x, y)
if first_byte not in set([b'\x02', b'\x03']):
- raise ValueError('Invalid EC public key - first byte is incorrect')
+ raise ValueError(unwrap(
+ '''
+ Invalid EC public key - first byte is incorrect
+ '''
+ ))
- raise ValueError('Compressed representations of EC public keys are not supported due to patent US6252960')
+ raise ValueError(unwrap(
+ '''
+ Compressed representations of EC public keys are not supported due
+ to patent US6252960
+ '''
+ ))
class ECPoint(OctetString, _ECPoint):
@@ -534,7 +533,12 @@
"""
if not isinstance(private_key, byte_cls) and not isinstance(private_key, Asn1Value):
- raise ValueError('private_key must be a byte string or Asn1Value, not %s' % object_name(private_key))
+ raise TypeError(unwrap(
+ '''
+ private_key must be a byte string or Asn1Value, not %s
+ ''',
+ type_name(private_key)
+ ))
if algorithm == 'rsa':
if not isinstance(private_key, RSAPrivateKey):
@@ -555,14 +559,19 @@
params = private_key['parameters']
del private_key['parameters']
else:
- raise ValueError('algorithm must be one of "rsa", "dsa", "ec", not %s' % repr(algorithm))
+ raise ValueError(unwrap(
+ '''
+ algorithm must be one of "rsa", "dsa", "ec", not %s
+ ''',
+ repr(algorithm)
+ ))
private_key_algo = PrivateKeyAlgorithm()
private_key_algo['algorithm'] = PrivateKeyAlgorithmId(algorithm)
private_key_algo['parameters'] = params
container = cls()
- container._algorithm = algorithm #pylint: disable=W0212
+ container._algorithm = algorithm
container['version'] = Integer(0)
container['private_key_algorithm'] = private_key_algo
container['private_key'] = private_key
@@ -570,7 +579,7 @@
# Here we save the DSA public key if possible since it is not contained
# within the PKCS#8 structure for a DSA key
if algorithm == 'dsa':
- container._public_key = public_key #pylint: disable=W0212
+ container._public_key = public_key
return container
@@ -602,11 +611,21 @@
curve_type, details = self.curve
if curve_type == 'implicit_ca':
- raise ValueError('Unable to compute public key for EC key using Implicit CA parameters')
+ raise ValueError(unwrap(
+ '''
+ Unable to compute public key for EC key using Implicit CA
+ parameters
+ '''
+ ))
if curve_type == 'specified':
if details['field_id']['field_type'] == 'characteristic_two_field':
- raise ValueError('Unable to compute public key for EC key over a characteristic two field')
+ raise ValueError(unwrap(
+ '''
+ Unable to compute public key for EC key over a
+ characteristic two field
+ '''
+ ))
curve = PrimeCurve(
details['field_id']['parameters'],
@@ -618,7 +637,13 @@
elif curve_type == 'named':
if details not in ('secp192r1', 'secp224r1', 'secp256r1', 'secp384r1', 'secp521r1'):
- raise ValueError('Unable to compute public key for EC named curve %s, parameters not currently included' % details)
+ raise ValueError(unwrap(
+ '''
+ Unable to compute public key for EC named curve %s,
+ parameters not currently included
+ ''',
+ details
+ ))
base_point = {
'secp192r1': SECP192R1_BASE_POINT,
@@ -677,7 +702,12 @@
"""
if self.algorithm != 'ec':
- raise ValueError('Only EC keys have a curve, this key is %s' % self.algorithm.upper())
+ raise ValueError(unwrap(
+ '''
+ Only EC keys have a curve, this key is %s
+ ''',
+ self.algorithm.upper()
+ ))
params = self['private_key_algorithm']['parameters']
chosen = params.chosen
@@ -703,7 +733,13 @@
"""
if self.algorithm != 'dsa':
- raise ValueError('Only DSA keys are generated using a hash algorithm, this key is %s' % self.algorithm.upper())
+ raise ValueError(unwrap(
+ '''
+ Only DSA keys are generated using a hash algorithm, this key is
+ %s
+ ''',
+ self.algorithm.upper()
+ ))
byte_len = math.log(self['private_key_algorithm']['parameters']['q'].native, 2) / 8
@@ -922,10 +958,20 @@
"""
if not isinstance(public_key, byte_cls) and not isinstance(public_key, Asn1Value):
- raise ValueError('public_key must be a byte string or Asn1Value, not %s' % object_name(public_key))
+ raise TypeError(unwrap(
+ '''
+ public_key must be a byte string or Asn1Value, not %s
+ ''',
+ type_name(public_key)
+ ))
if algorithm != 'rsa':
- raise ValueError('algorithm must "rsa", not %s' % repr(algorithm))
+ raise ValueError(unwrap(
+ '''
+ algorithm must "rsa", not %s
+ ''',
+ repr(algorithm)
+ ))
algo = PublicKeyAlgorithm()
algo['algorithm'] = PublicKeyAlgorithmId(algorithm)
@@ -953,7 +999,14 @@
key_type = self.algorithm.upper()
a_an = 'an' if key_type == 'EC' else 'a'
- raise ValueError('Only RSA public keys may be unwrapped - this key is %s %s public key' % (a_an, key_type))
+ raise ValueError(unwrap(
+ '''
+ Only RSA public keys may be unwrapped - this key is %s %s public
+ key
+ ''',
+ a_an,
+ key_type
+ ))
@property
def curve(self):
@@ -972,7 +1025,12 @@
"""
if self.algorithm != 'ec':
- raise ValueError('Only EC keys have a curve, this key is %s' % self.algorithm.upper())
+ raise ValueError(unwrap(
+ '''
+ Only EC keys have a curve, this key is %s
+ ''',
+ self.algorithm.upper()
+ ))
params = self['algorithm']['parameters']
chosen = params.chosen
@@ -998,7 +1056,13 @@
"""
if self.algorithm != 'dsa':
- raise ValueError('Only DSA keys are generated using a hash algorithm, this key is %s' % self.algorithm.upper())
+ raise ValueError(unwrap(
+ '''
+ Only DSA keys are generated using a hash algorithm, this key is
+ %s
+ ''',
+ self.algorithm.upper()
+ ))
byte_len = math.log(self['algorithm']['parameters']['q'].native, 2) / 8
diff --git a/asn1crypto/ocsp.py b/asn1crypto/ocsp.py
index 8ce5735..cd2c5c9 100644
--- a/asn1crypto/ocsp.py
+++ b/asn1crypto/ocsp.py
@@ -33,7 +33,6 @@
from .x509 import Certificate, GeneralName, GeneralNames, Name
-
# The structures in this file are taken from https://tools.ietf.org/html/rfc6960
diff --git a/asn1crypto/pdf.py b/asn1crypto/pdf.py
index 5a23323..c83f0ae 100644
--- a/asn1crypto/pdf.py
+++ b/asn1crypto/pdf.py
@@ -22,7 +22,6 @@
from .x509 import ExtensionId, Extension, GeneralName, KeyPurposeId
-
class AdobeArchiveRevInfo(Sequence):
_fields = [
('version', Integer)
@@ -56,12 +55,12 @@
_child_spec = RevocationInfoArchival
-ExtensionId._map['1.2.840.113583.1.1.9.2'] = 'adobe_archive_rev_info' #pylint: disable=W0212
-ExtensionId._map['1.2.840.113583.1.1.9.1'] = 'adobe_timestamp' #pylint: disable=W0212
-ExtensionId._map['1.2.840.113583.1.1.10'] = 'adobe_ppklite_credential' #pylint: disable=W0212
-Extension._oid_specs['adobe_archive_rev_info'] = AdobeArchiveRevInfo #pylint: disable=W0212
-Extension._oid_specs['adobe_timestamp'] = AdobeTimestamp #pylint: disable=W0212
-Extension._oid_specs['adobe_ppklite_credential'] = Null #pylint: disable=W0212
-KeyPurposeId._map['1.2.840.113583.1.1.5'] = 'pdf_signing' #pylint: disable=W0212
-CMSAttributeType._map['1.2.840.113583.1.1.8'] = 'adobe_revocation_info_archival' #pylint: disable=W0212
-CMSAttribute._oid_specs['adobe_revocation_info_archival'] = SetOfRevocationInfoArchival #pylint: disable=W0212
+ExtensionId._map['1.2.840.113583.1.1.9.2'] = 'adobe_archive_rev_info'
+ExtensionId._map['1.2.840.113583.1.1.9.1'] = 'adobe_timestamp'
+ExtensionId._map['1.2.840.113583.1.1.10'] = 'adobe_ppklite_credential'
+Extension._oid_specs['adobe_archive_rev_info'] = AdobeArchiveRevInfo
+Extension._oid_specs['adobe_timestamp'] = AdobeTimestamp
+Extension._oid_specs['adobe_ppklite_credential'] = Null
+KeyPurposeId._map['1.2.840.113583.1.1.5'] = 'pdf_signing'
+CMSAttributeType._map['1.2.840.113583.1.1.8'] = 'adobe_revocation_info_archival'
+CMSAttribute._oid_specs['adobe_revocation_info_archival'] = SetOfRevocationInfoArchival
diff --git a/asn1crypto/pem.py b/asn1crypto/pem.py
index b960981..2ee0088 100644
--- a/asn1crypto/pem.py
+++ b/asn1crypto/pem.py
@@ -15,19 +15,15 @@
import base64
import re
-from ._errors import object_name
+from ._errors import unwrap
+from ._types import type_name, str_cls, byte_cls
if sys.version_info < (3,):
- str_cls = unicode #pylint: disable=E0602
- byte_cls = str
- from cStringIO import StringIO as BytesIO #pylint: disable=F0401
+ from cStringIO import StringIO as BytesIO
else:
- str_cls = str
- byte_cls = bytes
from io import BytesIO
-
def detect(byte_string):
"""
Detect if a byte string seems to contain a PEM-encoded block
@@ -41,7 +37,12 @@
"""
if not isinstance(byte_string, byte_cls):
- raise ValueError('byte_string must be a byte string, not %s' % object_name(byte_string))
+ raise TypeError(unwrap(
+ '''
+ byte_string must be a byte string, not %s
+ ''',
+ type_name(byte_string)
+ ))
return byte_string.find(b'-----BEGIN') != -1 or byte_string.find(b'---- BEGIN') != -1
@@ -67,10 +68,19 @@
"""
if not isinstance(der_bytes, byte_cls):
- raise ValueError('der_bytes must be a byte string, not %s' % object_name(der_bytes))
+ raise TypeError(unwrap(
+ '''
+ der_bytes must be a byte string, not %s
+ ''' % type_name(der_bytes)
+ ))
if not isinstance(type_name, str_cls):
- raise ValueError('type_name must be a unicode string, not %s' % object_name(type_name))
+ raise TypeError(unwrap(
+ '''
+ type_name must be a unicode string, not %s
+ ''',
+ type_name(type_name)
+ ))
type_name = type_name.upper().encode('ascii')
@@ -89,7 +99,7 @@
b64_len = len(b64_bytes)
i = 0
while i < b64_len:
- output.write(b64_bytes[i:i+64])
+ output.write(b64_bytes[i:i + 64])
output.write(b'\n')
i += 64
output.write(b'-----END ')
@@ -110,21 +120,26 @@
ValueError - when the pem_bytes do not appear to be PEM-encoded bytes
:return:
- A generator of 3-element tuples in the format: (type_name, headers,
- der_bytes). The type_name is a unicode string of what is between
+ A generator of 3-element tuples in the format: (object_type, headers,
+ der_bytes). The object_type is a unicode string of what is between
"-----BEGIN " and "-----". Examples include: "CERTIFICATE",
"PUBLIC KEY", "PRIVATE KEY". The headers is a dict containing any lines
in the form "Name: Value" that are right after the begin line.
"""
if not isinstance(pem_bytes, byte_cls):
- raise ValueError('pem_bytes must be a byte string, not %s' % object_name(pem_bytes))
+ raise TypeError(unwrap(
+ '''
+ pem_bytes must be a byte string, not %s
+ ''',
+ type_name(pem_bytes)
+ ))
# Valid states include: "trash", "headers", "body"
state = 'trash'
headers = {}
base64_data = b''
- type_name = None
+ object_type = None
found_start = False
found_end = False
@@ -139,7 +154,7 @@
type_name_match = re.match(b'^(?:---- |-----)BEGIN ([A-Z0-9 ]+)(?: ----|-----)', line)
if not type_name_match:
continue
- type_name = type_name_match.group(1).decode('ascii')
+ object_type = type_name_match.group(1).decode('ascii')
found_start = True
state = 'headers'
@@ -158,19 +173,24 @@
if line[0:5] in (b'-----', b'---- '):
der_bytes = base64.b64decode(base64_data)
- yield (type_name, headers, der_bytes)
+ yield (object_type, headers, der_bytes)
state = 'trash'
headers = {}
base64_data = b''
- type_name = None
+ object_type = None
found_end = True
continue
base64_data += line
if not found_start or not found_end:
- raise ValueError('pem_bytes does not appear to contain PEM-encoded data - no BEGIN/END combination found')
+ raise ValueError(unwrap(
+ '''
+ pem_bytes does not appear to contain PEM-encoded data - no
+ BEGIN/END combination found
+ '''
+ ))
def unarmor(pem_bytes, multiple=False):
@@ -187,8 +207,8 @@
ValueError - when the pem_bytes do not appear to be PEM-encoded bytes
:return:
- A 3-element tuple (type_name, headers, der_bytes). The type_name is a
- unicode string of what is between "-----BEGIN " and "-----". Examples
+ A 3-element tuple (object_name, headers, der_bytes). The object_name is
+ a unicode string of what is between "-----BEGIN " and "-----". Examples
include: "CERTIFICATE", "PUBLIC KEY", "PRIVATE KEY". The headers is a
dict containing any lines in the form "Name: Value" that are right
after the begin line.
diff --git a/asn1crypto/pkcs12.py b/asn1crypto/pkcs12.py
index d4999d7..32ca18d 100644
--- a/asn1crypto/pkcs12.py
+++ b/asn1crypto/pkcs12.py
@@ -31,7 +31,6 @@
from .x509 import Certificate
-
# The structures in this file are taken from https://tools.ietf.org/html/rfc7292
class MacData(Sequence):
@@ -173,4 +172,4 @@
}
-SafeContents._child_spec = SafeBag #pylint: disable=W0212
+SafeContents._child_spec = SafeBag
diff --git a/asn1crypto/tsp.py b/asn1crypto/tsp.py
index a3e851c..2f8910c 100644
--- a/asn1crypto/tsp.py
+++ b/asn1crypto/tsp.py
@@ -294,12 +294,12 @@
_child_spec = SigningCertificateV2
-EncapsulatedContentInfo._oid_specs['tst_info'] = TSTInfo #pylint: disable=W0212
-EncapsulatedContentInfo._oid_specs['timestamped_data'] = TimeStampedData #pylint: disable=W0212
-ContentInfo._oid_specs['timestamped_data'] = TimeStampedData #pylint: disable=W0212
-ContentType._map['1.2.840.113549.1.9.16.1.4'] = 'tst_info' #pylint: disable=W0212
-ContentType._map['1.2.840.113549.1.9.16.1.31'] = 'timestamped_data' #pylint: disable=W0212
-CMSAttributeType._map['1.2.840.113549.1.9.16.2.12'] = 'signing_certificate' #pylint: disable=W0212
-CMSAttribute._oid_specs['signing_certificate'] = SetOfSigningCertificates #pylint: disable=W0212
-CMSAttributeType._map['1.2.840.113549.1.9.16.2.47'] = 'signing_certificate_v2' #pylint: disable=W0212
-CMSAttribute._oid_specs['signing_certificate_v2'] = SetOfSigningCertificatesV2 #pylint: disable=W0212
+EncapsulatedContentInfo._oid_specs['tst_info'] = TSTInfo
+EncapsulatedContentInfo._oid_specs['timestamped_data'] = TimeStampedData
+ContentInfo._oid_specs['timestamped_data'] = TimeStampedData
+ContentType._map['1.2.840.113549.1.9.16.1.4'] = 'tst_info'
+ContentType._map['1.2.840.113549.1.9.16.1.31'] = 'timestamped_data'
+CMSAttributeType._map['1.2.840.113549.1.9.16.2.12'] = 'signing_certificate'
+CMSAttribute._oid_specs['signing_certificate'] = SetOfSigningCertificates
+CMSAttributeType._map['1.2.840.113549.1.9.16.2.47'] = 'signing_certificate_v2'
+CMSAttribute._oid_specs['signing_certificate_v2'] = SetOfSigningCertificatesV2
diff --git a/asn1crypto/util.py b/asn1crypto/util.py
index 2265fcc..e83a3bb 100644
--- a/asn1crypto/util.py
+++ b/asn1crypto/util.py
@@ -18,13 +18,13 @@
import math
-from ._ordereddict import OrderedDict #pylint: disable=W0611
+from ._ordereddict import OrderedDict # noqa
if sys.platform == 'win32':
- from ._win._ws2_32 import inet_ntop, inet_pton #pylint: disable=W0611
+ from ._win._ws2_32 import inet_ntop, inet_pton
else:
- from socket import inet_ntop, inet_pton
+ from socket import inet_ntop, inet_pton # noqa
# Python 2
@@ -32,7 +32,6 @@
from datetime import timedelta, tzinfo
-
def int_to_bytes(value, signed=False, width=None):
"""
Converts an integer to a byte string
@@ -92,7 +91,7 @@
An integer
"""
- num = long(value.encode("hex"), 16) #pylint: disable=E0602
+ num = long(value.encode("hex"), 16) # noqa
if not signed:
return num
@@ -104,8 +103,7 @@
return num
-
- class utc(tzinfo):
+ class utc(tzinfo): # noqa
def tzname(self, _):
return 'UTC+00:00'
@@ -116,8 +114,7 @@
def dst(self, _):
return timedelta(0)
-
- class timezone():
+ class timezone(): # noqa
utc = utc()
@@ -125,8 +122,7 @@
# Python 3
else:
- from datetime import timezone #pylint: disable=W0611
-
+ from datetime import timezone # noqa
def int_to_bytes(value, signed=False, width=None):
"""
diff --git a/asn1crypto/x509.py b/asn1crypto/x509.py
index 99ec55e..0598106 100644
--- a/asn1crypto/x509.py
+++ b/asn1crypto/x509.py
@@ -21,7 +21,7 @@
import stringprep
import unicodedata
import socket
-from encodings import idna #pylint: disable=W0611
+from encodings import idna # noqa
import codecs
from ._ordereddict import OrderedDict
@@ -55,23 +55,19 @@
from .algos import SignedDigestAlgorithm
from .keys import PublicKeyInfo
from .util import int_to_bytes, int_from_bytes, inet_ntop, inet_pton
-from ._errors import object_name
+from ._errors import unwrap
+from ._types import type_name, str_cls, byte_cls
if sys.version_info < (3,):
- str_cls = unicode #pylint: disable=E0602
- byte_cls = str
- from urlparse import urlsplit, urlunsplit #pylint: disable=F0401
- from urllib import quote as urlquote, unquote as unquote_to_bytes #pylint: disable=E0611
+ from urlparse import urlsplit, urlunsplit
+ from urllib import quote as urlquote, unquote as unquote_to_bytes
bytes_to_list = lambda byte_string: [ord(b) for b in byte_string]
else:
- str_cls = str
- byte_cls = bytes
bytes_to_list = list
from urllib.parse import urlsplit, urlunsplit, quote as urlquote, unquote_to_bytes
-
# The structures in this file are taken from https://tools.ietf.org/html/rfc5280
# and a few other supplementary sources, mostly due to extra supported
# extension and name OIDs
@@ -112,7 +108,13 @@
"""
if not isinstance(value, str_cls):
- raise ValueError('%s value must be a unicode string, not %s' % (object_name(self), object_name(value)))
+ raise TypeError(unwrap(
+ '''
+ %s value must be a unicode string, not %s
+ ''',
+ type_name(self),
+ type_name(value)
+ ))
self._normalized = True
self._native = value
@@ -261,7 +263,13 @@
"""
if not isinstance(value, str_cls):
- raise ValueError('%s value must be a unicode string, not %s' % (object_name(self), object_name(value)))
+ raise TypeError(unwrap(
+ '''
+ %s value must be a unicode string, not %s
+ ''',
+ type_name(self),
+ type_name(value)
+ ))
if value.find('@') != -1:
mailbox, hostname = value.rsplit('@', 1)
@@ -307,13 +315,13 @@
if not self._normalized:
self.set(self.native)
- if not other._normalized: #pylint: disable=W0212
+ if not other._normalized:
other.set(other.native)
- if self._contents.find(b'@') == -1 or other._contents.find(b'@') == -1: #pylint: disable=W0212
- return self._contents == other._contents #pylint: disable=W0212
+ if self._contents.find(b'@') == -1 or other._contents.find(b'@') == -1:
+ return self._contents == other._contents
- other_mailbox, other_hostname = other._contents.rsplit(b'@', 1) #pylint: disable=W0212
+ other_mailbox, other_hostname = other._contents.rsplit(b'@', 1)
mailbox, hostname = self._contents.rsplit(b'@', 1)
if mailbox != other_mailbox:
@@ -326,12 +334,16 @@
class IPAddress(OctetString):
- def parse(self, spec=None, spec_params=None): #pylint: disable=W0613
+ def parse(self, spec=None, spec_params=None):
"""
This method is not applicable to IP addresses
"""
- raise ValueError('IP address values can not be parsed')
+ raise ValueError(unwrap(
+ '''
+ IP address values can not be parsed
+ '''
+ ))
def set(self, value):
"""
@@ -343,7 +355,13 @@
"""
if not isinstance(value, str_cls):
- raise ValueError('%s value must be a unicode string, not %s' % (object_name(self), object_name(value)))
+ raise TypeError(unwrap(
+ '''
+ %s value must be a unicode string, not %s
+ ''',
+ type_name(self),
+ type_name(value)
+ ))
original_value = value
@@ -354,17 +372,34 @@
value = parts[0]
cidr = int(parts[1])
if cidr < 0:
- raise ValueError('%s value contains a CIDR range less than 0' % object_name(self))
+ raise ValueError(unwrap(
+ '''
+ %s value contains a CIDR range less than 0
+ ''',
+ type_name(self)
+ ))
if value.find(':') != -1:
family = socket.AF_INET6
if cidr > 128:
- raise ValueError('%s value contains a CIDR range bigger than 128, the maximum value for an IPv6 address' % object_name(self))
+ raise ValueError(unwrap(
+ '''
+ %s value contains a CIDR range bigger than 128, the maximum
+ value for an IPv6 address
+ ''',
+ type_name(self)
+ ))
cidr_size = 128
else:
family = socket.AF_INET
if cidr > 32:
- raise ValueError('%s value contains a CIDR range bigger than 32, the maximum value for an IPv4 address' % object_name(self))
+ raise ValueError(unwrap(
+ '''
+ %s value contains a CIDR range bigger than 32, the maximum
+ value for an IPv4 address
+ ''',
+ type_name(self)
+ ))
cidr_size = 32
cidr_bytes = b''
@@ -659,7 +694,12 @@
string = re.sub('\ud834[\udd73-\udd7a]|\udb40[\udc20-\udc7f]|\U000e0001', '', string)
else:
string = re.sub('[\U0001D173-\U0001D17A\U000E0020-\U000E007F\U000e0001]', '', string)
- string = re.sub('[\u0000-\u0008\u000e-\u001f\u007f-\u0084\u0086-\u009f\u06dd\u070f\u180e\u200c-\u200f\u202a-\u202e\u2060-\u2063\u206a-\u206f\ufeff\ufff9-\ufffb]+', '', string)
+ string = re.sub(
+ '[\u0000-\u0008\u000e-\u001f\u007f-\u0084\u0086-\u009f\u06dd\u070f\u180e\u200c-\u200f'
+ '\u202a-\u202e\u2060-\u2063\u206a-\u206f\ufeff\ufff9-\ufffb]+',
+ '',
+ string
+ )
string = string.replace('\u200b', '')
string = re.sub('[\u00a0\u1680\u2000-\u200a\u2028-\u2029\u202f\u205f\u3000]', ' ', string)
@@ -671,22 +711,47 @@
# Prohibit step
for char in string:
if stringprep.in_table_a1(char):
- raise ValueError('X.509 Name objects may not contain unassigned code points')
+ raise ValueError(unwrap(
+ '''
+ X.509 Name objects may not contain unassigned code points
+ '''
+ ))
if stringprep.in_table_c8(char):
- raise ValueError('X.509 Name objects may not contain change display or deprecated characters')
+ raise ValueError(unwrap(
+ '''
+ X.509 Name objects may not contain change display or
+ zzzzdeprecated characters
+ '''
+ ))
if stringprep.in_table_c3(char):
- raise ValueError('X.509 Name objects may not contain private use characters')
+ raise ValueError(unwrap(
+ '''
+ X.509 Name objects may not contain private use characters
+ '''
+ ))
if stringprep.in_table_c4(char):
- raise ValueError('X.509 Name objects may not contain non-character code points')
+ raise ValueError(unwrap(
+ '''
+ X.509 Name objects may not contain non-character code points
+ '''
+ ))
if stringprep.in_table_c5(char):
- raise ValueError('X.509 Name objects may not contain surrogate code points')
+ raise ValueError(unwrap(
+ '''
+ X.509 Name objects may not contain surrogate code points
+ '''
+ ))
if char == '\ufffd':
- raise ValueError('X.509 Name objects may not contain the replacement character')
+ raise ValueError(unwrap(
+ '''
+ X.509 Name objects may not contain the replacement character
+ '''
+ ))
# Check bidirectional step - here we ensure that we are not mixing
# left-to-right and right-to-left text in the string
@@ -703,7 +768,12 @@
last_is_r_and_al = stringprep.in_table_d1(string[-1])
if has_l_cat or not first_is_r_and_al or not last_is_r_and_al:
- raise ValueError('X.509 Name object contains a malformed bidirectional sequence')
+ raise ValueError(unwrap(
+ '''
+ X.509 Name object contains a malformed bidirectional
+ sequence
+ '''
+ ))
# Insignificant space handling step
string = ' ' + re.sub(' +', ' ', string).strip() + ' '
@@ -759,8 +829,8 @@
self_values = self._get_values(self)
other_values = self._get_values(other)
- for type_name in self_types:
- if self_values[type_name] != other_values[type_name]:
+ for type_name_ in self_types:
+ if self_values[type_name_] != other_values[type_name_]:
return False
return True
@@ -792,7 +862,7 @@
"""
output = {}
- [output.update([(ntv['type'].native, ntv.prepped_value)]) for ntv in rdn] #pylint: disable=W0106
+ [output.update([(ntv['type'].native, ntv.prepped_value)]) for ntv in rdn]
return output
@@ -1260,10 +1330,21 @@
"""
if self.name in ('other_name', 'x400_address', 'edi_party_name'):
- raise ValueError('comparison is not supported for GeneralName objects of choice %s' % self.name)
+ raise ValueError(unwrap(
+ '''
+ Comparison is not supported for GeneralName objects of
+ choice %s
+ ''',
+ self.name
+ ))
if other.name in ('other_name', 'x400_address', 'edi_party_name'):
- raise ValueError('comparison is not supported for GeneralName objects of choice %s' % other.name)
+ raise ValueError(unwrap(
+ '''
+ Comparison is not supported for GeneralName objects of choice
+ %s''',
+ other.name
+ ))
if self.name != other.name:
return False
@@ -1364,7 +1445,12 @@
self._url = None
name = self['distribution_point']
if name.name != 'full_name':
- raise ValueError('CRL distribution points that are relative to the issuer are not supported')
+ raise ValueError(unwrap(
+ '''
+ CRL distribution points that are relative to the issuer are
+ not supported
+ '''
+ ))
for general_name in name.chosen:
if general_name.name == 'uniform_resource_identifier':
@@ -2059,12 +2145,13 @@
"""
if self._authority_issuer_serial is False:
- if self.authority_key_identifier_value and self.authority_key_identifier_value['authority_cert_issuer'].native:
- authority_issuer = self.authority_key_identifier_value['authority_cert_issuer'][0].chosen
+ akiv = self.authority_key_identifier_value
+ if akiv and akiv['authority_cert_issuer'].native:
+ issuer = self.authority_key_identifier_value['authority_cert_issuer'][0].chosen
# We untag the element since it is tagged via being a choice from GeneralName
- authority_issuer = authority_issuer.untag()
+ issuer = issuer.untag()
authority_serial = self.authority_key_identifier_value['authority_cert_serial_number'].native
- self._authority_issuer_serial = authority_issuer.sha256 + b':' + str_cls(authority_serial).encode('ascii')
+ self._authority_issuer_serial = issuer.sha256 + b':' + str_cls(authority_serial).encode('ascii')
else:
self._authority_issuer_serial = None
return self._authority_issuer_serial
@@ -2289,7 +2376,12 @@
"""
if not isinstance(domain_ip, str_cls):
- raise TypeError('domain_ip must be a unicode string, not %s' % object_name(domain_ip))
+ raise TypeError(unwrap(
+ '''
+ domain_ip must be a unicode string, not %s
+ ''',
+ type_name(domain_ip)
+ ))
encoded_domain_ip = domain_ip.encode('idna').decode('ascii').lower()
@@ -2315,7 +2407,8 @@
if valid_domain_labels == domain_labels:
return True
- if self._is_wildcard_domain(encoded_valid_domain) and self._is_wildcard_match(domain_labels, valid_domain_labels):
+ is_wildcard = self._is_wildcard_domain(encoded_valid_domain)
+ if is_wildcard and self._is_wildcard_match(domain_labels, valid_domain_labels):
return True
return False
diff --git a/dev-requirements.txt b/dev-requirements.txt
index fc7a185..a178187 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -1,2 +1,2 @@
coverage>=4.0b1
-pylint
\ No newline at end of file
+flake8
\ No newline at end of file
diff --git a/dev/lint.py b/dev/lint.py
index 7f5f15b..ec35573 100644
--- a/dev/lint.py
+++ b/dev/lint.py
@@ -3,23 +3,22 @@
import os
-from pylint.lint import Run
+from flake8.engine import get_style_guide
cur_dir = os.path.dirname(__file__)
-rc_path = os.path.join(cur_dir, '..', '.pylintrc')
+config_file = os.path.join(cur_dir, '..', '.pep8')
def run():
- print('Running pylint...')
+ print('Running flake8...')
- files = []
- for root, _, filenames in os.walk('../asn1crypto/'):
+ flake8_style = get_style_guide(config_file=config_file)
+
+ paths = []
+ for root, _, filenames in os.walk('asn1crypto'):
for filename in filenames:
if not filename.endswith('.py'):
continue
- files.append(os.path.join(root, filename))
-
- args = ['--rcfile=%s' % rc_path] + files
-
- Run(args)
+ paths.append(os.path.join(root, filename))
+ flake8_style.check_files(paths)
diff --git a/tests/_unittest_compat.py b/tests/_unittest_compat.py
index 3064061..7b867b4 100644
--- a/tests/_unittest_compat.py
+++ b/tests/_unittest_compat.py
@@ -29,7 +29,7 @@
self.fail(msg)
-def _assert_raises(self, excClass, callableObj=None, *args, **kwargs):
+def _assert_raises(self, excClass, callableObj=None, *args, **kwargs): # noqa
context = _AssertRaisesContext(excClass, self)
if callableObj is None:
return context
@@ -59,7 +59,7 @@
if not issubclass(exc_type, self.expected):
# let unexpected exceptions pass through
return False
- self.exception = exc_value # store for later retrieval
+ self.exception = exc_value # store for later retrieval
if self.expected_regexp is None:
return True
diff --git a/tests/test_cms.py b/tests/test_cms.py
index c8a6c41..6adb15d 100644
--- a/tests/test_cms.py
+++ b/tests/test_cms.py
@@ -14,7 +14,6 @@
fixtures_dir = os.path.join(tests_root, 'fixtures')
-
class CMSTests(unittest.TestCase):
def test_parse_content_info_data(self):
@@ -57,7 +56,9 @@
compressed_data['encap_content_info']['content_type'].native
)
self.assertEqual(
- b'\x78\x9C\x0B\xC9\xC8\x2C\x56\x00\xA2\x92\x8C\x54\x85\xDC\xD4\xE2\xE2\xC4\xF4\x54\x85\x92\x7C\x85\xD4\xBC\xE4\xC4\x82\xE2\xD2\x9C\xC4\x92\x54\x85\xCC\x3C\x85\x00\x6F\xE7\x60\x65\x73\x7D\x67\xDF\x60\x2E\x00\xB5\xCF\x10\x71',
+ b'\x78\x9C\x0B\xC9\xC8\x2C\x56\x00\xA2\x92\x8C\x54\x85\xDC\xD4\xE2\xE2\xC4\xF4\x54\x85\x92\x7C\x85\xD4\xBC'
+ b'\xE4\xC4\x82\xE2\xD2\x9C\xC4\x92\x54\x85\xCC\x3C\x85\x00\x6F\xE7\x60\x65\x73\x7D\x67\xDF\x60\x2E\x00\xB5'
+ b'\xCF\x10\x71',
compressed_data['encap_content_info']['content'].native
)
self.assertEqual(
@@ -128,7 +129,9 @@
encrypted_content_info['content_encryption_algorithm']['parameters'].native
)
self.assertEqual(
- b'\x80\xEE\x34\x8B\xFC\x04\x69\x4F\xBE\x15\x1C\x0C\x39\x2E\xF3\xEA\x8E\xEE\x17\x0D\x39\xC7\x4B\x6C\x4B\x13\xEF\x17\x82\x0D\xED\xBA\x6D\x2F\x3B\xAB\x4E\xEB\xF0\xDB\xD9\x6E\x1C\xC2\x3C\x1C\x4C\xFA\xF3\x98\x9B\x89\xBD\x48\x77\x07\xE2\x6B\x71\xCF\xB7\xFF\xCE\xA5',
+ b'\x80\xEE\x34\x8B\xFC\x04\x69\x4F\xBE\x15\x1C\x0C\x39\x2E\xF3\xEA\x8E\xEE\x17\x0D\x39\xC7\x4B\x6C\x4B'
+ b'\x13\xEF\x17\x82\x0D\xED\xBA\x6D\x2F\x3B\xAB\x4E\xEB\xF0\xDB\xD9\x6E\x1C\xC2\x3C\x1C\x4C\xFA\xF3\x98'
+ b'\x9B\x89\xBD\x48\x77\x07\xE2\x6B\x71\xCF\xB7\xFF\xCE\xA5',
encrypted_content_info['encrypted_content'].native
)
@@ -190,7 +193,17 @@
recipient['key_encryption_algorithm']['parameters'].native
)
self.assertEqual(
- b'\x97\x0A\xFD\x3B\x5C\x27\x45\x69\xCC\xDD\x45\x9E\xA7\x3C\x07\x27\x35\x16\x20\x21\xE4\x6E\x1D\xF8\x5B\xE8\x7F\xD8\x40\x41\xE9\xF2\x92\xCD\xC8\xC5\x03\x95\xEC\x6C\x0B\x97\x71\x87\x86\x3C\xEB\x68\x84\x06\x4E\xE6\xD0\xC4\x7D\x32\xFE\xA6\x06\xC9\xD5\xE1\x8B\xDA\xBF\x96\x5C\x20\x15\x49\x64\x7A\xA2\x4C\xFF\x8B\x0D\xEA\x76\x35\x9B\x7C\x43\xF7\x21\x95\x26\xE7\x70\x30\x98\x5F\x0D\x5E\x4A\xCB\xAD\x47\xDF\x46\xDA\x1F\x0E\xE2\xFE\x3A\x40\xD9\xF2\xDC\x0C\x97\xD9\x91\xED\x34\x8D\xF3\x73\xB0\x90\xF9\xDD\x31\x4D\x37\x93\x81\xD3\x92\xCB\x72\x4A\xD6\x9D\x01\x82\x85\xD5\x1F\xE2\xAA\x32\x12\x82\x4E\x17\xF6\xAA\x58\xDE\xBD\x1B\x80\xAF\x61\xF1\x8A\xD1\x7F\x9D\x41\x6A\xC0\xE4\xC7\x7E\x17\xDC\x94\x33\xE9\x74\x7E\xE9\xF8\x5C\x30\x87\x9B\xD6\xF0\xE3\x4A\xB7\xE3\xCC\x51\x8A\xD4\x37\xF1\xF9\x33\xB5\xD6\x1F\x36\xC1\x6F\x91\xA8\x5F\xE2\x6B\x08\xC7\x9D\xE8\xFD\xDC\xE8\x78\xE0\xC0\xC7\xCF\xC5\xEE\x60\xEC\x54\xFF\x1A\x9C\xF7\x4E\x2C\xD0\x88\xDC\xC2\x1F\xDC\x8A\x37\x9B\x71\x20\xFF\xFD\x6C\xE5\xBA\x8C\xDF\x0E\x3F\x20\xC6\xCB\x08\xA7\x07\xDB\x83',
+ b'\x97\x0A\xFD\x3B\x5C\x27\x45\x69\xCC\xDD\x45\x9E\xA7\x3C\x07\x27\x35\x16\x20\x21\xE4\x6E\x1D\xF8'
+ b'\x5B\xE8\x7F\xD8\x40\x41\xE9\xF2\x92\xCD\xC8\xC5\x03\x95\xEC\x6C\x0B\x97\x71\x87\x86\x3C\xEB\x68'
+ b'\x84\x06\x4E\xE6\xD0\xC4\x7D\x32\xFE\xA6\x06\xC9\xD5\xE1\x8B\xDA\xBF\x96\x5C\x20\x15\x49\x64\x7A'
+ b'\xA2\x4C\xFF\x8B\x0D\xEA\x76\x35\x9B\x7C\x43\xF7\x21\x95\x26\xE7\x70\x30\x98\x5F\x0D\x5E\x4A\xCB'
+ b'\xAD\x47\xDF\x46\xDA\x1F\x0E\xE2\xFE\x3A\x40\xD9\xF2\xDC\x0C\x97\xD9\x91\xED\x34\x8D\xF3\x73\xB0'
+ b'\x90\xF9\xDD\x31\x4D\x37\x93\x81\xD3\x92\xCB\x72\x4A\xD6\x9D\x01\x82\x85\xD5\x1F\xE2\xAA\x32\x12'
+ b'\x82\x4E\x17\xF6\xAA\x58\xDE\xBD\x1B\x80\xAF\x61\xF1\x8A\xD1\x7F\x9D\x41\x6A\xC0\xE4\xC7\x7E\x17'
+ b'\xDC\x94\x33\xE9\x74\x7E\xE9\xF8\x5C\x30\x87\x9B\xD6\xF0\xE3\x4A\xB7\xE3\xCC\x51\x8A\xD4\x37\xF1'
+ b'\xF9\x33\xB5\xD6\x1F\x36\xC1\x6F\x91\xA8\x5F\xE2\x6B\x08\xC7\x9D\xE8\xFD\xDC\xE8\x78\xE0\xC0\xC7'
+ b'\xCF\xC5\xEE\x60\xEC\x54\xFF\x1A\x9C\xF7\x4E\x2C\xD0\x88\xDC\xC2\x1F\xDC\x8A\x37\x9B\x71\x20\xFF'
+ b'\xFD\x6C\xE5\xBA\x8C\xDF\x0E\x3F\x20\xC6\xCB\x08\xA7\x07\xDB\x83',
recipient['encrypted_key'].native
)
self.assertEqual(
@@ -206,7 +219,9 @@
encrypted_content_info['content_encryption_algorithm']['parameters'].native
)
self.assertEqual(
- b'\xDC\x88\x55\x08\xE5\x67\x70\x49\x99\x54\xFD\xF8\x40\x7C\x38\xD5\x78\x1D\x6A\x95\x6D\x1E\xC4\x12\x39\xFE\xC0\x76\xDC\xF5\x79\x1A\x69\xA1\xB9\x40\x1E\xCF\xC8\x79\x3E\xF3\x38\xB4\x90\x00\x27\xD1\xB5\x64\xAB\x99\x51\x13\xF1\x0A',
+ b'\xDC\x88\x55\x08\xE5\x67\x70\x49\x99\x54\xFD\xF8\x40\x7C\x38\xD5\x78\x1D\x6A\x95\x6D\x1E\xC4\x12'
+ b'\x39\xFE\xC0\x76\xDC\xF5\x79\x1A\x69\xA1\xB9\x40\x1E\xCF\xC8\x79\x3E\xF3\x38\xB4\x90\x00\x27\xD1'
+ b'\xB5\x64\xAB\x99\x51\x13\xF1\x0A',
encrypted_content_info['encrypted_content'].native
)
self.assertEqual(
@@ -324,7 +339,8 @@
signed_attrs[2]['type'].native
)
self.assertEqual(
- b'\xA1\x30\xE2\x87\x90\x5A\x58\x15\x7A\x44\x54\x7A\xB9\xBC\xAE\xD3\x00\xF3\xEC\x3E\x97\xFF\x03\x20\x79\x34\x9D\x62\xAA\x20\xA5\x1D',
+ b'\xA1\x30\xE2\x87\x90\x5A\x58\x15\x7A\x44\x54\x7A\xB9\xBC\xAE\xD3\x00\xF3\xEC\x3E\x97\xFF'
+ b'\x03\x20\x79\x34\x9D\x62\xAA\x20\xA5\x1D',
signed_attrs[2]['values'][0].native
)
@@ -336,7 +352,18 @@
signer['signature_algorithm'].native
)
self.assertEqual(
- b'\xAC\x2F\xE3\x25\x39\x8F\xD3\xDF\x80\x4F\x0D\xBA\xB1\xEE\x99\x09\xA9\x21\xBB\xDF\x3C\x1E\x70\xDA\xDF\xC4\x0F\x1D\x10\x29\xBC\x94\xBE\xF8\xA8\xC2\x2D\x2A\x1F\x14\xBC\x4A\x5B\x66\x7F\x6F\xE4\xDF\x82\x4D\xD9\x3F\xEB\x89\xAA\x05\x1A\xE5\x58\xCE\xC4\x33\x53\x6E\xE4\x66\xF9\x21\xCF\x80\x35\x46\x88\xB5\x6A\xEA\x5C\x54\x49\x40\x31\xD6\xDC\x20\xD8\xA0\x63\x8C\xC1\xC3\xA1\x72\x5D\x0D\xCE\x43\xB1\x5C\xD8\x32\x3F\xA9\xE7\xBB\xD9\x56\xAE\xE7\xFB\x7C\x37\x32\x8B\x93\xC2\xC4\x47\xDD\x00\xFB\x1C\xEF\xC3\x68\x32\xDC\x06\x26\x17\x45\xF5\xB3\xDC\xD8\x5C\x2B\xC1\x8B\x97\x93\xB8\xF1\x85\xE2\x92\x3B\xC4\x6A\x6A\x89\xC5\x14\x51\x4A\x06\x11\x54\xB0\x29\x07\x75\xD8\xDF\x6B\xFB\x21\xE4\xA4\x09\x17\xAF\xAC\xA0\xF5\xC0\xFE\x7B\x03\x04\x40\x41\x57\xC4\xFD\x58\x1D\x10\x5E\xAC\x23\xAB\xAA\x80\x95\x96\x02\x71\x84\x9C\x0A\xBD\x54\xC4\xA2\x47\xAA\xE7\xC3\x09\x13\x6E\x26\x7D\x72\xAA\xA9\x0B\xF3\xCC\xC4\x48\xB4\x97\x14\x00\x47\x2A\x6B\xD3\x93\x3F\xD8\xFD\xAA\xB9\xFB\xFB\xD5\x09\x8D\x82\x8B\xDE\x0F\xED\x39\x6D\x7B\xDC\x76\x8B\xA6\x4E\x9B\x7A\xBA',
+ b'\xAC\x2F\xE3\x25\x39\x8F\xD3\xDF\x80\x4F\x0D\xBA\xB1\xEE\x99\x09\xA9\x21\xBB\xDF\x3C\x1E'
+ b'\x70\xDA\xDF\xC4\x0F\x1D\x10\x29\xBC\x94\xBE\xF8\xA8\xC2\x2D\x2A\x1F\x14\xBC\x4A\x5B\x66'
+ b'\x7F\x6F\xE4\xDF\x82\x4D\xD9\x3F\xEB\x89\xAA\x05\x1A\xE5\x58\xCE\xC4\x33\x53\x6E\xE4\x66'
+ b'\xF9\x21\xCF\x80\x35\x46\x88\xB5\x6A\xEA\x5C\x54\x49\x40\x31\xD6\xDC\x20\xD8\xA0\x63\x8C'
+ b'\xC1\xC3\xA1\x72\x5D\x0D\xCE\x43\xB1\x5C\xD8\x32\x3F\xA9\xE7\xBB\xD9\x56\xAE\xE7\xFB\x7C'
+ b'\x37\x32\x8B\x93\xC2\xC4\x47\xDD\x00\xFB\x1C\xEF\xC3\x68\x32\xDC\x06\x26\x17\x45\xF5\xB3'
+ b'\xDC\xD8\x5C\x2B\xC1\x8B\x97\x93\xB8\xF1\x85\xE2\x92\x3B\xC4\x6A\x6A\x89\xC5\x14\x51\x4A'
+ b'\x06\x11\x54\xB0\x29\x07\x75\xD8\xDF\x6B\xFB\x21\xE4\xA4\x09\x17\xAF\xAC\xA0\xF5\xC0\xFE'
+ b'\x7B\x03\x04\x40\x41\x57\xC4\xFD\x58\x1D\x10\x5E\xAC\x23\xAB\xAA\x80\x95\x96\x02\x71\x84'
+ b'\x9C\x0A\xBD\x54\xC4\xA2\x47\xAA\xE7\xC3\x09\x13\x6E\x26\x7D\x72\xAA\xA9\x0B\xF3\xCC\xC4'
+ b'\x48\xB4\x97\x14\x00\x47\x2A\x6B\xD3\x93\x3F\xD8\xFD\xAA\xB9\xFB\xFB\xD5\x09\x8D\x82\x8B'
+ b'\xDE\x0F\xED\x39\x6D\x7B\xDC\x76\x8B\xA6\x4E\x9B\x7A\xBA',
signer['signature'].native
)
@@ -450,7 +477,8 @@
signed_attrs[2]['type'].native
)
self.assertEqual(
- b'\x52\x88\x25\x47\x15\x5B\x2D\x50\x44\x68\x05\x24\xC8\x71\x5A\xCC\x62\x28\x36\x17\xB7\x68\xEE\xA1\x12\x90\x96\x4F\x94\xAE\xDB\x79',
+ b'\x52\x88\x25\x47\x15\x5B\x2D\x50\x44\x68\x05\x24\xC8\x71\x5A\xCC\x62\x28\x36\x17\xB7\x68'
+ b'\xEE\xA1\x12\x90\x96\x4F\x94\xAE\xDB\x79',
signed_attrs[2]['values'][0].native
)
@@ -462,7 +490,18 @@
signer['signature_algorithm'].native
)
self.assertEqual(
- b'\x43\x66\xEE\xF4\x6A\x02\x6F\xFE\x0D\xAE\xE6\xF3\x7A\x8F\x2C\x8E\x26\xB6\x25\x68\xEF\x5B\x4B\x4F\x9C\xE4\xE6\x71\x42\x22\xEC\x97\xFC\x53\xD9\xD6\x36\x1F\xA1\x32\x35\xFF\xA9\x95\x45\x50\x36\x36\x0C\x9A\x10\x6F\x06\xB6\x9D\x25\x10\x08\xF5\xF4\xE1\x68\x62\x60\xE5\xBF\xBD\xE2\x9F\xBD\x8A\x10\x29\x3B\xAF\xE7\xD6\x55\x7C\xEE\x3B\xFB\x93\x42\xE0\xB4\x4F\x89\xD0\x7B\x18\x51\x85\x90\x47\xF0\x5E\xE1\x15\x2C\xC1\x9A\xF1\x49\xE8\x11\x29\x17\x2E\x77\xD3\x35\x10\xAA\xCD\x32\x07\x32\x74\xCF\x2D\x89\xBD\xEF\xC7\xC9\xE7\xEC\x90\x44\xCE\x0B\xC5\x97\x00\x26\x67\x8A\x89\x5B\xFA\x46\xB2\x92\xD5\xCB\xA3\x52\x16\xDC\xF0\xF0\x79\xCB\x90\x93\x8E\x26\xB3\xEB\x8F\xBD\x54\x06\xD6\xB0\xA0\x04\x47\x7C\x63\xFC\x88\x5A\xE3\x81\xDF\x1E\x4D\x39\xFD\xF5\xA0\xE2\xD3\xAB\x13\xC1\xCF\x50\xB2\x0B\xC9\x36\xD6\xCB\xEA\x55\x39\x97\x8E\x34\x47\xE3\x6B\x44\x4A\x0E\x03\xAF\x41\xB2\x47\x2E\x26\xA3\x6B\x5F\xA1\x5C\x86\xA1\x96\x37\x02\xD3\x7C\x5F\xC1\xAF\x81\xE4\x1A\xD9\x87\x44\xB5\xB3\x5C\x45\x6C\xFF\x97\x4C\x3A\xB4\x2F\x5C\x2F\x86\x15\x51\x71\xA6\x27\x68',
+ b'\x43\x66\xEE\xF4\x6A\x02\x6F\xFE\x0D\xAE\xE6\xF3\x7A\x8F\x2C\x8E\x26\xB6\x25\x68\xEF\x5B'
+ b'\x4B\x4F\x9C\xE4\xE6\x71\x42\x22\xEC\x97\xFC\x53\xD9\xD6\x36\x1F\xA1\x32\x35\xFF\xA9\x95'
+ b'\x45\x50\x36\x36\x0C\x9A\x10\x6F\x06\xB6\x9D\x25\x10\x08\xF5\xF4\xE1\x68\x62\x60\xE5\xBF'
+ b'\xBD\xE2\x9F\xBD\x8A\x10\x29\x3B\xAF\xE7\xD6\x55\x7C\xEE\x3B\xFB\x93\x42\xE0\xB4\x4F\x89'
+ b'\xD0\x7B\x18\x51\x85\x90\x47\xF0\x5E\xE1\x15\x2C\xC1\x9A\xF1\x49\xE8\x11\x29\x17\x2E\x77'
+ b'\xD3\x35\x10\xAA\xCD\x32\x07\x32\x74\xCF\x2D\x89\xBD\xEF\xC7\xC9\xE7\xEC\x90\x44\xCE\x0B'
+ b'\xC5\x97\x00\x26\x67\x8A\x89\x5B\xFA\x46\xB2\x92\xD5\xCB\xA3\x52\x16\xDC\xF0\xF0\x79\xCB'
+ b'\x90\x93\x8E\x26\xB3\xEB\x8F\xBD\x54\x06\xD6\xB0\xA0\x04\x47\x7C\x63\xFC\x88\x5A\xE3\x81'
+ b'\xDF\x1E\x4D\x39\xFD\xF5\xA0\xE2\xD3\xAB\x13\xC1\xCF\x50\xB2\x0B\xC9\x36\xD6\xCB\xEA\x55'
+ b'\x39\x97\x8E\x34\x47\xE3\x6B\x44\x4A\x0E\x03\xAF\x41\xB2\x47\x2E\x26\xA3\x6B\x5F\xA1\x5C'
+ b'\x86\xA1\x96\x37\x02\xD3\x7C\x5F\xC1\xAF\x81\xE4\x1A\xD9\x87\x44\xB5\xB3\x5C\x45\x6C\xFF'
+ b'\x97\x4C\x3A\xB4\x2F\x5C\x2F\x86\x15\x51\x71\xA6\x27\x68',
signer['signature'].native
)
@@ -584,11 +623,21 @@
signer['signature_algorithm'].native
)
self.assertEqual(
- b'\x70\xBC\x18\x82\x41\xD6\xD8\xE7\x5C\xDC\x42\x27\xA5\xA8\xAA\x8B\x16\x15\x61\x3A\xE5\x47\x53\xFD\x8F\x45\xA3\x82\xE2\x72\x44\x07\xD1\xCB\xBF\xB4\x85\x4A\x2A\x16\x19\xDE\xDC\x53\x15\xCF\x98\xEE\x5C\x0E\xDF\xDE\xC8\x79\xCE\x2B\x38\x61\x36\xB0\xA1\xCB\x94\xD6\x4F\xCD\x83\xEF\x0C\xC9\x23\xA0\x7B\x8B\x65\x40\x5C\x3D\xA8\x3E\xCC\x0D\x1F\x17\x23\xF3\x74\x9F\x7E\x88\xF8\xF3\xBE\x4E\x19\x95\x0F\xEB\x95\x55\x69\xB4\xAA\xC3\x2A\x36\x03\x93\x1C\xDC\xE5\x65\x3F\x4E\x5E\x03\xC8\x56\xD8\x57\x8F\xE8\x2D\x85\x32\xDA\xFD\x79\xD4\xDD\x88\xCA\xA3\x14\x41\xE4\x3B\x03\x88\x0E\x2B\x76\xDC\x44\x3D\x4D\xFF\xB2\xC8\xC3\x83\xB1\x33\x37\x53\x51\x33\x4B\xCA\x1A\xAD\x7E\x6A\xBC\x61\x8B\x84\xDB\x7F\xCF\x61\xB2\x1D\x21\x83\xCF\xB8\x3F\xC6\x98\xED\xD8\x66\x06\xCF\x03\x30\x96\x9D\xB4\x7A\x16\xDF\x6E\xA7\x30\xEB\x77\xF7\x40\x13\xFB\xF2\xAC\x41\x79\x9D\xDC\xC0\xED\x4B\x8B\x19\xEE\x05\x3D\x61\x20\x39\x7E\x80\x1D\x3A\x23\x69\x48\x43\x60\x8B\x3E\x63\xAD\x01\x7A\xDE\x6F\x01\xBA\x51\xF3\x4B\x14\xBF\x6B\x77\x1A\x32\xC2\x0C\x93\xCC\x35\xBC\x66\xC6\x69',
+ b'\x70\xBC\x18\x82\x41\xD6\xD8\xE7\x5C\xDC\x42\x27\xA5\xA8\xAA\x8B\x16\x15\x61\x3A\xE5\x47'
+ b'\x53\xFD\x8F\x45\xA3\x82\xE2\x72\x44\x07\xD1\xCB\xBF\xB4\x85\x4A\x2A\x16\x19\xDE\xDC\x53'
+ b'\x15\xCF\x98\xEE\x5C\x0E\xDF\xDE\xC8\x79\xCE\x2B\x38\x61\x36\xB0\xA1\xCB\x94\xD6\x4F\xCD'
+ b'\x83\xEF\x0C\xC9\x23\xA0\x7B\x8B\x65\x40\x5C\x3D\xA8\x3E\xCC\x0D\x1F\x17\x23\xF3\x74\x9F'
+ b'\x7E\x88\xF8\xF3\xBE\x4E\x19\x95\x0F\xEB\x95\x55\x69\xB4\xAA\xC3\x2A\x36\x03\x93\x1C\xDC'
+ b'\xE5\x65\x3F\x4E\x5E\x03\xC8\x56\xD8\x57\x8F\xE8\x2D\x85\x32\xDA\xFD\x79\xD4\xDD\x88\xCA'
+ b'\xA3\x14\x41\xE4\x3B\x03\x88\x0E\x2B\x76\xDC\x44\x3D\x4D\xFF\xB2\xC8\xC3\x83\xB1\x33\x37'
+ b'\x53\x51\x33\x4B\xCA\x1A\xAD\x7E\x6A\xBC\x61\x8B\x84\xDB\x7F\xCF\x61\xB2\x1D\x21\x83\xCF'
+ b'\xB8\x3F\xC6\x98\xED\xD8\x66\x06\xCF\x03\x30\x96\x9D\xB4\x7A\x16\xDF\x6E\xA7\x30\xEB\x77'
+ b'\xF7\x40\x13\xFB\xF2\xAC\x41\x79\x9D\xDC\xC0\xED\x4B\x8B\x19\xEE\x05\x3D\x61\x20\x39\x7E'
+ b'\x80\x1D\x3A\x23\x69\x48\x43\x60\x8B\x3E\x63\xAD\x01\x7A\xDE\x6F\x01\xBA\x51\xF3\x4B\x14'
+ b'\xBF\x6B\x77\x1A\x32\xC2\x0C\x93\xCC\x35\xBC\x66\xC6\x69',
signer['signature'].native
)
-
def test_parse_content_info_pkcs7_signed_digested_data(self):
with open(os.path.join(fixtures_dir, 'pkcs7-signed-digested.der'), 'rb') as f:
info = cms.ContentInfo.load(f.read())
@@ -707,6 +756,17 @@
signer['signature_algorithm'].native
)
self.assertEqual(
- b'\x70\xBC\x18\x82\x41\xD6\xD8\xE7\x5C\xDC\x42\x27\xA5\xA8\xAA\x8B\x16\x15\x61\x3A\xE5\x47\x53\xFD\x8F\x45\xA3\x82\xE2\x72\x44\x07\xD1\xCB\xBF\xB4\x85\x4A\x2A\x16\x19\xDE\xDC\x53\x15\xCF\x98\xEE\x5C\x0E\xDF\xDE\xC8\x79\xCE\x2B\x38\x61\x36\xB0\xA1\xCB\x94\xD6\x4F\xCD\x83\xEF\x0C\xC9\x23\xA0\x7B\x8B\x65\x40\x5C\x3D\xA8\x3E\xCC\x0D\x1F\x17\x23\xF3\x74\x9F\x7E\x88\xF8\xF3\xBE\x4E\x19\x95\x0F\xEB\x95\x55\x69\xB4\xAA\xC3\x2A\x36\x03\x93\x1C\xDC\xE5\x65\x3F\x4E\x5E\x03\xC8\x56\xD8\x57\x8F\xE8\x2D\x85\x32\xDA\xFD\x79\xD4\xDD\x88\xCA\xA3\x14\x41\xE4\x3B\x03\x88\x0E\x2B\x76\xDC\x44\x3D\x4D\xFF\xB2\xC8\xC3\x83\xB1\x33\x37\x53\x51\x33\x4B\xCA\x1A\xAD\x7E\x6A\xBC\x61\x8B\x84\xDB\x7F\xCF\x61\xB2\x1D\x21\x83\xCF\xB8\x3F\xC6\x98\xED\xD8\x66\x06\xCF\x03\x30\x96\x9D\xB4\x7A\x16\xDF\x6E\xA7\x30\xEB\x77\xF7\x40\x13\xFB\xF2\xAC\x41\x79\x9D\xDC\xC0\xED\x4B\x8B\x19\xEE\x05\x3D\x61\x20\x39\x7E\x80\x1D\x3A\x23\x69\x48\x43\x60\x8B\x3E\x63\xAD\x01\x7A\xDE\x6F\x01\xBA\x51\xF3\x4B\x14\xBF\x6B\x77\x1A\x32\xC2\x0C\x93\xCC\x35\xBC\x66\xC6\x69',
+ b'\x70\xBC\x18\x82\x41\xD6\xD8\xE7\x5C\xDC\x42\x27\xA5\xA8\xAA\x8B\x16\x15\x61\x3A\xE5\x47'
+ b'\x53\xFD\x8F\x45\xA3\x82\xE2\x72\x44\x07\xD1\xCB\xBF\xB4\x85\x4A\x2A\x16\x19\xDE\xDC\x53'
+ b'\x15\xCF\x98\xEE\x5C\x0E\xDF\xDE\xC8\x79\xCE\x2B\x38\x61\x36\xB0\xA1\xCB\x94\xD6\x4F\xCD'
+ b'\x83\xEF\x0C\xC9\x23\xA0\x7B\x8B\x65\x40\x5C\x3D\xA8\x3E\xCC\x0D\x1F\x17\x23\xF3\x74\x9F'
+ b'\x7E\x88\xF8\xF3\xBE\x4E\x19\x95\x0F\xEB\x95\x55\x69\xB4\xAA\xC3\x2A\x36\x03\x93\x1C\xDC'
+ b'\xE5\x65\x3F\x4E\x5E\x03\xC8\x56\xD8\x57\x8F\xE8\x2D\x85\x32\xDA\xFD\x79\xD4\xDD\x88\xCA'
+ b'\xA3\x14\x41\xE4\x3B\x03\x88\x0E\x2B\x76\xDC\x44\x3D\x4D\xFF\xB2\xC8\xC3\x83\xB1\x33\x37'
+ b'\x53\x51\x33\x4B\xCA\x1A\xAD\x7E\x6A\xBC\x61\x8B\x84\xDB\x7F\xCF\x61\xB2\x1D\x21\x83\xCF'
+ b'\xB8\x3F\xC6\x98\xED\xD8\x66\x06\xCF\x03\x30\x96\x9D\xB4\x7A\x16\xDF\x6E\xA7\x30\xEB\x77'
+ b'\xF7\x40\x13\xFB\xF2\xAC\x41\x79\x9D\xDC\xC0\xED\x4B\x8B\x19\xEE\x05\x3D\x61\x20\x39\x7E'
+ b'\x80\x1D\x3A\x23\x69\x48\x43\x60\x8B\x3E\x63\xAD\x01\x7A\xDE\x6F\x01\xBA\x51\xF3\x4B\x14'
+ b'\xBF\x6B\x77\x1A\x32\xC2\x0C\x93\xCC\x35\xBC\x66\xC6\x69',
signer['signature'].native
)
diff --git a/tests/test_core.py b/tests/test_core.py
index a978ed2..2cc1de6 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -6,7 +6,7 @@
from asn1crypto import core
-from .unittest_data import DataDecorator, data
+from .unittest_data import data_decorator, data
from ._unittest_compat import patch
patch()
@@ -70,7 +70,7 @@
]
-@DataDecorator
+@data_decorator
class CoreTests(unittest.TestCase):
def test_sequence_spec(self):
@@ -84,23 +84,22 @@
seq = SequenceAny()
self.assertEqual(core.Any, seq.spec())
- #pylint: disable=C0326
@staticmethod
def compare_primitive_info():
return (
- (core.ObjectIdentifier('1.2.3'), core.ObjectIdentifier('1.2.3'), True),
- (core.Integer(1), Enum(1), False),
- (core.Integer(1), core.Integer(1, tag_type='implicit', tag=5), True),
- (core.Integer(1), core.Integer(1, tag_type='explicit', tag=5), True),
- (core.Integer(1), core.Integer(2), False),
- (core.OctetString(b''), core.OctetString(b''), True),
- (core.OctetString(b''), core.OctetString(b'1'), False),
- (core.OctetString(b''), core.OctetBitString(b''), False),
- (core.ParsableOctetString(b'12'), core.OctetString(b'12'), True),
- (core.ParsableOctetBitString(b'12'), core.OctetBitString(b'12'), True),
- (core.UTF8String('12'), core.UTF8String('12'), True),
- (core.UTF8String('12'), core.UTF8String('1'), False),
- (core.UTF8String('12'), core.IA5String('12'), False),
+ (core.ObjectIdentifier('1.2.3'), core.ObjectIdentifier('1.2.3'), True),
+ (core.Integer(1), Enum(1), False),
+ (core.Integer(1), core.Integer(1, tag_type='implicit', tag=5), True),
+ (core.Integer(1), core.Integer(1, tag_type='explicit', tag=5), True),
+ (core.Integer(1), core.Integer(2), False),
+ (core.OctetString(b''), core.OctetString(b''), True),
+ (core.OctetString(b''), core.OctetString(b'1'), False),
+ (core.OctetString(b''), core.OctetBitString(b''), False),
+ (core.ParsableOctetString(b'12'), core.OctetString(b'12'), True),
+ (core.ParsableOctetBitString(b'12'), core.OctetBitString(b'12'), True),
+ (core.UTF8String('12'), core.UTF8String('12'), True),
+ (core.UTF8String('12'), core.UTF8String('1'), False),
+ (core.UTF8String('12'), core.IA5String('12'), False),
)
@data('compare_primitive_info')
@@ -110,19 +109,18 @@
else:
self.assertNotEqual(one, two)
- #pylint: disable=C0326
@staticmethod
def integer_info():
return (
- (0, b'\x02\x01\x00'),
- (255, b'\x02\x02\x00\xFF'),
- (128, b'\x02\x02\x00\x80'),
- (127, b'\x02\x01\x7F'),
- (-127, b'\x02\x01\x81'),
- (-127, b'\x02\x01\x81'),
- (32768, b'\x02\x03\x00\x80\x00'),
- (-32768, b'\x02\x02\x80\x00'),
- (-32769, b'\x02\x03\xFF\x7F\xFF'),
+ (0, b'\x02\x01\x00'),
+ (255, b'\x02\x02\x00\xFF'),
+ (128, b'\x02\x02\x00\x80'),
+ (127, b'\x02\x01\x7F'),
+ (-127, b'\x02\x01\x81'),
+ (-127, b'\x02\x01\x81'),
+ (32768, b'\x02\x03\x00\x80\x00'),
+ (-32768, b'\x02\x02\x80\x00'),
+ (-32769, b'\x02\x03\xFF\x7F\xFF'),
)
@data('integer_info')
@@ -131,11 +129,10 @@
self.assertEqual(der_bytes, i.dump())
self.assertEqual(native, core.Integer.load(der_bytes).native)
- #pylint: disable=C0326
@staticmethod
def type_info():
return (
- ('universal/object_identifier.der', core.ObjectIdentifier, '1.2.840.113549.1.1.1'),
+ ('universal/object_identifier.der', core.ObjectIdentifier, '1.2.840.113549.1.1.1'),
)
@data('type_info')
@@ -147,11 +144,10 @@
self.assertEqual(native, parsed.native)
self.assertEqual(der, parsed.dump(force=True))
- #pylint: disable=C0326
@staticmethod
def bit_string_info():
return (
- ((0, 1, 1), b'\x03\x02\x05\x60'),
+ ((0, 1, 1), b'\x03\x02\x05\x60'),
((0, 1, 1, 0, 0, 0, 0, 0), b'\x03\x02\x00\x60'),
)
@@ -168,7 +164,6 @@
self.assertEqual(False, named[1])
self.assertEqual(True, named[0])
- #pylint: disable=C0326
@staticmethod
def mapped_bit_string_info():
return (
diff --git a/tests/test_crl.py b/tests/test_crl.py
index 6ee483d..f030635 100644
--- a/tests/test_crl.py
+++ b/tests/test_crl.py
@@ -13,7 +13,7 @@
if sys.version_info < (3,):
byte_cls = str
- num_cls = long #pylint: disable=E0602
+ num_cls = long # noqa
else:
byte_cls = bytes
num_cls = int
diff --git a/tests/test_csr.py b/tests/test_csr.py
index 7e9dbd5..b950971 100644
--- a/tests/test_csr.py
+++ b/tests/test_csr.py
@@ -12,7 +12,7 @@
if sys.version_info < (3,):
byte_cls = str
- num_cls = long #pylint: disable=E0602
+ num_cls = long # noqa
else:
byte_cls = bytes
num_cls = int
@@ -55,7 +55,7 @@
cri['subject_pk_info']['algorithm'].native
)
self.assertEqual(
- 24141757533938720807477509823483015516687050697622322097001928034085434547050399731881871694642845241206788286795830006142635608141713689209738431462004600429798152826994774062467402648660593454536565119527837471261495586474194846971065722669734666949739228862107500673350843489920495869942508240779131331715037662761414997889327943217889802893638175792326783316531272170879284118280173511200768884738639370318760377047837471530387161553030663446359575963736475504659902898072137674205021477968813148345198711103071746476009234601299344030395455052526948041544669303473529511160643491569274897838845918784633403435929,
+ 24141757533938720807477509823483015516687050697622322097001928034085434547050399731881871694642845241206788286795830006142635608141713689209738431462004600429798152826994774062467402648660593454536565119527837471261495586474194846971065722669734666949739228862107500673350843489920495869942508240779131331715037662761414997889327943217889802893638175792326783316531272170879284118280173511200768884738639370318760377047837471530387161553030663446359575963736475504659902898072137674205021477968813148345198711103071746476009234601299344030395455052526948041544669303473529511160643491569274897838845918784633403435929, # noqa
cri['subject_pk_info']['public_key'].parsed['modulus'].native
)
self.assertEqual(
@@ -67,7 +67,6 @@
cri['attributes'].native
)
-
def test_parse_csr2(self):
with open(os.path.join(fixtures_dir, 'test-third-der.csr'), 'rb') as f:
certification_request = csr.CertificationRequest.load(f.read())
@@ -99,7 +98,7 @@
cri['subject_pk_info']['algorithm'].native
)
self.assertEqual(
- 24242772097421005542208203320016703216069397492249392798445262959177221203301502279838173203064357049006693856302147277901773700963054800321566171864477088538775137040886151390015408166478059887940234405152693144166884492162723776487601158833605063151869850475289834250129252480954724818505034734280077580919995584375189497366089269712298471489896645221362055822887892887126082288043106492130176555423739906252380437817155678204772878611148787130925042126257401487070141904017757131876614711613405231164930930771261221451019736883391322299033324412671768599041417705072563016759224152503535867541947310239343903761461,
+ 24242772097421005542208203320016703216069397492249392798445262959177221203301502279838173203064357049006693856302147277901773700963054800321566171864477088538775137040886151390015408166478059887940234405152693144166884492162723776487601158833605063151869850475289834250129252480954724818505034734280077580919995584375189497366089269712298471489896645221362055822887892887126082288043106492130176555423739906252380437817155678204772878611148787130925042126257401487070141904017757131876614711613405231164930930771261221451019736883391322299033324412671768599041417705072563016759224152503535867541947310239343903761461, # noqa
cri['subject_pk_info']['public_key'].parsed['modulus'].native
)
self.assertEqual(
diff --git a/tests/test_keys.py b/tests/test_keys.py
index 8a03182..70b0ae2 100644
--- a/tests/test_keys.py
+++ b/tests/test_keys.py
@@ -6,7 +6,7 @@
from asn1crypto import keys, core, util
-from .unittest_data import DataDecorator, data
+from .unittest_data import data_decorator, data
from ._unittest_compat import patch
patch()
@@ -15,7 +15,7 @@
fixtures_dir = os.path.join(tests_root, 'fixtures')
-@DataDecorator
+@data_decorator
class KeysTests(unittest.TestCase):
def test_parse_rsa_private_key(self):
@@ -27,7 +27,7 @@
key['version'].native
)
self.assertEqual(
- 23903990516906431865559598284199534387004799030432486061102966678620221767754702651554142956492614440585611990224871381291841413369032752409360196079700921141819811294444393525264295297988924243231844876926173670633422654261873814968313363171188082579071492839040415373948505938897419917635370450127498164824808630475648771544810334682447182123219422360569466851807131368135806769502898151721274383486320505905826683946456552230958810028663378886363555981449715929872558073101554364803925363048965464124465016494920967179276744892632783712377912841537032383450409486298694116013299423220523450956288827030007092359007,
+ 23903990516906431865559598284199534387004799030432486061102966678620221767754702651554142956492614440585611990224871381291841413369032752409360196079700921141819811294444393525264295297988924243231844876926173670633422654261873814968313363171188082579071492839040415373948505938897419917635370450127498164824808630475648771544810334682447182123219422360569466851807131368135806769502898151721274383486320505905826683946456552230958810028663378886363555981449715929872558073101554364803925363048965464124465016494920967179276744892632783712377912841537032383450409486298694116013299423220523450956288827030007092359007, # noqa
key['modulus'].native
)
self.assertEqual(
@@ -35,27 +35,27 @@
key['public_exponent'].native
)
self.assertEqual(
- 9979296894007354255484849917690758820642557661666429934720496335307525025035760937280030384204921358841911348590147260206368632524783497961763507098900120579828036636037636859350155169644276779450131617753331883188587268575077705380671279069284616924232052795766448946873233783789819627790465470123569125678598045748629782316184667685110712273519313310937077963014676074966877849272992367512921997850502687035430136911690081438185238817835171119161013656103255853961444458012340770881411877222316871444386486841632394098449378506206645681449475758856053641206175913163492821894709155329556294181613669730336931773953,
+ 9979296894007354255484849917690758820642557661666429934720496335307525025035760937280030384204921358841911348590147260206368632524783497961763507098900120579828036636037636859350155169644276779450131617753331883188587268575077705380671279069284616924232052795766448946873233783789819627790465470123569125678598045748629782316184667685110712273519313310937077963014676074966877849272992367512921997850502687035430136911690081438185238817835171119161013656103255853961444458012340770881411877222316871444386486841632394098449378506206645681449475758856053641206175913163492821894709155329556294181613669730336931773953, # noqa
key['private_exponent'].native
)
self.assertEqual(
- 166647390172913547327716251713919741459272587597255782032652236515036001974461323181989715320980256918783849999012066159723695368018857439366733087649658067943054926668058248612521531843495934099419046629521378187012692776633310821178903471282399402138521150042979117060141563972064613977168440186057796106743,
+ 166647390172913547327716251713919741459272587597255782032652236515036001974461323181989715320980256918783849999012066159723695368018857439366733087649658067943054926668058248612521531843495934099419046629521378187012692776633310821178903471282399402138521150042979117060141563972064613977168440186057796106743, # noqa
key['prime1'].native
)
self.assertEqual(
- 143440533284701431115857974625778819273481773744021067505004499855263691219807413711274106281992493130281690570930126889424222979194828112331057105055939481042398415265558356642606674863401518188395487842736496447305100392269029249928750130190700690239916449523411304928539660679996452045625683879143320460249,
+ 143440533284701431115857974625778819273481773744021067505004499855263691219807413711274106281992493130281690570930126889424222979194828112331057105055939481042398415265558356642606674863401518188395487842736496447305100392269029249928750130190700690239916449523411304928539660679996452045625683879143320460249, # noqa
key['prime2'].native
)
self.assertEqual(
- 109414079859473229289779858629449815451592843305649008118818271892297238643195390011716060554289324731958287404176117228233683079641781234394481865640434212819044363330635799312574408253258259431525735957118503776629524657609514187779529692628749620437591384488141789034909003405007374076072765197764330205487,
+ 109414079859473229289779858629449815451592843305649008118818271892297238643195390011716060554289324731958287404176117228233683079641781234394481865640434212819044363330635799312574408253258259431525735957118503776629524657609514187779529692628749620437591384488141789034909003405007374076072765197764330205487, # noqa
key['exponent1'].native
)
self.assertEqual(
- 39361498857013145813625735320048312950154816653378623953034178027634194773898965899927575680536994315500952488328843279054659597751495930118280223039291020752651068863936425009698924893471060669547041417272275998418220630400632040385105243470857091616562513209775072216226822370097138922876120342440353924609,
+ 39361498857013145813625735320048312950154816653378623953034178027634194773898965899927575680536994315500952488328843279054659597751495930118280223039291020752651068863936425009698924893471060669547041417272275998418220630400632040385105243470857091616562513209775072216226822370097138922876120342440353924609, # noqa
key['exponent2'].native
)
self.assertEqual(
- 109796662729796355370195012683418958273962986010546166376879205603219777065076464250440708895625560840314914603409569660942497623175203159192440744329997446961447023349392064212216532091513743978251892999757210494211477167363008686808094766092274115601607346901935491774285446659775729268493276413171032997893,
+ 109796662729796355370195012683418958273962986010546166376879205603219777065076464250440708895625560840314914603409569660942497623175203159192440744329997446961447023349392064212216532091513743978251892999757210494211477167363008686808094766092274115601607346901935491774285446659775729268493276413171032997893, # noqa
key['coefficient'].native
)
self.assertEqual(
@@ -72,7 +72,7 @@
key[0].native
)
self.assertEqual(
- 23903990516906431865559598284199534387004799030432486061102966678620221767754702651554142956492614440585611990224871381291841413369032752409360196079700921141819811294444393525264295297988924243231844876926173670633422654261873814968313363171188082579071492839040415373948505938897419917635370450127498164824808630475648771544810334682447182123219422360569466851807131368135806769502898151721274383486320505905826683946456552230958810028663378886363555981449715929872558073101554364803925363048965464124465016494920967179276744892632783712377912841537032383450409486298694116013299423220523450956288827030007092359007,
+ 23903990516906431865559598284199534387004799030432486061102966678620221767754702651554142956492614440585611990224871381291841413369032752409360196079700921141819811294444393525264295297988924243231844876926173670633422654261873814968313363171188082579071492839040415373948505938897419917635370450127498164824808630475648771544810334682447182123219422360569466851807131368135806769502898151721274383486320505905826683946456552230958810028663378886363555981449715929872558073101554364803925363048965464124465016494920967179276744892632783712377912841537032383450409486298694116013299423220523450956288827030007092359007, # noqa
key[1].native
)
self.assertEqual(
@@ -80,32 +80,32 @@
key[2].native
)
self.assertEqual(
- 9979296894007354255484849917690758820642557661666429934720496335307525025035760937280030384204921358841911348590147260206368632524783497961763507098900120579828036636037636859350155169644276779450131617753331883188587268575077705380671279069284616924232052795766448946873233783789819627790465470123569125678598045748629782316184667685110712273519313310937077963014676074966877849272992367512921997850502687035430136911690081438185238817835171119161013656103255853961444458012340770881411877222316871444386486841632394098449378506206645681449475758856053641206175913163492821894709155329556294181613669730336931773953,
+ 9979296894007354255484849917690758820642557661666429934720496335307525025035760937280030384204921358841911348590147260206368632524783497961763507098900120579828036636037636859350155169644276779450131617753331883188587268575077705380671279069284616924232052795766448946873233783789819627790465470123569125678598045748629782316184667685110712273519313310937077963014676074966877849272992367512921997850502687035430136911690081438185238817835171119161013656103255853961444458012340770881411877222316871444386486841632394098449378506206645681449475758856053641206175913163492821894709155329556294181613669730336931773953, # noqa
key[3].native
)
self.assertEqual(
- 166647390172913547327716251713919741459272587597255782032652236515036001974461323181989715320980256918783849999012066159723695368018857439366733087649658067943054926668058248612521531843495934099419046629521378187012692776633310821178903471282399402138521150042979117060141563972064613977168440186057796106743,
+ 166647390172913547327716251713919741459272587597255782032652236515036001974461323181989715320980256918783849999012066159723695368018857439366733087649658067943054926668058248612521531843495934099419046629521378187012692776633310821178903471282399402138521150042979117060141563972064613977168440186057796106743, # noqa
key[4].native
)
self.assertEqual(
- 143440533284701431115857974625778819273481773744021067505004499855263691219807413711274106281992493130281690570930126889424222979194828112331057105055939481042398415265558356642606674863401518188395487842736496447305100392269029249928750130190700690239916449523411304928539660679996452045625683879143320460249,
+ 143440533284701431115857974625778819273481773744021067505004499855263691219807413711274106281992493130281690570930126889424222979194828112331057105055939481042398415265558356642606674863401518188395487842736496447305100392269029249928750130190700690239916449523411304928539660679996452045625683879143320460249, # noqa
key[5].native
)
self.assertEqual(
- 109414079859473229289779858629449815451592843305649008118818271892297238643195390011716060554289324731958287404176117228233683079641781234394481865640434212819044363330635799312574408253258259431525735957118503776629524657609514187779529692628749620437591384488141789034909003405007374076072765197764330205487,
+ 109414079859473229289779858629449815451592843305649008118818271892297238643195390011716060554289324731958287404176117228233683079641781234394481865640434212819044363330635799312574408253258259431525735957118503776629524657609514187779529692628749620437591384488141789034909003405007374076072765197764330205487, # noqa
key[6].native
)
self.assertEqual(
- 39361498857013145813625735320048312950154816653378623953034178027634194773898965899927575680536994315500952488328843279054659597751495930118280223039291020752651068863936425009698924893471060669547041417272275998418220630400632040385105243470857091616562513209775072216226822370097138922876120342440353924609,
+ 39361498857013145813625735320048312950154816653378623953034178027634194773898965899927575680536994315500952488328843279054659597751495930118280223039291020752651068863936425009698924893471060669547041417272275998418220630400632040385105243470857091616562513209775072216226822370097138922876120342440353924609, # noqa
key[7].native
)
self.assertEqual(
- 109796662729796355370195012683418958273962986010546166376879205603219777065076464250440708895625560840314914603409569660942497623175203159192440744329997446961447023349392064212216532091513743978251892999757210494211477167363008686808094766092274115601607346901935491774285446659775729268493276413171032997893,
+ 109796662729796355370195012683418958273962986010546166376879205603219777065076464250440708895625560840314914603409569660942497623175203159192440744329997446961447023349392064212216532091513743978251892999757210494211477167363008686808094766092274115601607346901935491774285446659775729268493276413171032997893, # noqa
key[8].native
)
with self.assertRaises(KeyError):
- key[9].native #pylint: disable=W0104
+ key[9].native
def test_parse_dsa_private_key(self):
with open(os.path.join(fixtures_dir, 'keys/test-dsa-der.key'), 'rb') as f:
@@ -116,7 +116,7 @@
key['version'].native
)
self.assertEqual(
- 4511743893397705393934377497936985478231822206263141826261443300639402520800626925517264115785551703273809312112372693877437137848393530691841757974971843334497076835630893064661599193178307024379015589119302113551197423138934242435710226975119594589912289060014025377813473273600967729027125618396732574594753039493158066887433778053086408525146692226448554390096911703556213619406958876388642882534250747780313634767409586007581976273681005928967585750017105562145167146445061803488570714706090280814293902464230717946651489964409785146803791743658888866280873858000476717727810363942159874283767926511678640730707887895260274767195555813448140889391762755466967436731106514029224490921857229134393798015954890071206959203407845438863870686180087606429828973298318856683615900474921310376145478859687052812749087809700610549251964102790514588562086548577933609968589710807989944739877028770343142449461177732058649962678857,
+ 4511743893397705393934377497936985478231822206263141826261443300639402520800626925517264115785551703273809312112372693877437137848393530691841757974971843334497076835630893064661599193178307024379015589119302113551197423138934242435710226975119594589912289060014025377813473273600967729027125618396732574594753039493158066887433778053086408525146692226448554390096911703556213619406958876388642882534250747780313634767409586007581976273681005928967585750017105562145167146445061803488570714706090280814293902464230717946651489964409785146803791743658888866280873858000476717727810363942159874283767926511678640730707887895260274767195555813448140889391762755466967436731106514029224490921857229134393798015954890071206959203407845438863870686180087606429828973298318856683615900474921310376145478859687052812749087809700610549251964102790514588562086548577933609968589710807989944739877028770343142449461177732058649962678857, # noqa
key['p'].native
)
self.assertEqual(
@@ -124,11 +124,11 @@
key['q'].native
)
self.assertEqual(
- 761437146067908309288345767887973163494473925243194806582679580640442238588269326525839153095505341738937595419375068472941615006110237832663093084973431440436421580371384720052414080562019831325744042316268714195397974084616335082272743706567701546951285088540646372701485690904535540223121118329044403681933304838754517522024738251994717369464179515923093116622352823578284891812676662979104509631349201801577889230316128523885862472086364717411346341249139971907827526291913249445756671582283459372536334490171231311487207683108274785825764378203622999309355578169139646003751751448501475767709869676880946562283552431757983801739671783678927397420797147373441051876558068212062253171347849380506793433921881336652424898488378657239798694995315456959568806256079056461448199493507273882763491729787817044805150879660784158902456811649964987582162907020243296662602990514615480712948126671999033658064244112238138589732202,
+ 761437146067908309288345767887973163494473925243194806582679580640442238588269326525839153095505341738937595419375068472941615006110237832663093084973431440436421580371384720052414080562019831325744042316268714195397974084616335082272743706567701546951285088540646372701485690904535540223121118329044403681933304838754517522024738251994717369464179515923093116622352823578284891812676662979104509631349201801577889230316128523885862472086364717411346341249139971907827526291913249445756671582283459372536334490171231311487207683108274785825764378203622999309355578169139646003751751448501475767709869676880946562283552431757983801739671783678927397420797147373441051876558068212062253171347849380506793433921881336652424898488378657239798694995315456959568806256079056461448199493507273882763491729787817044805150879660784158902456811649964987582162907020243296662602990514615480712948126671999033658064244112238138589732202, # noqa
key['g'].native
)
self.assertEqual(
- 934231235067929794039535952071098031636053793876274937162425423023735221571983693370780054696865229184537343792766496068557051933738826401423094028670222490622041397241325320965905259541032379046252395145258594355589801644789631904099105867133976990593761395721476198083091062806327384261369876465927159169400428623265291958463077792777155465482611741502621885386691681062128487785344975981628995609792181581218570320181053055516069553767918513262908069925035292416868414952256645902605335068760774106734518308281769128146479819566784704033671969858507248124850451414380441279385481154336362988505436125981975735568289420374790767927084033441728922597082155884801013899630856890463962357814273014111039522903328923758417820349377075487103441305806369234738881875734407495707878637895190993370257589211331043479113328811265005530361001980539377903738453549980082795009589559114091215518866106998956304437954236070776810740036,
+ 934231235067929794039535952071098031636053793876274937162425423023735221571983693370780054696865229184537343792766496068557051933738826401423094028670222490622041397241325320965905259541032379046252395145258594355589801644789631904099105867133976990593761395721476198083091062806327384261369876465927159169400428623265291958463077792777155465482611741502621885386691681062128487785344975981628995609792181581218570320181053055516069553767918513262908069925035292416868414952256645902605335068760774106734518308281769128146479819566784704033671969858507248124850451414380441279385481154336362988505436125981975735568289420374790767927084033441728922597082155884801013899630856890463962357814273014111039522903328923758417820349377075487103441305806369234738881875734407495707878637895190993370257589211331043479113328811265005530361001980539377903738453549980082795009589559114091215518866106998956304437954236070776810740036, # noqa
key['public_key'].native
)
self.assertEqual(
@@ -161,14 +161,25 @@
(
'curve',
util.OrderedDict([
- ('a', b'\xFF\xFF\xFF\xFF\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFC'),
- ('b', b'\x5A\xC6\x35\xD8\xAA\x3A\x93\xE7\xB3\xEB\xBD\x55\x76\x98\x86\xBC\x65\x1D\x06\xB0\xCC\x53\xB0\xF6\x3B\xCE\x3C\x3E\x27\xD2\x60\x4B'),
+ (
+ 'a',
+ b'\xFF\xFF\xFF\xFF\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00'
+ b'\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFC'
+ ),
+ (
+ 'b',
+ b'\x5A\xC6\x35\xD8\xAA\x3A\x93\xE7\xB3\xEB\xBD\x55\x76\x98\x86\xBC'
+ b'\x65\x1D\x06\xB0\xCC\x53\xB0\xF6\x3B\xCE\x3C\x3E\x27\xD2\x60\x4B'
+ ),
('seed', b'\xC4\x9D\x36\x08\x86\xE7\x04\x93\x6A\x66\x78\xE1\x13\x9D\x26\xB7\x81\x9F\x7E\x90'),
])
),
(
'base',
- b'\x04\x6B\x17\xD1\xF2\xE1\x2C\x42\x47\xF8\xBC\xE6\xE5\x63\xA4\x40\xF2\x77\x03\x7D\x81\x2D\xEB\x33\xA0\xF4\xA1\x39\x45\xD8\x98\xC2\x96\x4F\xE3\x42\xE2\xFE\x1A\x7F\x9B\x8E\xE7\xEB\x4A\x7C\x0F\x9E\x16\x2B\xCE\x33\x57\x6B\x31\x5E\xCE\xCB\xB6\x40\x68\x37\xBF\x51\xF5'
+ b'\x04\x6B\x17\xD1\xF2\xE1\x2C\x42\x47\xF8\xBC\xE6\xE5\x63\xA4\x40\xF2\x77'
+ b'\x03\x7D\x81\x2D\xEB\x33\xA0\xF4\xA1\x39\x45\xD8\x98\xC2\x96\x4F\xE3\x42'
+ b'\xE2\xFE\x1A\x7F\x9B\x8E\xE7\xEB\x4A\x7C\x0F\x9E\x16\x2B\xCE\x33\x57\x6B'
+ b'\x31\x5E\xCE\xCB\xB6\x40\x68\x37\xBF\x51\xF5'
),
(
'order',
@@ -180,7 +191,10 @@
key['parameters'].native
)
self.assertEqual(
- b'\x04\x8B\x5D\x4C\x71\xF7\xD6\xC6\xA3\x49\x63\x42\x5C\x47\x9F\xCB\x73\x24\x1D\xC9\xDD\xD1\x2D\xF1\x3A\x9F\xB7\x04\xDE\x20\xD0\x58\x00\x93\x54\xF6\x89\xC7\x2F\x87\x2B\xF7\xF9\x3D\x3B\x34\xED\x9E\x7B\x0E\x3D\x57\x42\xDF\x78\x03\x0B\xCC\x31\xC6\x03\xD7\x9F\x60\x01',
+ b'\x04\x8B\x5D\x4C\x71\xF7\xD6\xC6\xA3\x49\x63\x42\x5C\x47\x9F\xCB\x73\x24\x1D\xC9\xDD'
+ b'\xD1\x2D\xF1\x3A\x9F\xB7\x04\xDE\x20\xD0\x58\x00\x93\x54\xF6\x89\xC7\x2F\x87\x2B\xF7'
+ b'\xF9\x3D\x3B\x34\xED\x9E\x7B\x0E\x3D\x57\x42\xDF\x78\x03\x0B\xCC\x31\xC6\x03\xD7\x9F'
+ b'\x60\x01',
key['public_key'].native
)
@@ -189,7 +203,7 @@
key = keys.RSAPublicKey.load(f.read())
self.assertEqual(
- 23903990516906431865559598284199534387004799030432486061102966678620221767754702651554142956492614440585611990224871381291841413369032752409360196079700921141819811294444393525264295297988924243231844876926173670633422654261873814968313363171188082579071492839040415373948505938897419917635370450127498164824808630475648771544810334682447182123219422360569466851807131368135806769502898151721274383486320505905826683946456552230958810028663378886363555981449715929872558073101554364803925363048965464124465016494920967179276744892632783712377912841537032383450409486298694116013299423220523450956288827030007092359007,
+ 23903990516906431865559598284199534387004799030432486061102966678620221767754702651554142956492614440585611990224871381291841413369032752409360196079700921141819811294444393525264295297988924243231844876926173670633422654261873814968313363171188082579071492839040415373948505938897419917635370450127498164824808630475648771544810334682447182123219422360569466851807131368135806769502898151721274383486320505905826683946456552230958810028663378886363555981449715929872558073101554364803925363048965464124465016494920967179276744892632783712377912841537032383450409486298694116013299423220523450956288827030007092359007, # noqa
key['modulus'].native
)
self.assertEqual(
@@ -212,7 +226,7 @@
key['algorithm']['parameters'].native
)
self.assertEqual(
- 23903990516906431865559598284199534387004799030432486061102966678620221767754702651554142956492614440585611990224871381291841413369032752409360196079700921141819811294444393525264295297988924243231844876926173670633422654261873814968313363171188082579071492839040415373948505938897419917635370450127498164824808630475648771544810334682447182123219422360569466851807131368135806769502898151721274383486320505905826683946456552230958810028663378886363555981449715929872558073101554364803925363048965464124465016494920967179276744892632783712377912841537032383450409486298694116013299423220523450956288827030007092359007,
+ 23903990516906431865559598284199534387004799030432486061102966678620221767754702651554142956492614440585611990224871381291841413369032752409360196079700921141819811294444393525264295297988924243231844876926173670633422654261873814968313363171188082579071492839040415373948505938897419917635370450127498164824808630475648771544810334682447182123219422360569466851807131368135806769502898151721274383486320505905826683946456552230958810028663378886363555981449715929872558073101554364803925363048965464124465016494920967179276744892632783712377912841537032383450409486298694116013299423220523450956288827030007092359007, # noqa
public_key['modulus'].native
)
self.assertEqual(
@@ -244,7 +258,7 @@
key['version'].native
)
self.assertEqual(
- 23903990516906431865559598284199534387004799030432486061102966678620221767754702651554142956492614440585611990224871381291841413369032752409360196079700921141819811294444393525264295297988924243231844876926173670633422654261873814968313363171188082579071492839040415373948505938897419917635370450127498164824808630475648771544810334682447182123219422360569466851807131368135806769502898151721274383486320505905826683946456552230958810028663378886363555981449715929872558073101554364803925363048965464124465016494920967179276744892632783712377912841537032383450409486298694116013299423220523450956288827030007092359007,
+ 23903990516906431865559598284199534387004799030432486061102966678620221767754702651554142956492614440585611990224871381291841413369032752409360196079700921141819811294444393525264295297988924243231844876926173670633422654261873814968313363171188082579071492839040415373948505938897419917635370450127498164824808630475648771544810334682447182123219422360569466851807131368135806769502898151721274383486320505905826683946456552230958810028663378886363555981449715929872558073101554364803925363048965464124465016494920967179276744892632783712377912841537032383450409486298694116013299423220523450956288827030007092359007, # noqa
key['modulus'].native
)
self.assertEqual(
@@ -252,27 +266,27 @@
key['public_exponent'].native
)
self.assertEqual(
- 9979296894007354255484849917690758820642557661666429934720496335307525025035760937280030384204921358841911348590147260206368632524783497961763507098900120579828036636037636859350155169644276779450131617753331883188587268575077705380671279069284616924232052795766448946873233783789819627790465470123569125678598045748629782316184667685110712273519313310937077963014676074966877849272992367512921997850502687035430136911690081438185238817835171119161013656103255853961444458012340770881411877222316871444386486841632394098449378506206645681449475758856053641206175913163492821894709155329556294181613669730336931773953,
+ 9979296894007354255484849917690758820642557661666429934720496335307525025035760937280030384204921358841911348590147260206368632524783497961763507098900120579828036636037636859350155169644276779450131617753331883188587268575077705380671279069284616924232052795766448946873233783789819627790465470123569125678598045748629782316184667685110712273519313310937077963014676074966877849272992367512921997850502687035430136911690081438185238817835171119161013656103255853961444458012340770881411877222316871444386486841632394098449378506206645681449475758856053641206175913163492821894709155329556294181613669730336931773953, # noqa
key['private_exponent'].native
)
self.assertEqual(
- 166647390172913547327716251713919741459272587597255782032652236515036001974461323181989715320980256918783849999012066159723695368018857439366733087649658067943054926668058248612521531843495934099419046629521378187012692776633310821178903471282399402138521150042979117060141563972064613977168440186057796106743,
+ 166647390172913547327716251713919741459272587597255782032652236515036001974461323181989715320980256918783849999012066159723695368018857439366733087649658067943054926668058248612521531843495934099419046629521378187012692776633310821178903471282399402138521150042979117060141563972064613977168440186057796106743, # noqa
key['prime1'].native
)
self.assertEqual(
- 143440533284701431115857974625778819273481773744021067505004499855263691219807413711274106281992493130281690570930126889424222979194828112331057105055939481042398415265558356642606674863401518188395487842736496447305100392269029249928750130190700690239916449523411304928539660679996452045625683879143320460249,
+ 143440533284701431115857974625778819273481773744021067505004499855263691219807413711274106281992493130281690570930126889424222979194828112331057105055939481042398415265558356642606674863401518188395487842736496447305100392269029249928750130190700690239916449523411304928539660679996452045625683879143320460249, # noqa
key['prime2'].native
)
self.assertEqual(
- 109414079859473229289779858629449815451592843305649008118818271892297238643195390011716060554289324731958287404176117228233683079641781234394481865640434212819044363330635799312574408253258259431525735957118503776629524657609514187779529692628749620437591384488141789034909003405007374076072765197764330205487,
+ 109414079859473229289779858629449815451592843305649008118818271892297238643195390011716060554289324731958287404176117228233683079641781234394481865640434212819044363330635799312574408253258259431525735957118503776629524657609514187779529692628749620437591384488141789034909003405007374076072765197764330205487, # noqa
key['exponent1'].native
)
self.assertEqual(
- 39361498857013145813625735320048312950154816653378623953034178027634194773898965899927575680536994315500952488328843279054659597751495930118280223039291020752651068863936425009698924893471060669547041417272275998418220630400632040385105243470857091616562513209775072216226822370097138922876120342440353924609,
+ 39361498857013145813625735320048312950154816653378623953034178027634194773898965899927575680536994315500952488328843279054659597751495930118280223039291020752651068863936425009698924893471060669547041417272275998418220630400632040385105243470857091616562513209775072216226822370097138922876120342440353924609, # noqa
key['exponent2'].native
)
self.assertEqual(
- 109796662729796355370195012683418958273962986010546166376879205603219777065076464250440708895625560840314914603409569660942497623175203159192440744329997446961447023349392064212216532091513743978251892999757210494211477167363008686808094766092274115601607346901935491774285446659775729268493276413171032997893,
+ 109796662729796355370195012683418958273962986010546166376879205603219777065076464250440708895625560840314914603409569660942497623175203159192440744329997446961447023349392064212216532091513743978251892999757210494211477167363008686808094766092274115601607346901935491774285446659775729268493276413171032997893, # noqa
key['coefficient'].native
)
self.assertEqual(
@@ -285,14 +299,13 @@
key_info['attributes'].native
)
- #pylint: disable=C0326
@staticmethod
def key_sha1_hashes():
return (
- ('keys/test-public-der.key', b'\xbeB\x85=\xcc\xff\xe3\xf9(\x02\x8f~XV\xb4\xfd\x03\\\xeaK'),
- ('keys/test-public-dsa-der.key', b'\x81\xa37\x86\xf9\x99(\xf2tp`\x87\xf2\xd3~\x8d\x19a\xa8\xbe'),
+ ('keys/test-public-der.key', b'\xbeB\x85=\xcc\xff\xe3\xf9(\x02\x8f~XV\xb4\xfd\x03\\\xeaK'),
+ ('keys/test-public-dsa-der.key', b'\x81\xa37\x86\xf9\x99(\xf2tp`\x87\xf2\xd3~\x8d\x19a\xa8\xbe'),
('keys/test-public-ec-named-der.key', b'#\x8d\xee\xeeGH*\xe45T\xb8\xfdVh\x16_\xe2\xaa\xcd\x81'),
- ('keys/test-public-ec-der.key', b'T\xaaTpl4\x1am\xeb]\x97\xd7\x1e\xfc\xd5$<\x8a\x0e\xd7'),
+ ('keys/test-public-ec-der.key', b'T\xaaTpl4\x1am\xeb]\x97\xd7\x1e\xfc\xd5$<\x8a\x0e\xd7'),
)
@data('key_sha1_hashes')
@@ -302,14 +315,25 @@
self.assertEqual(sha1, public_key.sha1)
- #pylint: disable=C0326
@staticmethod
def key_sha256_hashes():
return (
- ('keys/test-public-der.key', b'\xd9\x80\xdf\x94J\x8e\x1e\xf5z\xd2o\x8eS\xa8\x03qX\x9a[\x17g\x12\x89\xc5\xcc\xca\x04\x94\xf2R|F'),
- ('keys/test-public-dsa-der.key', b'<\x10X\xbf=\xe4\xec3\xb9\xb2 \x11\xce9\xca\xd4\x95\xcf\xf9\xbc\x91q]O\x8f4\xbf\xdb\xdc\xe2\xd6\x82'),
- ('keys/test-public-ec-named-der.key', b'\x87e \xb4\x13\x8cu\xdd\x11\x92\xa4\xd9;\x8e\xe5"p\xb2\xb7\xa7\xcb8\x88\x16;f\xb9\xf8I\x86J\x1c'),
- ('keys/test-public-ec-der.key', b'\xf3\xa3k\xe0\xbf\xa9\xd9sl\xaa\x99\xe7\x9c-\xec\xb9\x0e\xe2d\xe9\xc3$\xb9\x893\x99A\xc19ec_'),
+ (
+ 'keys/test-public-der.key',
+ b'\xd9\x80\xdf\x94J\x8e\x1e\xf5z\xd2o\x8eS\xa8\x03qX\x9a[\x17g\x12\x89\xc5\xcc\xca\x04\x94\xf2R|F'
+ ),
+ (
+ 'keys/test-public-dsa-der.key',
+ b'<\x10X\xbf=\xe4\xec3\xb9\xb2 \x11\xce9\xca\xd4\x95\xcf\xf9\xbc\x91q]O\x8f4\xbf\xdb\xdc\xe2\xd6\x82'
+ ),
+ (
+ 'keys/test-public-ec-named-der.key',
+ b'\x87e \xb4\x13\x8cu\xdd\x11\x92\xa4\xd9;\x8e\xe5"p\xb2\xb7\xa7\xcb8\x88\x16;f\xb9\xf8I\x86J\x1c'
+ ),
+ (
+ 'keys/test-public-ec-der.key',
+ b'\xf3\xa3k\xe0\xbf\xa9\xd9sl\xaa\x99\xe7\x9c-\xec\xb9\x0e\xe2d\xe9\xc3$\xb9\x893\x99A\xc19ec_'
+ ),
)
@data('key_sha256_hashes')
@@ -319,14 +343,37 @@
self.assertEqual(sha256, public_key.sha256)
- #pylint: disable=C0326
@staticmethod
def key_pairs():
return (
- ('dsa', 'keys/test-pkcs8-dsa-der.key', 'keys/test-public-dsa-der.key', 'dsa', 3072),
- ('ec_named', 'keys/test-pkcs8-ec-named-der.key', 'keys/test-public-ec-named-der.key', 'ec', 256),
- ('ec', 'keys/test-pkcs8-ec-der.key', 'keys/test-public-ec-der.key', 'ec', 256),
- ('rsa', 'keys/test-pkcs8-der.key', 'keys/test-public-der.key', 'rsa', 2048),
+ (
+ 'dsa',
+ 'keys/test-pkcs8-dsa-der.key',
+ 'keys/test-public-dsa-der.key',
+ 'dsa',
+ 3072
+ ),
+ (
+ 'ec_named',
+ 'keys/test-pkcs8-ec-named-der.key',
+ 'keys/test-public-ec-named-der.key',
+ 'ec',
+ 256
+ ),
+ (
+ 'ec',
+ 'keys/test-pkcs8-ec-der.key',
+ 'keys/test-public-ec-der.key',
+ 'ec',
+ 256
+ ),
+ (
+ 'rsa',
+ 'keys/test-pkcs8-der.key',
+ 'keys/test-public-der.key',
+ 'rsa',
+ 2048
+ ),
)
@data('key_pairs', True)
@@ -345,7 +392,7 @@
with open(os.path.join(fixtures_dir, public_key_file), 'rb') as f:
public_key = keys.PublicKeyInfo.load(f.read())
- self.assertEqual(public_key['public_key'].native, private_key._compute_public_key().native) #pylint: disable=W0212
+ self.assertEqual(public_key['public_key'].native, private_key._compute_public_key().native)
@data('key_pairs', True)
def public_key_property(self, private_key_file, public_key_file, *_):
@@ -376,14 +423,29 @@
self.assertEqual(bit_size, private_key.bit_size)
self.assertEqual(bit_size, public_key.bit_size)
- #pylint: disable=C0326
@staticmethod
def key_variations():
return (
- ('dsa', 'keys/test-pkcs8-dsa-der.key', 'keys/test-dsa-der.key',),
- ('ec_named', 'keys/test-pkcs8-ec-named-der.key', 'keys/test-ec-named-der.key',),
- ('ec', 'keys/test-pkcs8-ec-der.key', 'keys/test-ec-der.key',),
- ('rsa', 'keys/test-pkcs8-der.key', 'keys/test-der.key',),
+ (
+ 'dsa',
+ 'keys/test-pkcs8-dsa-der.key',
+ 'keys/test-dsa-der.key',
+ ),
+ (
+ 'ec_named',
+ 'keys/test-pkcs8-ec-named-der.key',
+ 'keys/test-ec-named-der.key',
+ ),
+ (
+ 'ec',
+ 'keys/test-pkcs8-ec-der.key',
+ 'keys/test-ec-der.key',
+ ),
+ (
+ 'rsa',
+ 'keys/test-pkcs8-der.key',
+ 'keys/test-der.key',
+ ),
)
@data('key_variations', True)
@@ -399,14 +461,14 @@
with open(os.path.join(fixtures_dir, 'keys/test-pkcs8-der.key'), 'rb') as f:
private_key = keys.PrivateKeyInfo.load(f.read())
- with self.assertRaises(ValueError) as _:
- _ = private_key.curve
+ with self.assertRaises(ValueError):
+ private_key.curve
with open(os.path.join(fixtures_dir, 'keys/test-public-rsa-der.key'), 'rb') as f:
public_key = keys.PublicKeyInfo.load(f.read())
- with self.assertRaises(ValueError) as _:
- _ = public_key.curve
+ with self.assertRaises(ValueError):
+ public_key.curve
def test_curve_info_name(self):
with open(os.path.join(fixtures_dir, 'keys/test-pkcs8-ec-named-der.key'), 'rb') as f:
@@ -439,14 +501,28 @@
(
'curve',
util.OrderedDict([
- ('a', b'\xFF\xFF\xFF\xFF\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFC'),
- ('b', b'\x5A\xC6\x35\xD8\xAA\x3A\x93\xE7\xB3\xEB\xBD\x55\x76\x98\x86\xBC\x65\x1D\x06\xB0\xCC\x53\xB0\xF6\x3B\xCE\x3C\x3E\x27\xD2\x60\x4B'),
- ('seed', b'\xC4\x9D\x36\x08\x86\xE7\x04\x93\x6A\x66\x78\xE1\x13\x9D\x26\xB7\x81\x9F\x7E\x90'),
+ (
+ 'a',
+ b'\xFF\xFF\xFF\xFF\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00'
+ b'\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFC'
+ ),
+ (
+ 'b',
+ b'\x5A\xC6\x35\xD8\xAA\x3A\x93\xE7\xB3\xEB\xBD\x55\x76\x98\x86\xBC'
+ b'\x65\x1D\x06\xB0\xCC\x53\xB0\xF6\x3B\xCE\x3C\x3E\x27\xD2\x60\x4B'
+ ),
+ (
+ 'seed',
+ b'\xC4\x9D\x36\x08\x86\xE7\x04\x93\x6A\x66\x78\xE1\x13\x9D\x26\xB7\x81\x9F\x7E\x90'
+ ),
])
),
(
'base',
- b'\x04\x6B\x17\xD1\xF2\xE1\x2C\x42\x47\xF8\xBC\xE6\xE5\x63\xA4\x40\xF2\x77\x03\x7D\x81\x2D\xEB\x33\xA0\xF4\xA1\x39\x45\xD8\x98\xC2\x96\x4F\xE3\x42\xE2\xFE\x1A\x7F\x9B\x8E\xE7\xEB\x4A\x7C\x0F\x9E\x16\x2B\xCE\x33\x57\x6B\x31\x5E\xCE\xCB\xB6\x40\x68\x37\xBF\x51\xF5'
+ b'\x04\x6B\x17\xD1\xF2\xE1\x2C\x42\x47\xF8\xBC\xE6\xE5\x63\xA4\x40\xF2\x77\x03\x7D'
+ b'\x81\x2D\xEB\x33\xA0\xF4\xA1\x39\x45\xD8\x98\xC2\x96\x4F\xE3\x42\xE2\xFE\x1A\x7F'
+ b'\x9B\x8E\xE7\xEB\x4A\x7C\x0F\x9E\x16\x2B\xCE\x33\x57\x6B\x31\x5E\xCE\xCB\xB6\x40'
+ b'\x68\x37\xBF\x51\xF5'
),
(
'order',
diff --git a/tests/test_ocsp.py b/tests/test_ocsp.py
index 9357b27..c3492c1 100644
--- a/tests/test_ocsp.py
+++ b/tests/test_ocsp.py
@@ -21,7 +21,6 @@
fixtures_dir = os.path.join(tests_root, 'fixtures')
-
class OCSPTests(unittest.TestCase):
def test_parse_request(self):
diff --git a/tests/test_pem.py b/tests/test_pem.py
index 30c94ec..05dcd3d 100644
--- a/tests/test_pem.py
+++ b/tests/test_pem.py
@@ -7,14 +7,14 @@
from asn1crypto import pem, util
-from .unittest_data import DataDecorator, data
+from .unittest_data import data_decorator, data
from ._unittest_compat import patch
patch()
if sys.version_info < (3,):
byte_cls = str
- num_cls = long #pylint: disable=E0602
+ num_cls = long # noqa
else:
byte_cls = bytes
num_cls = int
@@ -24,19 +24,36 @@
fixtures_dir = os.path.join(tests_root, 'fixtures')
-@DataDecorator
+@data_decorator
class PEMTests(unittest.TestCase):
- #pylint: disable=C0326
@staticmethod
def detect_files():
return (
- ('keys/test-der.crt', False),
- ('keys/test-inter-der.crt', False),
- ('keys/test-third-der.crt', False),
- ('keys/test.crt', True),
- ('keys/test-inter.crt', True),
- ('keys/test-third.crt', True),
+ (
+ 'keys/test-der.crt',
+ False
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ False
+ ),
+ (
+ 'keys/test-third-der.crt',
+ False
+ ),
+ (
+ 'keys/test.crt',
+ True
+ ),
+ (
+ 'keys/test-inter.crt',
+ True
+ ),
+ (
+ 'keys/test-third.crt',
+ True
+ ),
)
@data('detect_files')
@@ -45,16 +62,48 @@
byte_string = f.read()
self.assertEqual(is_pem, pem.detect(byte_string))
- #pylint: disable=C0326
@staticmethod
def unarmor_armor_files():
return (
- ('keys/test.crt', 'keys/test-der.crt', 'CERTIFICATE', {}),
- ('keys/test-inter.crt', 'keys/test-inter-der.crt', 'CERTIFICATE', {}),
- ('keys/test-third.crt', 'keys/test-third-der.crt', 'CERTIFICATE', {}),
- ('keys/test-pkcs8.key', 'keys/test-pkcs8-der.key', 'PRIVATE KEY', {}),
- ('test-third.csr', 'test-third-der.csr', 'CERTIFICATE REQUEST', {}),
- ('keys/test-aes128.key', 'keys/test-aes128-der.key', 'RSA PRIVATE KEY', util.OrderedDict([('Proc-Type', '4,ENCRYPTED'), ('DEK-Info', 'AES-128-CBC,01F6EE04516C912788B11BD7377626C2')])),
+ (
+ 'keys/test.crt',
+ 'keys/test-der.crt',
+ 'CERTIFICATE',
+ {}
+ ),
+ (
+ 'keys/test-inter.crt',
+ 'keys/test-inter-der.crt',
+ 'CERTIFICATE',
+ {}
+ ),
+ (
+ 'keys/test-third.crt',
+ 'keys/test-third-der.crt',
+ 'CERTIFICATE',
+ {}
+ ),
+ (
+ 'keys/test-pkcs8.key',
+ 'keys/test-pkcs8-der.key',
+ 'PRIVATE KEY',
+ {}
+ ),
+ (
+ 'test-third.csr',
+ 'test-third-der.csr',
+ 'CERTIFICATE REQUEST',
+ {}
+ ),
+ (
+ 'keys/test-aes128.key',
+ 'keys/test-aes128-der.key',
+ 'RSA PRIVATE KEY',
+ util.OrderedDict([
+ ('Proc-Type', '4,ENCRYPTED'),
+ ('DEK-Info', 'AES-128-CBC,01F6EE04516C912788B11BD7377626C2')
+ ])
+ ),
)
@data('unarmor_armor_files')
diff --git a/tests/test_tsp.py b/tests/test_tsp.py
index a416872..ee6a2e1 100644
--- a/tests/test_tsp.py
+++ b/tests/test_tsp.py
@@ -14,7 +14,6 @@
fixtures_dir = os.path.join(tests_root, 'fixtures')
-
class TSPTests(unittest.TestCase):
def test_parse_request(self):
@@ -229,7 +228,10 @@
'certs',
[
util.OrderedDict([
- ('cert_hash', b'\x22\x3C\xDA\x27\x07\x96\x73\x81\x6B\x60\x8A\x1B\x8C\xB0\xAB\x02\x30\x10\x7F\xCC'),
+ (
+ 'cert_hash',
+ b'\x22\x3C\xDA\x27\x07\x96\x73\x81\x6B\x60\x8A\x1B\x8C\xB0\xAB\x02\x30\x10\x7F\xCC'
+ ),
('issuer_serial', None),
])
]
diff --git a/tests/test_x509.py b/tests/test_x509.py
index 54abff3..4a5586b 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -8,7 +8,7 @@
from asn1crypto import x509, core, pem, util
-from .unittest_data import DataDecorator, data
+from .unittest_data import data_decorator, data
from ._unittest_compat import patch
patch()
@@ -23,7 +23,7 @@
fixtures_dir = os.path.join(tests_root, 'fixtures')
-@DataDecorator
+@data_decorator
class X509Tests(unittest.TestCase):
def _load_cert(self, relative_path):
@@ -33,16 +33,39 @@
_, _, cert_bytes = pem.unarmor(cert_bytes)
return x509.Certificate.load(cert_bytes)
- #pylint: disable=C0326
@staticmethod
def is_valid_domain_ip_info():
return (
- ('geotrust_certs/codex.crt', 'codexns.io', True),
- ('geotrust_certs/codex.crt', 'dev.codexns.io', True),
- ('geotrust_certs/codex.crt', 'rc.codexns.io', True),
- ('geotrust_certs/codex.crt', 'foo.codexns.io', False),
- ('geotrust_certs/codex.crt', '1.2.3.4', False),
- ('geotrust_certs/codex.crt', '1::1', False),
+ (
+ 'geotrust_certs/codex.crt',
+ 'codexns.io',
+ True
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ 'dev.codexns.io',
+ True
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ 'rc.codexns.io',
+ True
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ 'foo.codexns.io',
+ False
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ '1.2.3.4',
+ False
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ '1::1',
+ False
+ ),
)
@data('is_valid_domain_ip_info')
@@ -50,17 +73,39 @@
cert = self._load_cert(cert)
self.assertEqual(result, cert.is_valid_domain_ip(domain_ip))
- #pylint: disable=C0326
@staticmethod
def ip_address_info():
return (
- ('127.0.0.1', b'\x04\x04\x7F\x00\x00\x01'),
- ('255.255.255.255', b'\x04\x04\xFF\xFF\xFF\xFF'),
- ('127.0.0.1/28', b'\x04\x08\x7F\x00\x00\x01\xFF\xFF\xFF\xF0'),
- ('255.255.255.255/0', b'\x04\x08\xFF\xFF\xFF\xFF\x00\x00\x00\x00'),
- ('af::ed', b'\x04\x10\x00\xAF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xED'),
- ('af::ed/128', b'\x04\x20\x00\xAF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xED\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF'),
- ('af::ed/0', b'\x04\x20\x00\xAF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xED\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'),
+ (
+ '127.0.0.1',
+ b'\x04\x04\x7F\x00\x00\x01'
+ ),
+ (
+ '255.255.255.255',
+ b'\x04\x04\xFF\xFF\xFF\xFF'
+ ),
+ (
+ '127.0.0.1/28',
+ b'\x04\x08\x7F\x00\x00\x01\xFF\xFF\xFF\xF0'
+ ),
+ (
+ '255.255.255.255/0',
+ b'\x04\x08\xFF\xFF\xFF\xFF\x00\x00\x00\x00'
+ ),
+ (
+ 'af::ed',
+ b'\x04\x10\x00\xAF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xED'
+ ),
+ (
+ 'af::ed/128',
+ b'\x04\x20\x00\xAF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+ b'\xED\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF'
+ ),
+ (
+ 'af::ed/0',
+ b'\x04\x20\x00\xAF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+ b'\xED\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+ ),
)
@data('ip_address_info')
@@ -68,15 +113,34 @@
self.assertEqual(der_bytes, x509.IPAddress(unicode_string).dump())
self.assertEqual(unicode_string, x509.IPAddress.load(der_bytes).native)
- #pylint: disable=C0326
@staticmethod
def compare_dnsname_info():
return (
- ('google.com', 'google.com', True),
- ('google.com', 'Google.com', True),
- ('Bücher.ch', b'\x16\x10xn--bcher-kva.ch', True),
- ('google.com', b'\x16\x0AGoogle.com', True),
- ('google.com', b'\x16\x09Google.co', False),
+ (
+ 'google.com',
+ 'google.com',
+ True
+ ),
+ (
+ 'google.com',
+ 'Google.com',
+ True
+ ),
+ (
+ 'Bücher.ch',
+ b'\x16\x10xn--bcher-kva.ch',
+ True
+ ),
+ (
+ 'google.com',
+ b'\x16\x0AGoogle.com',
+ True
+ ),
+ (
+ 'google.com',
+ b'\x16\x09Google.co',
+ False
+ ),
)
@data('compare_dnsname_info')
@@ -91,17 +155,44 @@
else:
self.assertNotEqual(one, two)
- #pylint: disable=C0326
@staticmethod
def compare_uri_info():
return (
- ('http://google.com', 'http://google.com', True),
- ('http://google.com/', 'http://Google.com', True),
- ('http://google.com:80', 'http://google.com', True),
- ('https://google.com', 'https://google.com:443/', True),
- ('http://google.com/%41%42%43', 'http://google.com/ABC', True),
- ('http://google.com/%41%42%43', 'http://google.com/abc', False),
- ('http://google.com/%41%42%43/', 'http://google.com/ABC%2F', False),
+ (
+ 'http://google.com',
+ 'http://google.com',
+ True
+ ),
+ (
+ 'http://google.com/',
+ 'http://Google.com',
+ True
+ ),
+ (
+ 'http://google.com:80',
+ 'http://google.com',
+ True
+ ),
+ (
+ 'https://google.com',
+ 'https://google.com:443/',
+ True
+ ),
+ (
+ 'http://google.com/%41%42%43',
+ 'http://google.com/ABC',
+ True
+ ),
+ (
+ 'http://google.com/%41%42%43',
+ 'http://google.com/abc',
+ False
+ ),
+ (
+ 'http://google.com/%41%42%43/',
+ 'http://google.com/ABC%2F',
+ False
+ ),
)
@data('compare_uri_info')
@@ -116,18 +207,49 @@
else:
self.assertNotEqual(one, two)
- #pylint: disable=C0326
@staticmethod
def compare_email_address_info():
return (
- ('[email protected]', '[email protected]', True),
- ('[email protected]', '[email protected]', True),
- ('[email protected]', '[email protected]', False),
- ('john@Bücher.ch', b'\x16\[email protected]', True),
- ('John@Bücher.ch', b'\x16\[email protected]', False),
- ('[email protected]', b'\x16\[email protected]', True),
- ('[email protected]', b'\x16\[email protected]', False),
- ('[email protected]', b'\x16\[email protected]', False),
+ (
+ '[email protected]',
+ '[email protected]',
+ True
+ ),
+ (
+ '[email protected]',
+ '[email protected]',
+ True
+ ),
+ (
+ '[email protected]',
+ '[email protected]',
+ False
+ ),
+ (
+ 'john@Bücher.ch',
+ b'\x16\[email protected]',
+ True
+ ),
+ (
+ 'John@Bücher.ch',
+ b'\x16\[email protected]',
+ False
+ ),
+ (
+ '[email protected]',
+ b'\x16\[email protected]',
+ True
+ ),
+ (
+ '[email protected]',
+ b'\x16\[email protected]',
+ False
+ ),
+ (
+ '[email protected]',
+ b'\x16\[email protected]',
+ False
+ ),
)
@data('compare_email_address_info')
@@ -142,15 +264,34 @@
else:
self.assertNotEqual(one, two)
- #pylint: disable=C0326
@staticmethod
def compare_ip_address_info():
return (
- ('127.0.0.1', '127.0.0.1', True),
- ('127.0.0.1', '127.0.0.2', False),
- ('127.0.0.1', '127.0.0.1/32', False),
- ('127.0.0.1/32', b'\x04\x08\x7F\x00\x00\x01\xFF\xFF\xFF\xFF', True),
- ('127.0.0.1', b'\x04\x08\x7F\x00\x00\x01\xFF\xFF\xFF\xFF', False),
+ (
+ '127.0.0.1',
+ '127.0.0.1',
+ True
+ ),
+ (
+ '127.0.0.1',
+ '127.0.0.2',
+ False
+ ),
+ (
+ '127.0.0.1',
+ '127.0.0.1/32',
+ False
+ ),
+ (
+ '127.0.0.1/32',
+ b'\x04\x08\x7F\x00\x00\x01\xFF\xFF\xFF\xFF',
+ True
+ ),
+ (
+ '127.0.0.1',
+ b'\x04\x08\x7F\x00\x00\x01\xFF\xFF\xFF\xFF',
+ False
+ ),
)
@data('compare_ip_address_info')
@@ -165,7 +306,6 @@
else:
self.assertNotEqual(one, two)
- #pylint: disable=C0326
@staticmethod
def compare_name_info():
return (
@@ -217,15 +357,34 @@
else:
self.assertNotEqual(general_name_1, general_name_2)
- #pylint: disable=C0326
@staticmethod
def signature_algo_info():
return (
- ('keys/test-der.crt', 'rsassa_pkcs1v15', 'sha256'),
- ('keys/test-inter-der.crt', 'rsassa_pkcs1v15', 'sha256'),
- ('keys/test-dsa-der.crt', 'dsa', 'sha256'),
- ('keys/test-third-der.crt', 'rsassa_pkcs1v15', 'sha256'),
- ('keys/test-ec-der.crt', 'ecdsa', 'sha256'),
+ (
+ 'keys/test-der.crt',
+ 'rsassa_pkcs1v15',
+ 'sha256'
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ 'rsassa_pkcs1v15',
+ 'sha256'
+ ),
+ (
+ 'keys/test-dsa-der.crt',
+ 'dsa',
+ 'sha256'
+ ),
+ (
+ 'keys/test-third-der.crt',
+ 'rsassa_pkcs1v15',
+ 'sha256'
+ ),
+ (
+ 'keys/test-ec-der.crt',
+ 'ecdsa',
+ 'sha256'
+ ),
)
@data('signature_algo_info')
@@ -234,25 +393,69 @@
self.assertEqual(signature_algo, cert['signature_algorithm'].signature_algo)
self.assertEqual(hash_algo, cert['signature_algorithm'].hash_algo)
- #pylint: disable=C0326
@staticmethod
def critical_extensions_info():
return (
- ('keys/test-der.crt', set()),
- ('keys/test-inter-der.crt', set()),
- ('keys/test-third-der.crt', set()),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', set(['basic_constraints', 'key_usage'])),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', set(['basic_constraints', 'key_usage'])),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', set(['basic_constraints', 'key_usage'])),
- ('geotrust_certs/codex.crt', set(['key_usage'])),
- ('lets_encrypt/isrgrootx1.pem', set(['key_usage', 'basic_constraints'])),
- ('lets_encrypt/letsencryptauthorityx1.pem', set(['key_usage', 'basic_constraints'])),
- ('lets_encrypt/letsencryptauthorityx2.pem', set(['key_usage', 'basic_constraints'])),
- ('globalsign_example_keys/IssuingCA-der.cer', set(['basic_constraints', 'key_usage'])),
- ('globalsign_example_keys/rootCA.cer', set(['basic_constraints', 'key_usage'])),
- ('globalsign_example_keys/SSL1.cer', set(['key_usage', 'extended_key_usage', 'basic_constraints'])),
- ('globalsign_example_keys/SSL2.cer', set(['key_usage', 'extended_key_usage', 'basic_constraints'])),
- ('globalsign_example_keys/SSL3.cer', set(['key_usage', 'extended_key_usage', 'basic_constraints'])),
+ (
+ 'keys/test-der.crt',
+ set()
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ set()
+ ),
+ (
+ 'keys/test-third-der.crt',
+ set()
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ set(['basic_constraints', 'key_usage'])
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ set(['basic_constraints', 'key_usage'])
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ set(['basic_constraints', 'key_usage'])
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ set(['key_usage'])
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ set(['key_usage', 'basic_constraints'])
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ set(['key_usage', 'basic_constraints'])
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ set(['key_usage', 'basic_constraints'])
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ set(['basic_constraints', 'key_usage'])
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ set(['basic_constraints', 'key_usage'])
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ set(['key_usage', 'extended_key_usage', 'basic_constraints'])
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ set(['key_usage', 'extended_key_usage', 'basic_constraints'])
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ set(['key_usage', 'extended_key_usage', 'basic_constraints'])
+ ),
)
@data('critical_extensions_info')
@@ -260,25 +463,69 @@
cert = self._load_cert(relative_path)
self.assertEqual(critical_extensions, cert.critical_extensions)
- #pylint: disable=C0326
@staticmethod
def key_identifier_value_info():
return (
- ('keys/test-der.crt', b'\xbeB\x85=\xcc\xff\xe3\xf9(\x02\x8f~XV\xb4\xfd\x03\\\xeaK'),
- ('keys/test-inter-der.crt', b'\xd2\n\xfd.%\xd1\xb7!\xd7P~\xbb\xa4}\xbf4\xefR^\x02'),
- ('keys/test-third-der.crt', b'D8\xe0\xe0&\x85\xbf\x98\x86\xdc\x1b\xe1\x1d\xf520\xbe\xab\xac\r'),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', b'\xda\xbb.\xaa\xb0\x0c\xb8\x88&Qt\\m\x03\xd3\xc0\xd8\x8fz\xd6'),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', b',\xd5PA\x97\x15\x8b\xf0\x8f6a[J\xfbk\xd9\x99\xc93\x92'),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', b'\xde\xcf\\P\xb7\xae\x02\x1f\x15\x17\xaa\x16\xe8\r\xb5(\x9djZ\xf3'),
- ('geotrust_certs/codex.crt', None),
- ('lets_encrypt/isrgrootx1.pem', b'y\xb4Y\xe6{\xb6\xe5\xe4\x01s\x80\x08\x88\xc8\x1aX\xf6\xe9\x9bn'),
- ('lets_encrypt/letsencryptauthorityx1.pem', b'\xa8Jjc\x04}\xdd\xba\xe6\xd19\xb7\xa6Ee\xef\xf3\xa8\xec\xa1'),
- ('lets_encrypt/letsencryptauthorityx2.pem', b'\xc5\xb1\xabNL\xb1\xcdd0\x93~\xc1\x84\x99\x05\xab\xe6\x03\xe2%'),
- ('globalsign_example_keys/IssuingCA-der.cer', b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"),
- ('globalsign_example_keys/rootCA.cer', b'd|\\\xe1\xe0`8NH\x9f\x05\xbcUc~?\xaeM\xf7\x1e'),
- ('globalsign_example_keys/SSL1.cer', b'\x94a\x04\x92\x04L\xe6\xffh\xa8\x96\xafy\xd2\xf32\x84\xae[\xcf'),
- ('globalsign_example_keys/SSL2.cer', b'\xd2\xb7\x15\x7fd0\x07(p\x83\xca(\xfa\x88\x96\xde\x9e\xfc\x8a='),
- ('globalsign_example_keys/SSL3.cer', b'G\xde\xa4\xe7\xea`\xe7\xee6\xc8\xf1\xd5\xb0F\x07\x07\x9eBh\xce'),
+ (
+ 'keys/test-der.crt',
+ b'\xbeB\x85=\xcc\xff\xe3\xf9(\x02\x8f~XV\xb4\xfd\x03\\\xeaK'
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ b'\xd2\n\xfd.%\xd1\xb7!\xd7P~\xbb\xa4}\xbf4\xefR^\x02'
+ ),
+ (
+ 'keys/test-third-der.crt',
+ b'D8\xe0\xe0&\x85\xbf\x98\x86\xdc\x1b\xe1\x1d\xf520\xbe\xab\xac\r'
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ b'\xda\xbb.\xaa\xb0\x0c\xb8\x88&Qt\\m\x03\xd3\xc0\xd8\x8fz\xd6'
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ b',\xd5PA\x97\x15\x8b\xf0\x8f6a[J\xfbk\xd9\x99\xc93\x92'
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ b'\xde\xcf\\P\xb7\xae\x02\x1f\x15\x17\xaa\x16\xe8\r\xb5(\x9djZ\xf3'
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ None
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ b'y\xb4Y\xe6{\xb6\xe5\xe4\x01s\x80\x08\x88\xc8\x1aX\xf6\xe9\x9bn'
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ b'\xa8Jjc\x04}\xdd\xba\xe6\xd19\xb7\xa6Ee\xef\xf3\xa8\xec\xa1'
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ b'\xc5\xb1\xabNL\xb1\xcdd0\x93~\xc1\x84\x99\x05\xab\xe6\x03\xe2%'
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ b'd|\\\xe1\xe0`8NH\x9f\x05\xbcUc~?\xaeM\xf7\x1e'
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ b'\x94a\x04\x92\x04L\xe6\xffh\xa8\x96\xafy\xd2\xf32\x84\xae[\xcf'
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ b'\xd2\xb7\x15\x7fd0\x07(p\x83\xca(\xfa\x88\x96\xde\x9e\xfc\x8a='
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ b'G\xde\xa4\xe7\xea`\xe7\xee6\xc8\xf1\xd5\xb0F\x07\x07\x9eBh\xce'
+ ),
)
@data('key_identifier_value_info')
@@ -287,13 +534,21 @@
value = cert.key_identifier_value
self.assertEqual(key_identifier_value, value.native if value else None)
- #pylint: disable=C0326
@staticmethod
def key_usage_value_info():
return (
- ('keys/test-der.crt', None),
- ('keys/test-inter-der.crt', None),
- ('keys/test-third-der.crt', None),
+ (
+ 'keys/test-der.crt',
+ None
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ None
+ ),
+ (
+ 'keys/test-third-der.crt',
+ None
+ ),
(
'geotrust_certs/GeoTrust_Universal_CA.crt',
set(['digital_signature', 'key_cert_sign', 'crl_sign'])
@@ -350,25 +605,73 @@
value = cert.key_usage_value
self.assertEqual(key_usage_value, value.native if value else None)
- #pylint: disable=C0326
@staticmethod
def subject_alt_name_value_info():
return (
- ('keys/test-der.crt', None),
- ('keys/test-inter-der.crt', None),
- ('keys/test-third-der.crt', None),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', None),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', None),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', [util.OrderedDict([('common_name', 'SymantecPKI-1-538')])]),
- ('geotrust_certs/codex.crt', ['dev.codexns.io', 'rc.codexns.io', 'packagecontrol.io', 'wbond.net', 'codexns.io']),
- ('lets_encrypt/isrgrootx1.pem', None),
- ('lets_encrypt/letsencryptauthorityx1.pem', None),
- ('lets_encrypt/letsencryptauthorityx2.pem', None),
- ('globalsign_example_keys/IssuingCA-der.cer', None),
- ('globalsign_example_keys/rootCA.cer', None),
- ('globalsign_example_keys/SSL1.cer', ['anything.example.com']),
- ('globalsign_example_keys/SSL2.cer', ['anything.example.com']),
- ('globalsign_example_keys/SSL3.cer', None),
+ (
+ 'keys/test-der.crt',
+ None
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ None
+ ),
+ (
+ 'keys/test-third-der.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ [
+ util.OrderedDict([
+ ('common_name', 'SymantecPKI-1-538')
+ ])
+ ]
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ ['dev.codexns.io', 'rc.codexns.io', 'packagecontrol.io', 'wbond.net', 'codexns.io']
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ None
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ None
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ None
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ ['anything.example.com']
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ ['anything.example.com']
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ None
+ ),
)
@data('subject_alt_name_value_info')
@@ -377,25 +680,69 @@
value = cert.subject_alt_name_value
self.assertEqual(subject_alt_name_value, value.native if value else None)
- #pylint: disable=C0326
@staticmethod
def basic_constraints_value_info():
return (
- ('keys/test-der.crt', {'ca': True, 'path_len_constraint': None}),
- ('keys/test-inter-der.crt', {'ca': True, 'path_len_constraint': None}),
- ('keys/test-third-der.crt', None),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', {'ca': True, 'path_len_constraint': None}),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', {'ca': True, 'path_len_constraint': None}),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', {'ca': True, 'path_len_constraint': 0}),
- ('geotrust_certs/codex.crt', {'ca': False, 'path_len_constraint': None}),
- ('lets_encrypt/isrgrootx1.pem', {'ca': True, 'path_len_constraint': None}),
- ('lets_encrypt/letsencryptauthorityx1.pem', {'ca': True, 'path_len_constraint': 0}),
- ('lets_encrypt/letsencryptauthorityx2.pem', {'ca': True, 'path_len_constraint': 0}),
- ('globalsign_example_keys/IssuingCA-der.cer', {'ca': True, 'path_len_constraint': None}),
- ('globalsign_example_keys/rootCA.cer', {'ca': True, 'path_len_constraint': None}),
- ('globalsign_example_keys/SSL1.cer', {'ca': False, 'path_len_constraint': None}),
- ('globalsign_example_keys/SSL2.cer', {'ca': False, 'path_len_constraint': None}),
- ('globalsign_example_keys/SSL3.cer', {'ca': False, 'path_len_constraint': None}),
+ (
+ 'keys/test-der.crt',
+ {'ca': True, 'path_len_constraint': None}
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ {'ca': True, 'path_len_constraint': None}
+ ),
+ (
+ 'keys/test-third-der.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ {'ca': True, 'path_len_constraint': None}
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ {'ca': True, 'path_len_constraint': None}
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ {'ca': True, 'path_len_constraint': 0}
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ {'ca': False, 'path_len_constraint': None}
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ {'ca': True, 'path_len_constraint': None}
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ {'ca': True, 'path_len_constraint': 0}
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ {'ca': True, 'path_len_constraint': 0}
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ {'ca': True, 'path_len_constraint': None}
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ {'ca': True, 'path_len_constraint': None}
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ {'ca': False, 'path_len_constraint': None}
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ {'ca': False, 'path_len_constraint': None}
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ {'ca': False, 'path_len_constraint': None}
+ ),
)
@data('basic_constraints_value_info')
@@ -404,20 +751,49 @@
value = cert.basic_constraints_value
self.assertEqual(basic_constraints_value, value.native if value else None)
- #pylint: disable=C0326
@staticmethod
def name_constraints_value_info():
return (
- ('keys/test-der.crt', None),
- ('keys/test-inter-der.crt', None),
- ('keys/test-third-der.crt', None),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', None),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', None),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', None),
- ('geotrust_certs/codex.crt', None),
- ('lets_encrypt/isrgrootx1.pem', None),
- ('lets_encrypt/letsencryptauthorityx1.pem', None),
- ('lets_encrypt/letsencryptauthorityx2.pem', None),
+ (
+ 'keys/test-der.crt',
+ None
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ None
+ ),
+ (
+ 'keys/test-third-der.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ None
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ None
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ None
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ None
+ ),
(
'globalsign_example_keys/IssuingCA-der.cer',
util.OrderedDict([
@@ -461,10 +837,22 @@
),
])
),
- ('globalsign_example_keys/rootCA.cer', None),
- ('globalsign_example_keys/SSL1.cer', None),
- ('globalsign_example_keys/SSL2.cer', None),
- ('globalsign_example_keys/SSL3.cer', None),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ None
+ ),
)
@data('name_constraints_value_info')
@@ -473,15 +861,29 @@
value = cert.name_constraints_value
self.assertEqual(name_constraints_value, value.native if value else None)
- #pylint: disable=C0326
@staticmethod
def crl_distribution_points_value_info():
return (
- ('keys/test-der.crt', None),
- ('keys/test-inter-der.crt', None),
- ('keys/test-third-der.crt', None),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', None),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', None),
+ (
+ 'keys/test-der.crt',
+ None
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ None
+ ),
+ (
+ 'keys/test-third-der.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ None
+ ),
(
'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
[
@@ -502,7 +904,10 @@
])
]
),
- ('lets_encrypt/isrgrootx1.pem', None),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ None
+ ),
(
'lets_encrypt/letsencryptauthorityx1.pem',
[
@@ -541,9 +946,18 @@
('crl_issuer', None)
])
]),
- ('globalsign_example_keys/SSL1.cer', None),
- ('globalsign_example_keys/SSL2.cer', None),
- ('globalsign_example_keys/SSL3.cer', None),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ None
+ ),
)
@data('crl_distribution_points_value_info')
@@ -552,15 +966,29 @@
value = cert.crl_distribution_points_value
self.assertEqual(crl_distribution_points_value, value.native if value else None)
- #pylint: disable=C0326
@staticmethod
def certificate_policies_value_info():
return (
- ('keys/test-der.crt', None),
- ('keys/test-inter-der.crt', None),
- ('keys/test-third-der.crt', None),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', None),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', None),
+ (
+ 'keys/test-der.crt',
+ None
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ None
+ ),
+ (
+ 'keys/test-third-der.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ None
+ ),
(
'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
[
@@ -605,7 +1033,10 @@
])
]
),
- ('lets_encrypt/isrgrootx1.pem', None),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ None
+ ),
(
'lets_encrypt/letsencryptauthorityx1.pem',
[
@@ -665,7 +1096,10 @@
])
]
),
- ('globalsign_example_keys/rootCA.cer', None),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ None
+ ),
(
'globalsign_example_keys/SSL1.cer',
[
@@ -725,25 +1159,69 @@
value = cert.certificate_policies_value
self.assertEqual(certificate_policies_value, value.native if value else None)
- #pylint: disable=C0326
@staticmethod
def policy_mappings_value_info():
return (
- ('keys/test-der.crt', None),
- ('keys/test-inter-der.crt', None),
- ('keys/test-third-der.crt', None),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', None),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', None),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', None),
- ('geotrust_certs/codex.crt', None),
- ('lets_encrypt/isrgrootx1.pem', None),
- ('lets_encrypt/letsencryptauthorityx1.pem', None),
- ('lets_encrypt/letsencryptauthorityx2.pem', None),
- ('globalsign_example_keys/IssuingCA-der.cer', None),
- ('globalsign_example_keys/rootCA.cer', None),
- ('globalsign_example_keys/SSL1.cer', None),
- ('globalsign_example_keys/SSL2.cer', None),
- ('globalsign_example_keys/SSL3.cer', None),
+ (
+ 'keys/test-der.crt',
+ None
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ None
+ ),
+ (
+ 'keys/test-third-der.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ None
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ None
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ None
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ None
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ None
+ ),
)
@data('policy_mappings_value_info')
@@ -752,7 +1230,6 @@
value = cert.policy_mappings_value
self.assertEqual(policy_mappings_value, value.native if value else None)
- #pylint: disable=C0326
@staticmethod
def authority_key_identifier_value_info():
return (
@@ -885,25 +1362,69 @@
value = cert.authority_key_identifier_value
self.assertEqual(authority_key_identifier_value, value.native if value else None)
- #pylint: disable=C0326
@staticmethod
def policy_constraints_value_info():
return (
- ('keys/test-der.crt', None),
- ('keys/test-inter-der.crt', None),
- ('keys/test-third-der.crt', None),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', None),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', None),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', None),
- ('geotrust_certs/codex.crt', None),
- ('lets_encrypt/isrgrootx1.pem', None),
- ('lets_encrypt/letsencryptauthorityx1.pem', None),
- ('lets_encrypt/letsencryptauthorityx2.pem', None),
- ('globalsign_example_keys/IssuingCA-der.cer', None),
- ('globalsign_example_keys/rootCA.cer', None),
- ('globalsign_example_keys/SSL1.cer', None),
- ('globalsign_example_keys/SSL2.cer', None),
- ('globalsign_example_keys/SSL3.cer', None),
+ (
+ 'keys/test-der.crt',
+ None
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ None
+ ),
+ (
+ 'keys/test-third-der.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ None
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ None
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ None
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ None
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ None
+ ),
)
@data('policy_constraints_value_info')
@@ -912,25 +1433,68 @@
value = cert.policy_constraints_value
self.assertEqual(policy_constraints_value, value.native if value else None)
- #pylint: disable=C0326
@staticmethod
def extended_key_usage_value_info():
return (
- ('keys/test-der.crt', None),
- ('keys/test-inter-der.crt', None),
- ('keys/test-third-der.crt', None),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', None),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', None),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', None),
- ('geotrust_certs/codex.crt', ['server_auth', 'client_auth']),
- ('lets_encrypt/isrgrootx1.pem', None),
- ('lets_encrypt/letsencryptauthorityx1.pem', None),
- ('lets_encrypt/letsencryptauthorityx2.pem', None),
- ('globalsign_example_keys/IssuingCA-der.cer', None),
- ('globalsign_example_keys/rootCA.cer', None),
- ('globalsign_example_keys/SSL1.cer', ['server_auth', 'client_auth']),
- ('globalsign_example_keys/SSL2.cer', ['server_auth', 'client_auth']),
- ('globalsign_example_keys/SSL3.cer', ['server_auth', 'client_auth']),
+ (
+ 'keys/test-der.crt',
+ None
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ None
+ ),
+ (
+ 'keys/test-third-der.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ ['server_auth', 'client_auth']),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ None
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ None
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ None
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ ['server_auth', 'client_auth']
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ ['server_auth', 'client_auth']
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ ['server_auth', 'client_auth']
+ ),
)
@data('extended_key_usage_value_info')
@@ -939,15 +1503,29 @@
value = cert.extended_key_usage_value
self.assertEqual(extended_key_usage_value, value.native if value else None)
- #pylint: disable=C0326
@staticmethod
def authority_information_access_value_info():
return (
- ('keys/test-der.crt', None),
- ('keys/test-inter-der.crt', None),
- ('keys/test-third-der.crt', None),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', None),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', None),
+ (
+ 'keys/test-der.crt',
+ None
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ None
+ ),
+ (
+ 'keys/test-third-der.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ None
+ ),
(
'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
[
@@ -970,7 +1548,10 @@
]),
]
),
- ('lets_encrypt/isrgrootx1.pem', None),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ None
+ ),
(
'lets_encrypt/letsencryptauthorityx1.pem',
[
@@ -997,8 +1578,14 @@
])
]
),
- ('globalsign_example_keys/IssuingCA-der.cer', None),
- ('globalsign_example_keys/rootCA.cer', None),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ None
+ ),
(
'globalsign_example_keys/SSL1.cer',
[
@@ -1046,25 +1633,69 @@
value = cert.authority_information_access_value
self.assertEqual(authority_information_access_value, value.native if value else None)
- #pylint: disable=C0326
@staticmethod
def ocsp_no_check_value_info():
return (
- ('keys/test-der.crt', None),
- ('keys/test-inter-der.crt', None),
- ('keys/test-third-der.crt', None),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', None),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', None),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', None),
- ('geotrust_certs/codex.crt', None),
- ('lets_encrypt/isrgrootx1.pem', None),
- ('lets_encrypt/letsencryptauthorityx1.pem', None),
- ('lets_encrypt/letsencryptauthorityx2.pem', None),
- ('globalsign_example_keys/IssuingCA-der.cer', None),
- ('globalsign_example_keys/rootCA.cer', None),
- ('globalsign_example_keys/SSL1.cer', None),
- ('globalsign_example_keys/SSL2.cer', None),
- ('globalsign_example_keys/SSL3.cer', None),
+ (
+ 'keys/test-der.crt',
+ None
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ None
+ ),
+ (
+ 'keys/test-third-der.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ None
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ None
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ None
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ None
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ None
+ ),
)
@data('ocsp_no_check_value_info')
@@ -1073,25 +1704,69 @@
value = cert.ocsp_no_check_value
self.assertEqual(ocsp_no_check_value, value.native if value else None)
- #pylint: disable=C0326
@staticmethod
def serial_number_info():
return (
- ('keys/test-der.crt', 13683582341504654466),
- ('keys/test-inter-der.crt', 1590137),
- ('keys/test-third-der.crt', 2474902313),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', 1),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', 32798226551256963324313806436981982369),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', 146934555852773531829332059263122711876),
- ('geotrust_certs/codex.crt', 130338219198307073574879940486642352162),
- ('lets_encrypt/isrgrootx1.pem', 172886928669790476064670243504169061120),
- ('lets_encrypt/letsencryptauthorityx1.pem', 307817870430047279283060309415759825539),
- ('lets_encrypt/letsencryptauthorityx2.pem', 199666138109676817050168330923544141416),
- ('globalsign_example_keys/IssuingCA-der.cer', 43543335419752),
- ('globalsign_example_keys/rootCA.cer', 342514332211132),
- ('globalsign_example_keys/SSL1.cer', 425155524522),
- ('globalsign_example_keys/SSL2.cer', 425155524522),
- ('globalsign_example_keys/SSL3.cer', 425155524522),
+ (
+ 'keys/test-der.crt',
+ 13683582341504654466
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ 1590137
+ ),
+ (
+ 'keys/test-third-der.crt',
+ 2474902313
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ 1
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ 32798226551256963324313806436981982369
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ 146934555852773531829332059263122711876
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ 130338219198307073574879940486642352162
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ 172886928669790476064670243504169061120
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ 307817870430047279283060309415759825539
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ 199666138109676817050168330923544141416
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ 43543335419752
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ 342514332211132
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ 425155524522
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ 425155524522
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ 425155524522
+ ),
)
@data('serial_number_info')
@@ -1099,25 +1774,69 @@
cert = self._load_cert(relative_path)
self.assertEqual(serial_number, cert.serial_number)
- #pylint: disable=C0326
@staticmethod
def key_identifier_info():
return (
- ('keys/test-der.crt', b'\xbeB\x85=\xcc\xff\xe3\xf9(\x02\x8f~XV\xb4\xfd\x03\\\xeaK'),
- ('keys/test-inter-der.crt', b'\xd2\n\xfd.%\xd1\xb7!\xd7P~\xbb\xa4}\xbf4\xefR^\x02'),
- ('keys/test-third-der.crt', b'D8\xe0\xe0&\x85\xbf\x98\x86\xdc\x1b\xe1\x1d\xf520\xbe\xab\xac\r'),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', b'\xda\xbb.\xaa\xb0\x0c\xb8\x88&Qt\\m\x03\xd3\xc0\xd8\x8fz\xd6'),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', b',\xd5PA\x97\x15\x8b\xf0\x8f6a[J\xfbk\xd9\x99\xc93\x92'),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', b'\xde\xcf\\P\xb7\xae\x02\x1f\x15\x17\xaa\x16\xe8\r\xb5(\x9djZ\xf3'),
- ('geotrust_certs/codex.crt', None),
- ('lets_encrypt/isrgrootx1.pem', b'y\xb4Y\xe6{\xb6\xe5\xe4\x01s\x80\x08\x88\xc8\x1aX\xf6\xe9\x9bn'),
- ('lets_encrypt/letsencryptauthorityx1.pem', b'\xa8Jjc\x04}\xdd\xba\xe6\xd19\xb7\xa6Ee\xef\xf3\xa8\xec\xa1'),
- ('lets_encrypt/letsencryptauthorityx2.pem', b'\xc5\xb1\xabNL\xb1\xcdd0\x93~\xc1\x84\x99\x05\xab\xe6\x03\xe2%'),
- ('globalsign_example_keys/IssuingCA-der.cer', b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"),
- ('globalsign_example_keys/rootCA.cer', b'd|\\\xe1\xe0`8NH\x9f\x05\xbcUc~?\xaeM\xf7\x1e'),
- ('globalsign_example_keys/SSL1.cer', b'\x94a\x04\x92\x04L\xe6\xffh\xa8\x96\xafy\xd2\xf32\x84\xae[\xcf'),
- ('globalsign_example_keys/SSL2.cer', b'\xd2\xb7\x15\x7fd0\x07(p\x83\xca(\xfa\x88\x96\xde\x9e\xfc\x8a='),
- ('globalsign_example_keys/SSL3.cer', b'G\xde\xa4\xe7\xea`\xe7\xee6\xc8\xf1\xd5\xb0F\x07\x07\x9eBh\xce'),
+ (
+ 'keys/test-der.crt',
+ b'\xbeB\x85=\xcc\xff\xe3\xf9(\x02\x8f~XV\xb4\xfd\x03\\\xeaK'
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ b'\xd2\n\xfd.%\xd1\xb7!\xd7P~\xbb\xa4}\xbf4\xefR^\x02'
+ ),
+ (
+ 'keys/test-third-der.crt',
+ b'D8\xe0\xe0&\x85\xbf\x98\x86\xdc\x1b\xe1\x1d\xf520\xbe\xab\xac\r'
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ b'\xda\xbb.\xaa\xb0\x0c\xb8\x88&Qt\\m\x03\xd3\xc0\xd8\x8fz\xd6'
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ b',\xd5PA\x97\x15\x8b\xf0\x8f6a[J\xfbk\xd9\x99\xc93\x92'
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ b'\xde\xcf\\P\xb7\xae\x02\x1f\x15\x17\xaa\x16\xe8\r\xb5(\x9djZ\xf3'
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ None
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ b'y\xb4Y\xe6{\xb6\xe5\xe4\x01s\x80\x08\x88\xc8\x1aX\xf6\xe9\x9bn'
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ b'\xa8Jjc\x04}\xdd\xba\xe6\xd19\xb7\xa6Ee\xef\xf3\xa8\xec\xa1'
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ b'\xc5\xb1\xabNL\xb1\xcdd0\x93~\xc1\x84\x99\x05\xab\xe6\x03\xe2%'
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ b'd|\\\xe1\xe0`8NH\x9f\x05\xbcUc~?\xaeM\xf7\x1e'
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ b'\x94a\x04\x92\x04L\xe6\xffh\xa8\x96\xafy\xd2\xf32\x84\xae[\xcf'
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ b'\xd2\xb7\x15\x7fd0\x07(p\x83\xca(\xfa\x88\x96\xde\x9e\xfc\x8a='
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ b'G\xde\xa4\xe7\xea`\xe7\xee6\xc8\xf1\xd5\xb0F\x07\x07\x9eBh\xce'
+ ),
)
@data('key_identifier_info')
@@ -1125,25 +1844,83 @@
cert = self._load_cert(relative_path)
self.assertEqual(key_identifier, cert.key_identifier)
- #pylint: disable=C0326
@staticmethod
def issuer_serial_info():
return (
- ('keys/test-der.crt', b'\xdd\x8a\x19x\xae`\x19=\xa7\xf8\x00\xb9\xfbx\xf8\xedu\xb8!\xf8\x8c\xdb\x1f\x99\'7w\x93\xb4\xa4\'\xa0:13683582341504654466'),
- ('keys/test-inter-der.crt', b'\xdd\x8a\x19x\xae`\x19=\xa7\xf8\x00\xb9\xfbx\xf8\xedu\xb8!\xf8\x8c\xdb\x1f\x99\'7w\x93\xb4\xa4\'\xa0:1590137'),
- ('keys/test-third-der.crt', b'\xed{\x9b\xbf\x9b\xdbd\xa4\xea\xf2#+H\x96\xcd\x80\x99\xf6\xecCM\x94\x07\x02\xe2\x18\xf3\x83\x8c8%\x01:2474902313'),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', b'\xa1\x848\xf2\xe5w\xee\xec\xce\xfefJC+\xdf\x97\x7f\xd2Y\xe3\xdc\xa0D7~\x07\xd9\x9dzL@g:1'),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', b'\xdcg\x0c\x80\x03\xb3D\xa0v\xe2\xee\xec\x8b\xd6\x82\x01\xf0\x13\x0cwT\xb4\x8f\x80\x0eT\x9d\xbf\xbf\xa4\x11\x80:32798226551256963324313806436981982369'),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', b'\xdcg\x0c\x80\x03\xb3D\xa0v\xe2\xee\xec\x8b\xd6\x82\x01\xf0\x13\x0cwT\xb4\x8f\x80\x0eT\x9d\xbf\xbf\xa4\x11\x80:146934555852773531829332059263122711876'),
- ('geotrust_certs/codex.crt', b'x\x12\xe0\x15\x00d;\xc3\xb9/\xf6\x13\n\xd8\xe2\xddY\xf7\xaf*=C\x01<\x86\xf5\x9f_\xab;e\xd1:130338219198307073574879940486642352162'),
- ('lets_encrypt/isrgrootx1.pem', b'\xf6\xdb/\xbd\x9d\xd8]\x92Y\xdd\xb3\xc6\xde}{/\xec?>\x0c\xef\x17a\xbc\xbf3 W\x1e-0\xf8:172886928669790476064670243504169061120'),
- ('lets_encrypt/letsencryptauthorityx1.pem', b'\xf6\xdb/\xbd\x9d\xd8]\x92Y\xdd\xb3\xc6\xde}{/\xec?>\x0c\xef\x17a\xbc\xbf3 W\x1e-0\xf8:307817870430047279283060309415759825539'),
- ('lets_encrypt/letsencryptauthorityx2.pem', b'\xf6\xdb/\xbd\x9d\xd8]\x92Y\xdd\xb3\xc6\xde}{/\xec?>\x0c\xef\x17a\xbc\xbf3 W\x1e-0\xf8:199666138109676817050168330923544141416'),
- ('globalsign_example_keys/IssuingCA-der.cer', b'\xd2\xe7\xca\x10\xc1\x91\x92Y^A\x11\xd3Rz\xd5\x93\x19wk\x11\xef\xaa\x9c\xad\x10\x8ak\x8a\x08-\x0c\xff:43543335419752'),
- ('globalsign_example_keys/rootCA.cer', b'\xd2\xe7\xca\x10\xc1\x91\x92Y^A\x11\xd3Rz\xd5\x93\x19wk\x11\xef\xaa\x9c\xad\x10\x8ak\x8a\x08-\x0c\xff:342514332211132'),
- ('globalsign_example_keys/SSL1.cer', b'_\xc0S\xb1\xeb}\xe3\x8e\xe4{\xdb\xd7\xe2\xd9}=3\x97|\x0c\x1e\xecz\xcc\x92u\x1f\xf0\x1d\xbc\x9f\xe4:425155524522'),
- ('globalsign_example_keys/SSL2.cer', b'_\xc0S\xb1\xeb}\xe3\x8e\xe4{\xdb\xd7\xe2\xd9}=3\x97|\x0c\x1e\xecz\xcc\x92u\x1f\xf0\x1d\xbc\x9f\xe4:425155524522'),
- ('globalsign_example_keys/SSL3.cer', b'_\xc0S\xb1\xeb}\xe3\x8e\xe4{\xdb\xd7\xe2\xd9}=3\x97|\x0c\x1e\xecz\xcc\x92u\x1f\xf0\x1d\xbc\x9f\xe4:425155524522'),
+ (
+ 'keys/test-der.crt',
+ b'\xdd\x8a\x19x\xae`\x19=\xa7\xf8\x00\xb9\xfbx\xf8\xedu\xb8!\xf8\x8c'
+ b'\xdb\x1f\x99\'7w\x93\xb4\xa4\'\xa0:13683582341504654466'
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ b'\xdd\x8a\x19x\xae`\x19=\xa7\xf8\x00\xb9\xfbx\xf8\xedu\xb8!\xf8\x8c'
+ b'\xdb\x1f\x99\'7w\x93\xb4\xa4\'\xa0:1590137'
+ ),
+ (
+ 'keys/test-third-der.crt',
+ b'\xed{\x9b\xbf\x9b\xdbd\xa4\xea\xf2#+H\x96\xcd\x80\x99\xf6\xecCM\x94'
+ b'\x07\x02\xe2\x18\xf3\x83\x8c8%\x01:2474902313'
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ b'\xa1\x848\xf2\xe5w\xee\xec\xce\xfefJC+\xdf\x97\x7f\xd2Y\xe3\xdc\xa0D7~\x07\xd9\x9dzL@g:1'
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ b'\xdcg\x0c\x80\x03\xb3D\xa0v\xe2\xee\xec\x8b\xd6\x82\x01\xf0\x13\x0cwT'
+ b'\xb4\x8f\x80\x0eT\x9d\xbf\xbf\xa4\x11\x80:32798226551256963324313806436981982369'
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ b'\xdcg\x0c\x80\x03\xb3D\xa0v\xe2\xee\xec\x8b\xd6\x82\x01\xf0\x13\x0cwT'
+ b'\xb4\x8f\x80\x0eT\x9d\xbf\xbf\xa4\x11\x80:146934555852773531829332059263122711876'
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ b'x\x12\xe0\x15\x00d;\xc3\xb9/\xf6\x13\n\xd8\xe2\xddY\xf7\xaf*=C\x01<\x86\xf5\x9f'
+ b'_\xab;e\xd1:130338219198307073574879940486642352162'
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ b'\xf6\xdb/\xbd\x9d\xd8]\x92Y\xdd\xb3\xc6\xde}{/\xec?>\x0c\xef\x17a\xbc\xbf3 W\x1e'
+ b'-0\xf8:172886928669790476064670243504169061120'
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ b'\xf6\xdb/\xbd\x9d\xd8]\x92Y\xdd\xb3\xc6\xde}{/\xec?>\x0c\xef\x17a\xbc\xbf3 W\x1e-'
+ b'0\xf8:307817870430047279283060309415759825539'
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ b'\xf6\xdb/\xbd\x9d\xd8]\x92Y\xdd\xb3\xc6\xde}{/\xec?>\x0c\xef\x17a\xbc\xbf3 W\x1e-'
+ b'0\xf8:199666138109676817050168330923544141416'
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ b'\xd2\xe7\xca\x10\xc1\x91\x92Y^A\x11\xd3Rz\xd5\x93\x19wk\x11\xef\xaa\x9c\xad\x10'
+ b'\x8ak\x8a\x08-\x0c\xff:43543335419752'
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ b'\xd2\xe7\xca\x10\xc1\x91\x92Y^A\x11\xd3Rz\xd5\x93\x19wk\x11\xef\xaa\x9c\xad\x10'
+ b'\x8ak\x8a\x08-\x0c\xff:342514332211132'
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ b'_\xc0S\xb1\xeb}\xe3\x8e\xe4{\xdb\xd7\xe2\xd9}=3\x97|\x0c\x1e\xecz\xcc\x92u\x1f'
+ b'\xf0\x1d\xbc\x9f\xe4:425155524522'
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ b'_\xc0S\xb1\xeb}\xe3\x8e\xe4{\xdb\xd7\xe2\xd9}=3\x97|\x0c\x1e\xecz\xcc\x92u\x1f'
+ b'\xf0\x1d\xbc\x9f\xe4:425155524522'
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ b'_\xc0S\xb1\xeb}\xe3\x8e\xe4{\xdb\xd7\xe2\xd9}=3\x97|\x0c\x1e\xecz\xcc\x92u\x1f'
+ b'\xf0\x1d\xbc\x9f\xe4:425155524522'
+ ),
)
@data('issuer_serial_info')
@@ -1151,25 +1928,69 @@
cert = self._load_cert(relative_path)
self.assertEqual(issuer_serial, cert.issuer_serial)
- #pylint: disable=C0326
@staticmethod
def authority_key_identifier_info():
return (
- ('keys/test-der.crt', b'\xbeB\x85=\xcc\xff\xe3\xf9(\x02\x8f~XV\xb4\xfd\x03\\\xeaK'),
- ('keys/test-inter-der.crt', b'\xbeB\x85=\xcc\xff\xe3\xf9(\x02\x8f~XV\xb4\xfd\x03\\\xeaK'),
- ('keys/test-third-der.crt', b'\xd2\n\xfd.%\xd1\xb7!\xd7P~\xbb\xa4}\xbf4\xefR^\x02'),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', b'\xda\xbb.\xaa\xb0\x0c\xb8\x88&Qt\\m\x03\xd3\xc0\xd8\x8fz\xd6'),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', None),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', b',\xd5PA\x97\x15\x8b\xf0\x8f6a[J\xfbk\xd9\x99\xc93\x92'),
- ('geotrust_certs/codex.crt', b'\xde\xcf\\P\xb7\xae\x02\x1f\x15\x17\xaa\x16\xe8\r\xb5(\x9djZ\xf3'),
- ('lets_encrypt/isrgrootx1.pem', None),
- ('lets_encrypt/letsencryptauthorityx1.pem', b'y\xb4Y\xe6{\xb6\xe5\xe4\x01s\x80\x08\x88\xc8\x1aX\xf6\xe9\x9bn'),
- ('lets_encrypt/letsencryptauthorityx2.pem', b'y\xb4Y\xe6{\xb6\xe5\xe4\x01s\x80\x08\x88\xc8\x1aX\xf6\xe9\x9bn'),
- ('globalsign_example_keys/IssuingCA-der.cer', b'd|\\\xe1\xe0`8NH\x9f\x05\xbcUc~?\xaeM\xf7\x1e'),
- ('globalsign_example_keys/rootCA.cer', None),
- ('globalsign_example_keys/SSL1.cer', b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"),
- ('globalsign_example_keys/SSL2.cer', b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"),
- ('globalsign_example_keys/SSL3.cer', b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"),
+ (
+ 'keys/test-der.crt',
+ b'\xbeB\x85=\xcc\xff\xe3\xf9(\x02\x8f~XV\xb4\xfd\x03\\\xeaK'
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ b'\xbeB\x85=\xcc\xff\xe3\xf9(\x02\x8f~XV\xb4\xfd\x03\\\xeaK'
+ ),
+ (
+ 'keys/test-third-der.crt',
+ b'\xd2\n\xfd.%\xd1\xb7!\xd7P~\xbb\xa4}\xbf4\xefR^\x02'
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ b'\xda\xbb.\xaa\xb0\x0c\xb8\x88&Qt\\m\x03\xd3\xc0\xd8\x8fz\xd6'
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ b',\xd5PA\x97\x15\x8b\xf0\x8f6a[J\xfbk\xd9\x99\xc93\x92'
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ b'\xde\xcf\\P\xb7\xae\x02\x1f\x15\x17\xaa\x16\xe8\r\xb5(\x9djZ\xf3'
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ None
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ b'y\xb4Y\xe6{\xb6\xe5\xe4\x01s\x80\x08\x88\xc8\x1aX\xf6\xe9\x9bn'
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ b'y\xb4Y\xe6{\xb6\xe5\xe4\x01s\x80\x08\x88\xc8\x1aX\xf6\xe9\x9bn'
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ b'd|\\\xe1\xe0`8NH\x9f\x05\xbcUc~?\xaeM\xf7\x1e'
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ b"'\xf8/\xe9]\xd7\r\xf4\xa8\xea\x87\x99=\xfd\x8e\xb3\x9e@\xd0\x91"
+ ),
)
@data('authority_key_identifier_info')
@@ -1177,25 +1998,70 @@
cert = self._load_cert(relative_path)
self.assertEqual(authority_key_identifier, cert.authority_key_identifier)
- #pylint: disable=C0326
@staticmethod
def authority_issuer_serial_info():
return (
- ('keys/test-der.crt', b'\xdd\x8a\x19x\xae`\x19=\xa7\xf8\x00\xb9\xfbx\xf8\xedu\xb8!\xf8\x8c\xdb\x1f\x99\'7w\x93\xb4\xa4\'\xa0:13683582341504654466'),
- ('keys/test-inter-der.crt', None),
- ('keys/test-third-der.crt', None),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', None),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', None),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', None),
- ('geotrust_certs/codex.crt', None),
- ('lets_encrypt/isrgrootx1.pem', None),
- ('lets_encrypt/letsencryptauthorityx1.pem', None),
- ('lets_encrypt/letsencryptauthorityx2.pem', None),
- ('globalsign_example_keys/IssuingCA-der.cer', None),
- ('globalsign_example_keys/rootCA.cer', None),
- ('globalsign_example_keys/SSL1.cer', None),
- ('globalsign_example_keys/SSL2.cer', None),
- ('globalsign_example_keys/SSL3.cer', None),
+ (
+ 'keys/test-der.crt',
+ b'\xdd\x8a\x19x\xae`\x19=\xa7\xf8\x00\xb9\xfbx\xf8\xedu\xb8!\xf8\x8c'
+ b'\xdb\x1f\x99\'7w\x93\xb4\xa4\'\xa0:13683582341504654466'
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ None
+ ),
+ (
+ 'keys/test-third-der.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ None
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ None
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ None
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ None
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ None
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ None
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ None
+ ),
)
@data('authority_issuer_serial_info')
@@ -1203,25 +2069,69 @@
cert = self._load_cert(relative_path)
self.assertEqual(authority_issuer_serial, cert.authority_issuer_serial)
- #pylint: disable=C0326
@staticmethod
def ocsp_urls_info():
return (
- ('keys/test-der.crt', []),
- ('keys/test-inter-der.crt', []),
- ('keys/test-third-der.crt', []),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', []),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', []),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', ['http://g2.symcb.com']),
- ('geotrust_certs/codex.crt', ['http://gm.symcd.com']),
- ('lets_encrypt/isrgrootx1.pem', []),
- ('lets_encrypt/letsencryptauthorityx1.pem', ['http://ocsp.root-x1.letsencrypt.org/']),
- ('lets_encrypt/letsencryptauthorityx2.pem', ['http://ocsp.root-x1.letsencrypt.org/']),
- ('globalsign_example_keys/IssuingCA-der.cer', []),
- ('globalsign_example_keys/rootCA.cer', []),
- ('globalsign_example_keys/SSL1.cer', ['http://ocsp.exampleovca.com/']),
- ('globalsign_example_keys/SSL2.cer', ['http://ocsp.exampleovca.com/']),
- ('globalsign_example_keys/SSL3.cer', ['http://ocsp.exampleovca.com/']),
+ (
+ 'keys/test-der.crt',
+ []
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ []
+ ),
+ (
+ 'keys/test-third-der.crt',
+ []
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ []
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ []
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ ['http://g2.symcb.com']
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ ['http://gm.symcd.com']
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ []
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ ['http://ocsp.root-x1.letsencrypt.org/']
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ ['http://ocsp.root-x1.letsencrypt.org/']
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ []
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ []
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ ['http://ocsp.exampleovca.com/']
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ ['http://ocsp.exampleovca.com/']
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ ['http://ocsp.exampleovca.com/']
+ ),
)
@data('ocsp_urls_info')
@@ -1229,15 +2139,29 @@
cert = self._load_cert(relative_path)
self.assertEqual(ocsp_url, cert.ocsp_urls)
- #pylint: disable=C0326
@staticmethod
def crl_distribution_points_info():
return (
- ('keys/test-der.crt', []),
- ('keys/test-inter-der.crt', []),
- ('keys/test-third-der.crt', []),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', []),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', []),
+ (
+ 'keys/test-der.crt',
+ []
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ []
+ ),
+ (
+ 'keys/test-third-der.crt',
+ []
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ []
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ []
+ ),
(
'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
[
@@ -1258,7 +2182,10 @@
])
]
),
- ('lets_encrypt/isrgrootx1.pem', []),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ []
+ ),
(
'lets_encrypt/letsencryptauthorityx1.pem',
[
@@ -1299,9 +2226,18 @@
])
]
),
- ('globalsign_example_keys/SSL1.cer', []),
- ('globalsign_example_keys/SSL2.cer', []),
- ('globalsign_example_keys/SSL3.cer', []),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ []
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ []
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ []
+ ),
)
@data('crl_distribution_points_info')
@@ -1310,25 +2246,69 @@
points = [point.native for point in cert.crl_distribution_points]
self.assertEqual(crl_distribution_point, points)
- #pylint: disable=C0326
@staticmethod
def valid_domains_info():
return (
- ('keys/test-der.crt', []),
- ('keys/test-inter-der.crt', []),
- ('keys/test-third-der.crt', []),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', []),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', []),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', []),
- ('geotrust_certs/codex.crt', ['dev.codexns.io', 'rc.codexns.io', 'packagecontrol.io', 'wbond.net', 'codexns.io']),
- ('lets_encrypt/isrgrootx1.pem', []),
- ('lets_encrypt/letsencryptauthorityx1.pem', []),
- ('lets_encrypt/letsencryptauthorityx2.pem', []),
- ('globalsign_example_keys/IssuingCA-der.cer', []),
- ('globalsign_example_keys/rootCA.cer', []),
- ('globalsign_example_keys/SSL1.cer', ['anything.example.com']),
- ('globalsign_example_keys/SSL2.cer', ['anything.example.com']),
- ('globalsign_example_keys/SSL3.cer', ['*.google.com']),
+ (
+ 'keys/test-der.crt',
+ []
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ []
+ ),
+ (
+ 'keys/test-third-der.crt',
+ []
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ []
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ []
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ []
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ ['dev.codexns.io', 'rc.codexns.io', 'packagecontrol.io', 'wbond.net', 'codexns.io']
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ []
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ []
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ []
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ []
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ []
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ ['anything.example.com']
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ ['anything.example.com']
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ ['*.google.com']
+ ),
)
@data('valid_domains_info')
@@ -1336,25 +2316,69 @@
cert = self._load_cert(relative_path)
self.assertEqual(valid_domains, cert.valid_domains)
- #pylint: disable=C0326
@staticmethod
def valid_ips_info():
return (
- ('keys/test-der.crt', []),
- ('keys/test-inter-der.crt', []),
- ('keys/test-third-der.crt', []),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', []),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', []),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', []),
- ('geotrust_certs/codex.crt', []),
- ('lets_encrypt/isrgrootx1.pem', []),
- ('lets_encrypt/letsencryptauthorityx1.pem', []),
- ('lets_encrypt/letsencryptauthorityx2.pem', []),
- ('globalsign_example_keys/IssuingCA-der.cer', []),
- ('globalsign_example_keys/rootCA.cer', []),
- ('globalsign_example_keys/SSL1.cer', []),
- ('globalsign_example_keys/SSL2.cer', []),
- ('globalsign_example_keys/SSL3.cer', []),
+ (
+ 'keys/test-der.crt',
+ []
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ []
+ ),
+ (
+ 'keys/test-third-der.crt',
+ []
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ []
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ []
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ []
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ []
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ []
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ []
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ []
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ []
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ []
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ []
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ []
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ []
+ ),
)
@data('valid_ips_info')
@@ -1362,25 +2386,69 @@
cert = self._load_cert(relative_path)
self.assertEqual(crl_url, cert.valid_ips)
- #pylint: disable=C0326
@staticmethod
def self_issued_info():
return (
- ('keys/test-der.crt', True),
- ('keys/test-inter-der.crt', False),
- ('keys/test-third-der.crt', False),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', True),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', True),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', False),
- ('geotrust_certs/codex.crt', False),
- ('lets_encrypt/isrgrootx1.pem', True),
- ('lets_encrypt/letsencryptauthorityx1.pem', False),
- ('lets_encrypt/letsencryptauthorityx2.pem', False),
- ('globalsign_example_keys/IssuingCA-der.cer', False),
- ('globalsign_example_keys/rootCA.cer', True),
- ('globalsign_example_keys/SSL1.cer', False),
- ('globalsign_example_keys/SSL2.cer', False),
- ('globalsign_example_keys/SSL3.cer', False),
+ (
+ 'keys/test-der.crt',
+ True
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ False
+ ),
+ (
+ 'keys/test-third-der.crt',
+ False
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ True
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ True
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ False
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ False
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ True
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ False
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ False
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ False
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ True
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ False
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ False
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ False
+ ),
)
@data('self_issued_info')
@@ -1388,25 +2456,69 @@
cert = self._load_cert(relative_path)
self.assertEqual(self_issued, cert.self_issued)
- #pylint: disable=C0326
@staticmethod
def self_signed_info():
return (
- ('keys/test-der.crt', 'yes'),
- ('keys/test-inter-der.crt', 'no'),
- ('keys/test-third-der.crt', 'no'),
- ('geotrust_certs/GeoTrust_Universal_CA.crt', 'yes'),
- ('geotrust_certs/GeoTrust_Primary_CA.crt', 'yes'),
- ('geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt', 'no'),
- ('geotrust_certs/codex.crt', 'no'),
- ('lets_encrypt/isrgrootx1.pem', 'yes'),
- ('lets_encrypt/letsencryptauthorityx1.pem', 'no'),
- ('lets_encrypt/letsencryptauthorityx2.pem', 'no'),
- ('globalsign_example_keys/IssuingCA-der.cer', 'no'),
- ('globalsign_example_keys/rootCA.cer', 'yes'),
- ('globalsign_example_keys/SSL1.cer', 'no'),
- ('globalsign_example_keys/SSL2.cer', 'no'),
- ('globalsign_example_keys/SSL3.cer', 'no'),
+ (
+ 'keys/test-der.crt',
+ 'yes'
+ ),
+ (
+ 'keys/test-inter-der.crt',
+ 'no'
+ ),
+ (
+ 'keys/test-third-der.crt',
+ 'no'
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Universal_CA.crt',
+ 'yes'
+ ),
+ (
+ 'geotrust_certs/GeoTrust_Primary_CA.crt',
+ 'yes'
+ ),
+ (
+ 'geotrust_certs/GeoTrust_EV_SSL_CA_-_G4.crt',
+ 'no'
+ ),
+ (
+ 'geotrust_certs/codex.crt',
+ 'no'
+ ),
+ (
+ 'lets_encrypt/isrgrootx1.pem',
+ 'yes'
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx1.pem',
+ 'no'
+ ),
+ (
+ 'lets_encrypt/letsencryptauthorityx2.pem',
+ 'no'
+ ),
+ (
+ 'globalsign_example_keys/IssuingCA-der.cer',
+ 'no'
+ ),
+ (
+ 'globalsign_example_keys/rootCA.cer',
+ 'yes'
+ ),
+ (
+ 'globalsign_example_keys/SSL1.cer',
+ 'no'
+ ),
+ (
+ 'globalsign_example_keys/SSL2.cer',
+ 'no'
+ ),
+ (
+ 'globalsign_example_keys/SSL3.cer',
+ 'no'
+ ),
)
@data('self_signed_info')
@@ -1484,7 +2596,7 @@
subject_public_key_algorithm['parameters'].native
)
self.assertEqual(
- 23903990516906431865559598284199534387004799030432486061102966678620221767754702651554142956492614440585611990224871381291841413369032752409360196079700921141819811294444393525264295297988924243231844876926173670633422654261873814968313363171188082579071492839040415373948505938897419917635370450127498164824808630475648771544810334682447182123219422360569466851807131368135806769502898151721274383486320505905826683946456552230958810028663378886363555981449715929872558073101554364803925363048965464124465016494920967179276744892632783712377912841537032383450409486298694116013299423220523450956288827030007092359007,
+ 23903990516906431865559598284199534387004799030432486061102966678620221767754702651554142956492614440585611990224871381291841413369032752409360196079700921141819811294444393525264295297988924243231844876926173670633422654261873814968313363171188082579071492839040415373948505938897419917635370450127498164824808630475648771544810334682447182123219422360569466851807131368135806769502898151721274383486320505905826683946456552230958810028663378886363555981449715929872558073101554364803925363048965464124465016494920967179276744892632783712377912841537032383450409486298694116013299423220523450956288827030007092359007, # noqa
subject_public_key['modulus'].native
)
self.assertEqual(
@@ -1527,7 +2639,10 @@
(
'extn_value',
util.OrderedDict([
- ('key_identifier', b'\xBE\x42\x85\x3D\xCC\xFF\xE3\xF9\x28\x02\x8F\x7E\x58\x56\xB4\xFD\x03\x5C\xEA\x4B'),
+ (
+ 'key_identifier',
+ b'\xBE\x42\x85\x3D\xCC\xFF\xE3\xF9\x28\x02\x8F\x7E\x58\x56\xB4\xFD\x03\x5C\xEA\x4B'
+ ),
(
'authority_cert_issuer',
[
@@ -1628,14 +2743,14 @@
)
self.assertEqual(
util.OrderedDict([
- ('p', 4511743893397705393934377497936985478231822206263141826261443300639402520800626925517264115785551703273809312112372693877437137848393530691841757974971843334497076835630893064661599193178307024379015589119302113551197423138934242435710226975119594589912289060014025377813473273600967729027125618396732574594753039493158066887433778053086408525146692226448554390096911703556213619406958876388642882534250747780313634767409586007581976273681005928967585750017105562145167146445061803488570714706090280814293902464230717946651489964409785146803791743658888866280873858000476717727810363942159874283767926511678640730707887895260274767195555813448140889391762755466967436731106514029224490921857229134393798015954890071206959203407845438863870686180087606429828973298318856683615900474921310376145478859687052812749087809700610549251964102790514588562086548577933609968589710807989944739877028770343142449461177732058649962678857),
+ ('p', 4511743893397705393934377497936985478231822206263141826261443300639402520800626925517264115785551703273809312112372693877437137848393530691841757974971843334497076835630893064661599193178307024379015589119302113551197423138934242435710226975119594589912289060014025377813473273600967729027125618396732574594753039493158066887433778053086408525146692226448554390096911703556213619406958876388642882534250747780313634767409586007581976273681005928967585750017105562145167146445061803488570714706090280814293902464230717946651489964409785146803791743658888866280873858000476717727810363942159874283767926511678640730707887895260274767195555813448140889391762755466967436731106514029224490921857229134393798015954890071206959203407845438863870686180087606429828973298318856683615900474921310376145478859687052812749087809700610549251964102790514588562086548577933609968589710807989944739877028770343142449461177732058649962678857), # noqa
('q', 71587850165936478337655415373676526523562874562337607790945426056266440596923),
- ('g', 761437146067908309288345767887973163494473925243194806582679580640442238588269326525839153095505341738937595419375068472941615006110237832663093084973431440436421580371384720052414080562019831325744042316268714195397974084616335082272743706567701546951285088540646372701485690904535540223121118329044403681933304838754517522024738251994717369464179515923093116622352823578284891812676662979104509631349201801577889230316128523885862472086364717411346341249139971907827526291913249445756671582283459372536334490171231311487207683108274785825764378203622999309355578169139646003751751448501475767709869676880946562283552431757983801739671783678927397420797147373441051876558068212062253171347849380506793433921881336652424898488378657239798694995315456959568806256079056461448199493507273882763491729787817044805150879660784158902456811649964987582162907020243296662602990514615480712948126671999033658064244112238138589732202),
+ ('g', 761437146067908309288345767887973163494473925243194806582679580640442238588269326525839153095505341738937595419375068472941615006110237832663093084973431440436421580371384720052414080562019831325744042316268714195397974084616335082272743706567701546951285088540646372701485690904535540223121118329044403681933304838754517522024738251994717369464179515923093116622352823578284891812676662979104509631349201801577889230316128523885862472086364717411346341249139971907827526291913249445756671582283459372536334490171231311487207683108274785825764378203622999309355578169139646003751751448501475767709869676880946562283552431757983801739671783678927397420797147373441051876558068212062253171347849380506793433921881336652424898488378657239798694995315456959568806256079056461448199493507273882763491729787817044805150879660784158902456811649964987582162907020243296662602990514615480712948126671999033658064244112238138589732202), # noqa
]),
subject_public_key_algorithm['parameters'].native
)
self.assertEqual(
- 934231235067929794039535952071098031636053793876274937162425423023735221571983693370780054696865229184537343792766496068557051933738826401423094028670222490622041397241325320965905259541032379046252395145258594355589801644789631904099105867133976990593761395721476198083091062806327384261369876465927159169400428623265291958463077792777155465482611741502621885386691681062128487785344975981628995609792181581218570320181053055516069553767918513262908069925035292416868414952256645902605335068760774106734518308281769128146479819566784704033671969858507248124850451414380441279385481154336362988505436125981975735568289420374790767927084033441728922597082155884801013899630856890463962357814273014111039522903328923758417820349377075487103441305806369234738881875734407495707878637895190993370257589211331043479113328811265005530361001980539377903738453549980082795009589559114091215518866106998956304437954236070776810740036,
+ 934231235067929794039535952071098031636053793876274937162425423023735221571983693370780054696865229184537343792766496068557051933738826401423094028670222490622041397241325320965905259541032379046252395145258594355589801644789631904099105867133976990593761395721476198083091062806327384261369876465927159169400428623265291958463077792777155465482611741502621885386691681062128487785344975981628995609792181581218570320181053055516069553767918513262908069925035292416868414952256645902605335068760774106734518308281769128146479819566784704033671969858507248124850451414380441279385481154336362988505436125981975735568289420374790767927084033441728922597082155884801013899630856890463962357814273014111039522903328923758417820349377075487103441305806369234738881875734407495707878637895190993370257589211331043479113328811265005530361001980539377903738453549980082795009589559114091215518866106998956304437954236070776810740036, # noqa
subject_public_key.native
)
self.assertEqual(
@@ -1674,7 +2789,10 @@
(
'extn_value',
util.OrderedDict([
- ('key_identifier', b'\x81\xA3\x37\x86\xF9\x99\x28\xF2\x74\x70\x60\x87\xF2\xD3\x7E\x8D\x19\x61\xA8\xBE'),
+ (
+ 'key_identifier',
+ b'\x81\xA3\x37\x86\xF9\x99\x28\xF2\x74\x70\x60\x87\xF2\xD3\x7E\x8D\x19\x61\xA8\xBE'
+ ),
('authority_cert_issuer', None),
('authority_cert_serial_number', None),
])
@@ -1776,11 +2894,13 @@
field_id['parameters'].native
)
self.assertEqual(
- b'\xFF\xFF\xFF\xFF\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFC',
+ b'\xFF\xFF\xFF\xFF\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00'
+ b'\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFC',
curve['a'].native
)
self.assertEqual(
- b'\x5A\xC6\x35\xD8\xAA\x3A\x93\xE7\xB3\xEB\xBD\x55\x76\x98\x86\xBC\x65\x1D\x06\xB0\xCC\x53\xB0\xF6\x3B\xCE\x3C\x3E\x27\xD2\x60\x4B',
+ b'\x5A\xC6\x35\xD8\xAA\x3A\x93\xE7\xB3\xEB\xBD\x55\x76\x98\x86\xBC'
+ b'\x65\x1D\x06\xB0\xCC\x53\xB0\xF6\x3B\xCE\x3C\x3E\x27\xD2\x60\x4B',
curve['b'].native
)
self.assertEqual(
@@ -1788,7 +2908,10 @@
curve['seed'].native
)
self.assertEqual(
- b'\x04\x6B\x17\xD1\xF2\xE1\x2C\x42\x47\xF8\xBC\xE6\xE5\x63\xA4\x40\xF2\x77\x03\x7D\x81\x2D\xEB\x33\xA0\xF4\xA1\x39\x45\xD8\x98\xC2\x96\x4F\xE3\x42\xE2\xFE\x1A\x7F\x9B\x8E\xE7\xEB\x4A\x7C\x0F\x9E\x16\x2B\xCE\x33\x57\x6B\x31\x5E\xCE\xCB\xB6\x40\x68\x37\xBF\x51\xF5',
+ b'\x04\x6B\x17\xD1\xF2\xE1\x2C\x42\x47\xF8\xBC\xE6\xE5\x63\xA4\x40'
+ b'\xF2\x77\x03\x7D\x81\x2D\xEB\x33\xA0\xF4\xA1\x39\x45\xD8\x98\xC2'
+ b'\x96\x4F\xE3\x42\xE2\xFE\x1A\x7F\x9B\x8E\xE7\xEB\x4A\x7C\x0F\x9E'
+ b'\x16\x2B\xCE\x33\x57\x6B\x31\x5E\xCE\xCB\xB6\x40\x68\x37\xBF\x51\xF5',
public_key_params['base'].native
)
self.assertEqual(
@@ -1804,7 +2927,9 @@
public_key_params['hash'].native
)
self.assertEqual(
- b'\x04\x8b]Lq\xf7\xd6\xc6\xa3IcB\\G\x9f\xcbs$\x1d\xc9\xdd\xd1-\xf1:\x9f\xb7\x04\xde \xd0X\x00\x93T\xf6\x89\xc7/\x87+\xf7\xf9=;4\xed\x9e{\x0e=WB\xdfx\x03\x0b\xcc1\xc6\x03\xd7\x9f`\x01',
+ b'\x04\x8b]Lq\xf7\xd6\xc6\xa3IcB\\G\x9f\xcbs$\x1d\xc9\xdd\xd1-\xf1:\x9f'
+ b'\xb7\x04\xde \xd0X\x00\x93T\xf6\x89\xc7/\x87+\xf7\xf9=;4\xed\x9e{\x0e'
+ b'=WB\xdfx\x03\x0b\xcc1\xc6\x03\xd7\x9f`\x01',
subject_public_key.native
)
self.assertEqual(
@@ -1843,7 +2968,10 @@
(
'extn_value',
util.OrderedDict([
- ('key_identifier', b'\x54\xAA\x54\x70\x6C\x34\x1A\x6D\xEB\x5D\x97\xD7\x1E\xFC\xD5\x24\x3C\x8A\x0E\xD7'),
+ (
+ 'key_identifier',
+ b'\x54\xAA\x54\x70\x6C\x34\x1A\x6D\xEB\x5D\x97\xD7\x1E\xFC\xD5\x24\x3C\x8A\x0E\xD7'
+ ),
('authority_cert_issuer', None),
('authority_cert_serial_number', None),
])
diff --git a/tests/unittest_data.py b/tests/unittest_data.py
index 25dd58c..5ceac54 100644
--- a/tests/unittest_data.py
+++ b/tests/unittest_data.py
@@ -25,20 +25,20 @@
"""
def test_func_decorator(test_func):
- test_func._provider_method = provider_method #pylint: disable=W0212
- test_func._provider_name_suffix = first_param_name_suffix #pylint: disable=W0212
+ test_func._provider_method = provider_method
+ test_func._provider_name_suffix = first_param_name_suffix
return test_func
return test_func_decorator
-def DataDecorator(cls):
+def data_decorator(cls):
"""
A class decorator that works with the @provider decorator to generate test
method from a data provider
"""
def generate_test_func(name, original_function, num, params):
- if original_function._provider_name_suffix: #pylint: disable=W0212
+ if original_function._provider_name_suffix:
data_name = params[0]
params = params[1:]
else:
@@ -53,7 +53,7 @@
func = getattr(cls, name)
if hasattr(func, '_provider_method'):
num = 1
- for params in getattr(cls, func._provider_method)(): #pylint: disable=W0212
+ for params in getattr(cls, func._provider_method)():
generate_test_func(name, func, num, params)
num += 1