Skip to content

Commit

Permalink
fix import cycle with asymmetricpadding (#5758)
Browse files Browse the repository at this point in the history
* fix import cycle with asymmetricpadding

* Update src/cryptography/hazmat/primitives/_asymmetric.py
  • Loading branch information
reaperhulk committed Feb 7, 2021
1 parent a3e435f commit 4f03b8e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
17 changes: 17 additions & 0 deletions src/cryptography/hazmat/primitives/_asymmetric.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.

import abc


# This exists to break an import cycle. It is normally accessible from the
# asymmetric padding module.


class AsymmetricPadding(metaclass=abc.ABCMeta):
@abc.abstractproperty
def name(self) -> str:
"""
A string naming this padding (e.g. "PSS", "PKCS1").
"""
10 changes: 1 addition & 9 deletions src/cryptography/hazmat/primitives/asymmetric/padding.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@
# for complete details.


import abc
import typing

from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives._asymmetric import AsymmetricPadding
from cryptography.hazmat.primitives.asymmetric import rsa


class AsymmetricPadding(metaclass=abc.ABCMeta):
@abc.abstractproperty
def name(self) -> str:
"""
A string naming this padding (e.g. "PSS", "PKCS1").
"""


class PKCS1v15(AsymmetricPadding):
name = "EMSA-PKCS1-v1_5"

Expand Down
2 changes: 1 addition & 1 deletion src/cryptography/hazmat/primitives/asymmetric/rsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
from cryptography.hazmat.backends import _get_backend
from cryptography.hazmat.backends.interfaces import RSABackend
from cryptography.hazmat.primitives import _serialization, hashes
from cryptography.hazmat.primitives._asymmetric import AsymmetricPadding
from cryptography.hazmat.primitives.asymmetric import (
AsymmetricSignatureContext,
AsymmetricVerificationContext,
utils as asym_utils,
)
from cryptography.hazmat.primitives.asymmetric.padding import AsymmetricPadding


class RSAPrivateKey(metaclass=abc.ABCMeta):
Expand Down

0 comments on commit 4f03b8e

Please sign in to comment.