Loading .coveragerc +1 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,6 @@ source = cryptolyzer exclude_lines = pragma: no cover raise NotImplementedError fail_under = 92 fail_under = 100 include = cryptolyzer/* show_missing = True cryptolyzer/common/analyzer.py +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ class ProtocolHandlerBase(object): plugin_root_dir_parts = __file__.split(os.path.sep)[:-2] # remove common/analyzer.py plugin_module_dir_parts = set() for path in glob.iglob(os.path.sep.join(plugin_root_dir_parts + ['*', 'analyzer.py'])): if plugin_root_dir_parts[-3:] == ['cryptolyzer', 'common', 'analyzer.py']: if path == __file__: continue plugin_path_parts = path.split(os.path.sep)[-3:-1] # split plugin dirs Loading cryptolyzer/common/dhparam.py +16 −11 Original line number Diff line number Diff line #!/usr/bin/env python # -*- coding: utf-8 -*- from cryptography.hazmat.backends import default_backend as cryptography_default_backend # pylint: disable=import-error import cryptography.exceptions # pylint: disable=import-error import cryptography.hazmat.primitives.asymmetric.ec as cryptography_ec # pylint: disable=import-error import cryptography.hazmat.primitives.asymmetric.dh as cryptography_dh # pylint: disable=import-error import cryptography.hazmat.primitives.asymmetric.x25519 as cryptography_x25519 # pylint: disable=import-error from cryptography.hazmat.backends import default_backend as cryptography_default_backend import cryptography.exceptions import cryptography.hazmat.primitives.asymmetric.ec as cryptography_ec import cryptography.hazmat.primitives.asymmetric.dh as cryptography_dh import cryptography.hazmat.primitives.asymmetric.x25519 as cryptography_x25519 from cryptoparser.common.base import Vector, VectorParamNumeric, Serializable from cryptoparser.common.parse import ParserBinary from cryptoparser.tls.extension import TlsNamedCurve, TlsNamedCurveFactory from cryptoparser.tls.subprotocol import TlsECCurveType from cryptolyzer.common.exception import ResponseError, ResponseErrorType class TlsDHParamVector(Vector): # pylint: disable=too-many-ancestors @classmethod Loading Loading @@ -53,18 +55,21 @@ def parse_ecdh_params(param_bytes): if named_curve == TlsNamedCurve.X25519: try: public_key = cryptography_x25519.X25519PublicKey.from_public_bytes(bytes(parser['point'])) except cryptography.exceptions.UnsupportedAlgorithm: except cryptography.exceptions.UnsupportedAlgorithm: # pragma: no cover raise NotImplementedError(named_curve) else: try: cryptography_curve = getattr(cryptography_ec, named_curve.name)() except AttributeError: except AttributeError: # pragma: no cover raise NotImplementedError(named_curve) try: public_key = cryptography_ec.EllipticCurvePublicKey.from_encoded_point( cryptography_curve, bytes(parser['point']) ) except ValueError: raise ResponseError(ResponseErrorType.UNPARSABLE_RESPONSE) return parser['named_curve'], public_key Loading cryptolyzer/common/exception.py +1 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ class NetworkError(IOError): class ResponseErrorType(enum.IntEnum): PLAIN_TEXT_RESPONSE = 1 UNPARSABLE_RESPONSE = 2 UNSUPPORTED_SECURITY = 3 class ResponseError(ValueError): Loading cryptolyzer/common/x509.py +3 −3 Original line number Diff line number Diff line Loading @@ -221,11 +221,11 @@ class PublicKeyX509(PublicKey): @property def subject(self): return [attribute for attribute in self._certificate.subject] return list(self._certificate.subject) @property def issuer(self): return [attribute for attribute in self._certificate.issuer] return list(self._certificate.issuer) @property def common_names(self): Loading Loading @@ -264,7 +264,7 @@ class PublicKeyX509(PublicKey): cryptography_x509.oid.NameOID.COMMON_NAME ) for relative_name in attributes: crl_distribution_points.append(relative_name) crl_distribution_points.append(relative_name.value) return crl_distribution_points Loading Loading
.coveragerc +1 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,6 @@ source = cryptolyzer exclude_lines = pragma: no cover raise NotImplementedError fail_under = 92 fail_under = 100 include = cryptolyzer/* show_missing = True
cryptolyzer/common/analyzer.py +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ class ProtocolHandlerBase(object): plugin_root_dir_parts = __file__.split(os.path.sep)[:-2] # remove common/analyzer.py plugin_module_dir_parts = set() for path in glob.iglob(os.path.sep.join(plugin_root_dir_parts + ['*', 'analyzer.py'])): if plugin_root_dir_parts[-3:] == ['cryptolyzer', 'common', 'analyzer.py']: if path == __file__: continue plugin_path_parts = path.split(os.path.sep)[-3:-1] # split plugin dirs Loading
cryptolyzer/common/dhparam.py +16 −11 Original line number Diff line number Diff line #!/usr/bin/env python # -*- coding: utf-8 -*- from cryptography.hazmat.backends import default_backend as cryptography_default_backend # pylint: disable=import-error import cryptography.exceptions # pylint: disable=import-error import cryptography.hazmat.primitives.asymmetric.ec as cryptography_ec # pylint: disable=import-error import cryptography.hazmat.primitives.asymmetric.dh as cryptography_dh # pylint: disable=import-error import cryptography.hazmat.primitives.asymmetric.x25519 as cryptography_x25519 # pylint: disable=import-error from cryptography.hazmat.backends import default_backend as cryptography_default_backend import cryptography.exceptions import cryptography.hazmat.primitives.asymmetric.ec as cryptography_ec import cryptography.hazmat.primitives.asymmetric.dh as cryptography_dh import cryptography.hazmat.primitives.asymmetric.x25519 as cryptography_x25519 from cryptoparser.common.base import Vector, VectorParamNumeric, Serializable from cryptoparser.common.parse import ParserBinary from cryptoparser.tls.extension import TlsNamedCurve, TlsNamedCurveFactory from cryptoparser.tls.subprotocol import TlsECCurveType from cryptolyzer.common.exception import ResponseError, ResponseErrorType class TlsDHParamVector(Vector): # pylint: disable=too-many-ancestors @classmethod Loading Loading @@ -53,18 +55,21 @@ def parse_ecdh_params(param_bytes): if named_curve == TlsNamedCurve.X25519: try: public_key = cryptography_x25519.X25519PublicKey.from_public_bytes(bytes(parser['point'])) except cryptography.exceptions.UnsupportedAlgorithm: except cryptography.exceptions.UnsupportedAlgorithm: # pragma: no cover raise NotImplementedError(named_curve) else: try: cryptography_curve = getattr(cryptography_ec, named_curve.name)() except AttributeError: except AttributeError: # pragma: no cover raise NotImplementedError(named_curve) try: public_key = cryptography_ec.EllipticCurvePublicKey.from_encoded_point( cryptography_curve, bytes(parser['point']) ) except ValueError: raise ResponseError(ResponseErrorType.UNPARSABLE_RESPONSE) return parser['named_curve'], public_key Loading
cryptolyzer/common/exception.py +1 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ class NetworkError(IOError): class ResponseErrorType(enum.IntEnum): PLAIN_TEXT_RESPONSE = 1 UNPARSABLE_RESPONSE = 2 UNSUPPORTED_SECURITY = 3 class ResponseError(ValueError): Loading
cryptolyzer/common/x509.py +3 −3 Original line number Diff line number Diff line Loading @@ -221,11 +221,11 @@ class PublicKeyX509(PublicKey): @property def subject(self): return [attribute for attribute in self._certificate.subject] return list(self._certificate.subject) @property def issuer(self): return [attribute for attribute in self._certificate.issuer] return list(self._certificate.issuer) @property def common_names(self): Loading Loading @@ -264,7 +264,7 @@ class PublicKeyX509(PublicKey): cryptography_x509.oid.NameOID.COMMON_NAME ) for relative_name in attributes: crl_distribution_points.append(relative_name) crl_distribution_points.append(relative_name.value) return crl_distribution_points Loading