Skip to content

Commit 3a520b5

Browse files
committed
Merge branch 'hpke'
2 parents f1cefb8 + 7949b7b commit 3a520b5

File tree

52 files changed

+1756
-305
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1756
-305
lines changed

.readthedocs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2
22
python:
33
install:
4-
- requirements: Doc/requirements.txt
4+
- requirements: Doc/requirements-docs.txt
55
build:
66
os: ubuntu-22.04
77
tools:

Changelog.rst

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Changelog
44
Under development
55
++++++++++++++++++++++++++
66

7+
New features
8+
---------------
9+
* Added support for HPKE (RFC 9180).
10+
711
Other changes
812
-------------
913
* Remove support for Python 3.6.

Doc/Makefile

+1-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
1414
# the i18n builder cannot share the environment and doctrees with the others
1515
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
1616

17-
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
17+
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp latex latexpdf text man changes linkcheck doctest gettext
1818

1919
help:
2020
@echo "Please use \`make <target>' where <target> is one of"
@@ -26,7 +26,6 @@ help:
2626
@echo " htmlhelp to make HTML files and a HTML help project"
2727
@echo " qthelp to make HTML files and a qthelp project"
2828
@echo " devhelp to make HTML files and a Devhelp project"
29-
@echo " epub to make an epub"
3029
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
3130
@echo " latexpdf to make LaTeX files and run them through pdflatex"
3231
@echo " text to make text files"
@@ -90,11 +89,6 @@ devhelp:
9089
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PyCryptodome"
9190
@echo "# devhelp"
9291

93-
epub:
94-
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
95-
@echo
96-
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
97-
9892
latex:
9993
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
10094
@echo

Doc/conf.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ def have_aes_ni(self):
5454
# Add any Sphinx extension module names here, as strings. They can be extensions
5555
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
5656
extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.napoleon',
57-
'sphinx.ext.mathjax' ]
57+
'sphinx.ext.mathjax', 'sphinx_autodoc_typehints' ]
5858

5959
# Add any paths that contain templates here, relative to this directory.
6060
templates_path = ['_templates']
6161

6262
# The suffix of source filenames.
63-
source_suffix = '.rst'
63+
source_suffix = {'.rst': 'restructuredtext'}
6464

6565
# The encoding of source files.
6666
#source_encoding = 'utf-8-sig'
@@ -70,7 +70,7 @@ def have_aes_ni(self):
7070

7171
# General information about the project.
7272
project = 'PyCryptodome'
73-
copyright = '2022, Helder Eijs'
73+
copyright = '2025, Helder Eijs'
7474

7575
# The version info for the project you're documenting, acts as replacement for
7676
# |version| and |release|, also used in various other places throughout the

Doc/reqs.txt

-26
This file was deleted.

Doc/requirements-docs.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sphinx==8.2.3
2+
sphinx-autodoc-typehints==3.1.0

Doc/requirements.txt

-1
This file was deleted.

Doc/sphinx_rtd_theme/__init__.py

+54-20
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
From https://github.com/ryan-roemer/sphinx-bootstrap-theme.
55
"""
66

7+
import os
78
from os import path
89
from sys import version_info as python_version
910

@@ -12,14 +13,18 @@
1213
from sphinx.util.logging import getLogger
1314

1415

15-
__version__ = '1.1.2alpha1'
16+
__version__ = '3.0.2'
1617
__version_full__ = __version__
1718

1819
logger = getLogger(__name__)
1920

2021

2122
def get_html_theme_path():
2223
"""Return list of HTML theme paths."""
24+
logger.warning(
25+
_('Calling get_html_theme_path is deprecated. If you are calling it to define html_theme_path, you are safe to remove that code.')
26+
)
27+
2328
cur_dir = path.abspath(path.dirname(path.dirname(__file__)))
2429
return cur_dir
2530

@@ -31,40 +36,69 @@ def config_initiated(app, config):
3136
_('The canonical_url option is deprecated, use the html_baseurl option from Sphinx instead.')
3237
)
3338

39+
if theme_options.get("analytics_id"):
40+
logger.warning(
41+
_('The analytics_id option is deprecated, use the sphinxcontrib-googleanalytics extension instead.')
42+
)
43+
44+
if theme_options.get("analytics_anonymize_ip"):
45+
logger.warning(
46+
_('The analytics_anonymize_ip option is deprecated, use the sphinxcontrib-googleanalytics extension instead.')
47+
)
48+
49+
if "extra_css_files" in config.html_context:
50+
logger.warning(
51+
_('The extra_css_file option is deprecated, use the html_css_files option from Sphinx instead.')
52+
)
53+
3454

3555
def extend_html_context(app, pagename, templatename, context, doctree):
3656
# Add ``sphinx_version_info`` tuple for use in Jinja templates
3757
context['sphinx_version_info'] = sphinx_version
3858

59+
# Inject all the Read the Docs environment variables in the context:
60+
# https://docs.readthedocs.io/en/stable/reference/environment-variables.html
61+
context['READTHEDOCS'] = os.environ.get("READTHEDOCS", False) == "True"
62+
if context['READTHEDOCS']:
63+
for key, value in os.environ.items():
64+
if key.startswith("READTHEDOCS_"):
65+
context[key] = value
66+
67+
3968

4069
# See http://www.sphinx-doc.org/en/stable/theming.html#distribute-your-theme-as-a-python-package
4170
def setup(app):
4271
if python_version[0] < 3:
43-
logger.warning("Python 2 is deprecated with sphinx_rtd_theme, update to Python 3")
44-
app.require_sphinx('1.6')
45-
if sphinx_version <= (2, 0, 0):
46-
logger.warning("Sphinx 1.x is deprecated with sphinx_rtd_theme, update to Sphinx 2.x or greater")
47-
if not app.config.html_experimental_html5_writer:
48-
logger.warning("'html4_writer' is deprecated with sphinx_rtd_theme")
49-
else:
50-
if app.config.html4_writer:
51-
logger.warning("'html4_writer' is deprecated with sphinx_rtd_theme")
72+
logger.error("Python 2 is not supported with sphinx_rtd_theme, update to Python 3.")
73+
74+
app.require_sphinx('6.0')
75+
if app.config.html4_writer:
76+
logger.error("'html4_writer' is not supported with sphinx_rtd_theme.")
77+
78+
# Since Sphinx 6, jquery isn't bundled anymore and we need to ensure that
79+
# the sphinxcontrib-jquery extension is enabled.
80+
# See: https://dev.readthedocs.io/en/latest/design/sphinx-jquery.html
81+
if sphinx_version >= (6, 0, 0):
82+
# Documentation of Sphinx guarantees that an extension is added and
83+
# enabled at most once.
84+
# See: https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.setup_extension
85+
app.setup_extension("sphinxcontrib.jquery")
86+
# However, we need to call the extension's callback since setup_extension doesn't do it
87+
# See: https://github.com/sphinx-contrib/jquery/issues/23
88+
from sphinxcontrib.jquery import add_js_files as jquery_add_js_files
89+
jquery_add_js_files(app, app.config)
5290

5391
# Register the theme that can be referenced without adding a theme path
5492
app.add_html_theme('sphinx_rtd_theme', path.abspath(path.dirname(__file__)))
5593

56-
if sphinx_version >= (1, 8, 0):
57-
# Add Sphinx message catalog for newer versions of Sphinx
58-
# See http://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.add_message_catalog
59-
rtd_locale_path = path.join(path.abspath(path.dirname(__file__)), 'locale')
60-
app.add_message_catalog('sphinx', rtd_locale_path)
61-
app.connect('config-inited', config_initiated)
94+
# Add Sphinx message catalog for newer versions of Sphinx
95+
# See http://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.add_message_catalog
96+
rtd_locale_path = path.join(path.abspath(path.dirname(__file__)), 'locale')
97+
app.add_message_catalog('sphinx', rtd_locale_path)
98+
app.connect('config-inited', config_initiated)
6299

63100
# sphinx emits the permalink icon for headers, so choose one more in keeping with our theme
64-
if sphinx_version >= (3, 5, 0):
65-
app.config.html_permalinks_icon = "\uf0c1"
66-
else:
67-
app.config.html_add_permalinks = "\uf0c1"
101+
app.config.html_permalinks_icon = "\uf0c1"
68102

69103
# Extend the default context when rendering the templates.
70104
app.connect("html-page-context", extend_html_context)

Doc/sphinx_rtd_theme/layout.html

+38-68
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,47 @@
77
{%- set titlesuffix = "" %}
88
{%- endif %}
99
{%- set lang_attr = 'en' if language == None else (language | replace('_', '-')) %}
10-
{%- set sphinx_writer = 'writer-html5' if html5_doctype else 'writer-html4' -%}
1110

1211
{# Build sphinx_version_info tuple from sphinx_version string in pure Jinja #}
1312
{%- set (_ver_major, _ver_minor) = (sphinx_version.split('.') | list)[:2] | map('int') -%}
1413
{%- set sphinx_version_info = (_ver_major, _ver_minor, -1) -%}
1514

1615
<!DOCTYPE html>
17-
<html class="{{ sphinx_writer }}" lang="{{ lang_attr }}" >
16+
<html class="writer-html5" lang="{{ lang_attr }}"{% if sphinx_version_info >= (7, 2) %} data-content_root="{{ content_root }}"{% endif %}>
1817
<head>
1918
<meta charset="utf-8" />
19+
{%- if READTHEDOCS and not embedded %}
20+
<meta name="readthedocs-addons-api-version" content="1">
21+
{%- endif %}
2022
{{- metatags }}
2123
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
2224
{%- block htmltitle %}
2325
<title>{{ title|striptags|e }}{{ titlesuffix }}</title>
2426
{%- endblock -%}
2527

2628
{#- CSS #}
27-
{%- if sphinx_version_info < (4, 0) -%}
28-
<link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
29-
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
30-
{%- endif %}
31-
{%- for css in css_files %}
32-
{%- if css|attr("rel") %}
33-
<link rel="{{ css.rel }}" href="{{ pathto(css.filename, 1) }}" type="text/css"{% if css.title is not none %} title="{{ css.title }}"{% endif %} />
29+
{%- for css_file in css_files %}
30+
{%- if css_file|attr("filename") %}
31+
{{ css_tag(css_file) }}
3432
{%- else %}
35-
<link rel="stylesheet" href="{{ pathto(css, 1) }}" type="text/css" />
33+
<link rel="stylesheet" href="{{ pathto(css_file, 1)|escape }}" type="text/css" />
3634
{%- endif %}
3735
{%- endfor %}
3836

39-
{%- for cssfile in extra_css_files %}
40-
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
37+
{#
38+
"extra_css_files" is an undocumented Read the Docs theme specific option.
39+
There is no need to check for ``|attr("filename")`` here because it's always a string.
40+
Note that this option should be removed in favor of regular ``html_css_files``:
41+
https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_css_files
42+
#}
43+
{%- for css_file in extra_css_files %}
44+
<link rel="stylesheet" href="{{ pathto(css_file, 1)|escape }}" type="text/css" />
4145
{%- endfor -%}
4246

4347
{#- FAVICON #}
44-
{%- if favicon %}
45-
{%- if sphinx_version_info < (4, 0) -%}
46-
<link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/>
47-
{%- else %}
48+
{%- if favicon_url %}
4849
<link rel="shortcut icon" href="{{ favicon_url }}"/>
49-
{%- endif %}
50-
{%- endif -%}
50+
{%- endif %}
5151

5252
{#- CANONICAL URL (deprecated) #}
5353
{%- if theme_canonical_url and not pageurl %}
@@ -61,36 +61,16 @@
6161

6262
{#- JAVASCRIPTS #}
6363
{%- block scripts %}
64-
<!--[if lt IE 9]>
65-
<script src="{{ pathto('_static/js/html5shiv.min.js', 1) }}"></script>
66-
<![endif]-->
6764
{%- if not embedded %}
68-
{# XXX Sphinx 1.8.0 made this an external js-file, quick fix until we refactor the template to inherert more blocks directly from sphinx #}
69-
{%- if sphinx_version_info >= (1, 8) -%}
70-
{%- if sphinx_version_info < (4, 0) -%}
71-
<script id="documentation_options" data-url_root="{{ url_root }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
72-
{%- endif -%}
73-
{%- for scriptfile in script_files %}
74-
{{ js_tag(scriptfile) }}
75-
{%- endfor %}
76-
{%- else %}
77-
<script>
78-
var DOCUMENTATION_OPTIONS = {
79-
URL_ROOT:'{{ url_root }}',
80-
VERSION:'{{ release|e }}',
81-
LANGUAGE:'{{ language }}',
82-
COLLAPSE_INDEX:false,
83-
FILE_SUFFIX:'{{ '' if no_search_suffix else file_suffix }}',
84-
HAS_SOURCE: {{ has_source|lower }},
85-
SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}'
86-
};
87-
</script>
88-
{%- for scriptfile in script_files %}
89-
<script src="{{ pathto(scriptfile, 1) }}"></script>
90-
{%- endfor %}
91-
{%- endif %}
65+
{%- for scriptfile in script_files %}
66+
{{ js_tag(scriptfile) }}
67+
{%- endfor %}
9268
<script src="{{ pathto('_static/js/theme.js', 1) }}"></script>
9369

70+
{%- if READTHEDOCS or DEBUG %}
71+
<script src="{{ pathto('_static/js/versions.js', 1) }}"></script>
72+
{%- endif %}
73+
9474
{#- OPENSEARCH #}
9575
{%- if use_opensearch %}
9676
<link rel="search" type="application/opensearchdescription+xml"
@@ -133,32 +113,22 @@
133113
<div class="wy-side-nav-search" {% if theme_style_nav_header_background %} style="background: {{theme_style_nav_header_background}}" {% endif %}>
134114
{%- block sidebartitle %}
135115

136-
{%- if logo and theme_logo_only %}
137-
<a href="{{ pathto(master_doc) }}">
138-
{%- else %}
139-
<a href="{{ pathto(master_doc) }}" class="icon icon-home"> {{ project }}
140-
{%- endif %}
141-
142-
{%- if logo %}
143-
{#- Not strictly valid HTML, but it's the only way to display/scale
144-
it properly, without weird scripting or heaps of work
145-
#}
146-
{%- if sphinx_version_info < (4, 0) -%}
147-
<img src="{{ pathto('_static/' + logo, 1) }}" class="logo" alt="{{ _('Logo') }}"/>
148-
{%- else %}
149-
<img src="{{ logo_url }}" class="logo" alt="{{ _('Logo') }}"/>
116+
{# the logo helper function was removed in Sphinx 6 and deprecated since Sphinx 4 #}
117+
{# the master_doc variable was renamed to root_doc in Sphinx 4 (master_doc still exists in later Sphinx versions) #}
118+
{%- set _logo_url = logo_url|default(pathto('_static/' + (logo or ""), 1)) %}
119+
{%- set _root_doc = root_doc|default(master_doc) %}
120+
<a href="{{ pathto(_root_doc) }}"{% if not theme_logo_only %} class="icon icon-home"{% endif %}>
121+
{% if not theme_logo_only %}{{ project }}{% endif %}
122+
{%- if logo or logo_url %}
123+
<img src="{{ _logo_url }}" class="logo" alt="{{ _('Logo') }}"/>
150124
{%- endif %}
151-
{%- endif %}
152125
</a>
153126

154-
{%- if theme_display_version %}
155-
{%- set nav_version = version %}
156-
{%- if READTHEDOCS and current_version %}
157-
{%- set nav_version = current_version %}
158-
{%- endif %}
159-
{%- if nav_version %}
160-
<div class="version">
161-
{{ nav_version }}
127+
{%- if READTHEDOCS or DEBUG %}
128+
{%- if theme_version_selector or theme_language_selector %}
129+
<div class="switch-menus">
130+
<div class="version-switch"></div>
131+
<div class="language-switch"></div>
162132
</div>
163133
{%- endif %}
164134
{%- endif %}

0 commit comments

Comments
 (0)