Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Python 3.12 and drop EOL 3.7 #223

Merged
merged 11 commits into from
Nov 1, 2023
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
7 changes: 4 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Test Python-RSA

on: [push]
on: [push, pull_request, workflow_dispatch]

permissions:
contents: read
Expand All @@ -11,20 +11,21 @@ jobs:
strategy:
matrix:
python-version:
- "3.7"
- "3.8"
- "pypy3.8"
- "3.9"
- "pypy3.9"
- "3.10"
- "pypy3.10"
- "3.11"
- "3.12"

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ cache: pip
# See: https://github.com/travis-ci/travis-ci/issues/3024

python:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
Expand All @@ -18,7 +17,7 @@ install:
- poetry install

script:
- poetry run py.test tests/
- poetry run pytest tests/

after_success:
- poetry run coveralls
12 changes: 6 additions & 6 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
master_doc = 'index'

# General information about the project.
project = u'Python-RSA'
copyright = u'2011-2019, Sybren A. Stüvel'
project = 'Python-RSA'
hugovk marked this conversation as resolved.
Show resolved Hide resolved
copyright = '2011-2019, Sybren A. Stüvel'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -180,8 +180,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'Python-RSA.tex', u'Python-RSA Documentation',
u'Sybren A. Stüvel', 'manual'),
('index', 'Python-RSA.tex', 'Python-RSA Documentation',
'Sybren A. Stüvel', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -213,8 +213,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'python-rsa', u'Python-RSA Documentation',
[u'Sybren A. Stüvel'], 1)
('index', 'python-rsa', 'Python-RSA Documentation',
['Sybren A. Stüvel'], 1)
]

todo_include_todos = True
2 changes: 1 addition & 1 deletion doc/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ GitHub. It also hosts the `issue tracker`_.
Dependencies
------------

Python-RSA is compatible with Python versions 3.7 and newer. The last
Python-RSA is compatible with Python versions 3.8 and newer. The last
version with Python 2.7 support was Python-RSA 4.0.

Python-RSA has very few dependencies. As a matter of fact, to use it
Expand Down
569 changes: 239 additions & 330 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
hugovk marked this conversation as resolved.
Show resolved Hide resolved
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Security :: Cryptography",
Expand All @@ -32,7 +32,7 @@ include = [
]

[tool.poetry.dependencies]
python = ">=3.7, <4"
python = ">=3.8, <4"
pyasn1 = ">=0.1.3"

[tool.poetry.dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion rsa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def assert_int(var: int, name: str) -> None:
if isinstance(var, int):
return

raise TypeError("%s should be an integer, not %s" % (name, var.__class__))
raise TypeError("{} should be an integer, not {}".format(name, var.__class__))


def encrypt_int(message: int, ekey: int, n: int) -> int:
Expand Down
25 changes: 6 additions & 19 deletions rsa/pkcs1.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"SHA-256": b"\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01\x05\x00\x04\x20",
"SHA-384": b"\x30\x41\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x02\x05\x00\x04\x30",
"SHA-512": b"\x30\x51\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x03\x05\x00\x04\x40",
"SHA3-256": b"\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x08\x05\x00\x04\x20",
"SHA3-384": b"\x30\x41\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x09\x05\x00\x04\x30",
"SHA3-512": b"\x30\x51\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x0a\x05\x00\x04\x40",
}

HASH_METHODS: typing.Dict[str, typing.Callable[[], HashType]] = {
Expand All @@ -56,29 +59,13 @@
"SHA-256": hashlib.sha256,
"SHA-384": hashlib.sha384,
"SHA-512": hashlib.sha512,
"SHA3-256": hashlib.sha3_256,
"SHA3-384": hashlib.sha3_384,
"SHA3-512": hashlib.sha3_512,
}
"""Hash methods supported by this library."""


if sys.version_info >= (3, 6):
# Python 3.6 introduced SHA3 support.
HASH_ASN1.update(
{
"SHA3-256": b"\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x08\x05\x00\x04\x20",
"SHA3-384": b"\x30\x41\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x09\x05\x00\x04\x30",
"SHA3-512": b"\x30\x51\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x0a\x05\x00\x04\x40",
}
)

HASH_METHODS.update(
{
"SHA3-256": hashlib.sha3_256,
"SHA3-384": hashlib.sha3_384,
"SHA3-512": hashlib.sha3_512,
}
)


class CryptoError(Exception):
"""Base class for all exceptions in this module."""

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ max-complexity = 10
max-line-length = 100

[mypy]
python_version = 3.7
python_version = 3.8
warn_unused_ignores = True
ignore_missing_imports = True
follow_imports = skip
Expand Down
1 change: 0 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Unit tests for CLI entry points.
"""

from __future__ import print_function

import functools
import io
Expand Down
3 changes: 1 addition & 2 deletions tests/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@

"""Tests string operations."""

from __future__ import absolute_import

import unittest

import rsa

unicode_string = u"Euro=\u20ac ABCDEFGHIJKLMNOPQRSTUVWXYZ"
unicode_string = "Euro=\u20ac ABCDEFGHIJKLMNOPQRSTUVWXYZ"


class StringTest(unittest.TestCase):
Expand Down
10 changes: 2 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
# Environment changes have to be manually synced with '.travis.yml'.
envlist = py37,py38,py39,py310,py311
envlist = py{38,39,310,311,312}
isolated_build = True

[pytest]
Expand All @@ -10,10 +10,4 @@ addopts = -v --cov rsa --cov-report term-missing
deps = poetry
commands =
poetry install
poetry run py.test tests/

[testenv:py37]
whitelist_externals = poetry
commands=
poetry install
poetry run py.test --doctest-modules rsa tests/
poetry run pytest --doctest-modules rsa tests/