Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
chadgates committed Jan 11, 2023
2 parents a99c7be + 26669fd commit 8add140
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
96 changes: 30 additions & 66 deletions pyas2lib/cms.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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),
}
),
]
)
]
),
}
),
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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",
]

Expand All @@ -16,6 +16,7 @@
"pylama-pylint==3.1.1",
"black==22.6.0",
"pytest-black==0.3.12",
"pyflakes==2.4.0",
]

setup(
Expand All @@ -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="[email protected]",
packages=find_packages(where=".", exclude=("test*",)),
Expand Down

0 comments on commit 8add140

Please sign in to comment.