Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions google/auth/crypt/_python_rsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from __future__ import absolute_import

import io
import warnings

from pyasn1.codec.der import decoder # type: ignore
from pyasn1_modules import pem # type: ignore
Expand All @@ -39,6 +40,15 @@
_PKCS8_MARKER = ("-----BEGIN PRIVATE KEY-----", "-----END PRIVATE KEY-----")
_PKCS8_SPEC = PrivateKeyInfo()

warnings.warn(
(
"The 'rsa' library is deprecated and will be removed in a future release. "
"Please migrate to 'cryptography'."
),
category=DeprecationWarning,
stacklevel=2,
)


def _bit_list_to_bytes(bit_list):
"""Converts an iterable of 1s and 0s to bytes.
Expand All @@ -64,6 +74,10 @@ def _bit_list_to_bytes(bit_list):
class RSAVerifier(base.Verifier):
"""Verifies RSA cryptographic signatures using public keys.

.. deprecated::
The `rsa` library has been archived. Please migrate to
`cryptography`.

Args:
public_key (rsa.key.PublicKey): The public key used to verify
signatures.
Expand Down Expand Up @@ -116,6 +130,10 @@ def from_string(cls, public_key):
class RSASigner(base.Signer, base.FromServiceAccountMixin):
"""Signs messages with an RSA private key.

.. deprecated::
The `rsa` library has been archived. Please migrate to
`cryptography`.

Args:
private_key (rsa.key.PrivateKey): The private key to sign with.
key_id (str): Optional key ID used to identify this private key. This
Expand Down
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def unit(session):
"--cov-report=term-missing",
"tests",
"tests_async",
*session.posargs,
)


Expand Down
9 changes: 9 additions & 0 deletions tests/crypt/test__python_rsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,12 @@ def test_from_service_account_file(self):

assert signer.key_id == SERVICE_ACCOUNT_INFO[base._JSON_FILE_PRIVATE_KEY_ID]
assert isinstance(signer._key, rsa.key.PrivateKey)


class TestModule(object):
def test_import_warning(self):
import importlib
from google.auth.crypt import _python_rsa

with pytest.warns(DeprecationWarning, match="The 'rsa' library is deprecated"):
importlib.reload(_python_rsa)
Loading