diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 48f1b3b..b012af3 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -8,7 +8,7 @@ on: - "master" jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: python-version: [3.7, 3.8, 3.9, "3.10"] diff --git a/CHANGELOG.md b/CHANGELOG.md index fee551e..308eeab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ # Release History -## 1.4.0 - 2022-02-06 +## 1.4.2 - 2022-12-11 + +* fix: update the black version to fix github ci pipeline +* feat: added partner setting to force canonicalize binary +* fix: freeze the version of pyflakes to resolve klen/pylama#224 +* feat: update the versions of oscrypt and asn1crypto +* fix: Use SMIMECapabilites from asn1crypto instead of the custom class (needed due to asn1crypto upgrade) + +## 1.4.1 - 2022-02-06 * fix: freezing pylama version to avoid breaking changes * feat: option to pass custom domain for AS2 message-id generation diff --git a/pyas2lib/cms.py b/pyas2lib/cms.py index 01bc008..0172980 100644 --- a/pyas2lib/cms.py +++ b/pyas2lib/cms.py @@ -1,19 +1,19 @@ """Define functions related to the CMS operations such as encrypting, signature, etc.""" import hashlib import zlib -from collections import OrderedDict from datetime import datetime, timezone from asn1crypto import cms, core, algos +from asn1crypto.cms import SMIMECapabilityIdentifier from oscrypto import asymmetric, symmetric, util +from pyas2lib.constants import DIGEST_ALGORITHMS from pyas2lib.exceptions import ( AS2Exception, DecompressionError, DecryptionError, IntegrityError, ) -from pyas2lib.constants import DIGEST_ALGORITHMS from pyas2lib.utils import normalize_digest_alg @@ -277,68 +277,6 @@ def sign_message( digest_func.update(data_to_sign) message_digest = digest_func.digest() - class SmimeCapability(core.Sequence): - """Define the possible list of Smime Capability.""" - - _fields = [ - ("0", core.Any, {"optional": True}), - ("1", core.Any, {"optional": True}), - ("2", core.Any, {"optional": True}), - ("3", core.Any, {"optional": True}), - ("4", core.Any, {"optional": True}), - ] - - class SmimeCapabilities(core.Sequence): - """Define the Smime Capabilities supported by pyas2.""" - - _fields = [ - ("0", SmimeCapability), - ("1", SmimeCapability, {"optional": True}), - ("2", SmimeCapability, {"optional": True}), - ("3", SmimeCapability, {"optional": True}), - ("4", SmimeCapability, {"optional": True}), - ("5", SmimeCapability, {"optional": True}), - ] - - smime_cap = OrderedDict( - [ - ( - "0", - OrderedDict( - [("0", core.ObjectIdentifier("2.16.840.1.101.3.4.1.42"))] - ), - ), - ( - "1", - OrderedDict( - [("0", core.ObjectIdentifier("2.16.840.1.101.3.4.1.2"))] - ), - ), - ( - "2", - OrderedDict([("0", core.ObjectIdentifier("1.2.840.113549.3.7"))]), - ), - ( - "3", - OrderedDict( - [ - ("0", core.ObjectIdentifier("1.2.840.113549.3.2")), - ("1", core.Integer(128)), - ] - ), - ), - ( - "4", - OrderedDict( - [ - ("0", core.ObjectIdentifier("1.2.840.113549.3.4")), - ("1", core.Integer(128)), - ] - ), - ), - ] - ) - signed_attributes = cms.CMSAttributes( [ cms.CMSAttribute( @@ -376,8 +314,34 @@ class SmimeCapabilities(core.Sequence): cms.CMSAttribute( { "type": cms.CMSAttributeType("1.2.840.113549.1.9.15"), - "values": cms.SetOfAny( - [core.Any(SmimeCapabilities(smime_cap))] + "values": cms.SetOfSMIMECapabilites( + [ + cms.SMIMECapabilites( + [ + SMIMECapabilityIdentifier( + {"capability_id": "2.16.840.1.101.3.4.1.42"} + ), + SMIMECapabilityIdentifier( + {"capability_id": "2.16.840.1.101.3.4.1.2"} + ), + SMIMECapabilityIdentifier( + {"capability_id": "1.2.840.113549.3.7"} + ), + SMIMECapabilityIdentifier( + { + "capability_id": "1.2.840.113549.3.2", + "parameters": core.Integer(128), + } + ), + SMIMECapabilityIdentifier( + { + "capability_id": "1.2.840.113549.3.4", + "parameters": core.Integer(128), + } + ), + ] + ) + ] ), } ), diff --git a/setup.py b/setup.py index 71bda72..7bc4ff0 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,8 @@ from setuptools import setup, find_packages install_requires = [ - "asn1crypto==1.4.0", - "oscrypto==1.2.1", + "asn1crypto==1.5.1", + "oscrypto==1.3.0", "pyOpenSSL==21.0.0", ] @@ -16,6 +16,7 @@ "pylama-pylint==3.1.1", "black==22.6.0", "pytest-black==0.3.12", + "pyflakes==2.4.0", ] setup( @@ -26,7 +27,7 @@ long_description="Docs for this project are maintained at " "https://github.com/abhishek-ram/pyas2-lib/blob/" "master/README.md", - version="1.4.1", + version="1.4.2", author="Abhishek Ram", author_email="abhishek8816@gmail.com", packages=find_packages(where=".", exclude=("test*",)),