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

Doc generation #255

Merged
merged 2 commits into from
Apr 4, 2022
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
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
69 changes: 69 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys

sys.path.insert(0, os.path.abspath("../../src"))


# -- Project information -----------------------------------------------------

project = "python-ecdsa"
copyright = "2021, Brian Warner and Hubert Kario"
author = "Brian Warner and Hubert Kario"

# The full version, including alpha/beta/rc tags
release = "0.17.0"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.coverage",
"sphinx.ext.imgmath",
"sphinx.ext.viewcode",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []

todo_include_todos = False

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

autodoc_default_options = {
"undoc-members": True,
"inherited-members": True,
}

intersphinx_mapping = {"https://docs.python.org/": None}
7 changes: 7 additions & 0 deletions docs/source/ecdsa.curves.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ecdsa.curves module
===================

.. automodule:: ecdsa.curves
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/ecdsa.der.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ecdsa.der module
================

.. automodule:: ecdsa.der
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/ecdsa.ecdh.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ecdsa.ecdh module
=================

.. automodule:: ecdsa.ecdh
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/ecdsa.ecdsa.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ecdsa.ecdsa module
==================

.. automodule:: ecdsa.ecdsa
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/ecdsa.ellipticcurve.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ecdsa.ellipticcurve module
==========================

.. automodule:: ecdsa.ellipticcurve
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/ecdsa.errors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ecdsa.errors module
===================

.. automodule:: ecdsa.errors
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/ecdsa.keys.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ecdsa.keys module
=================

.. automodule:: ecdsa.keys
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/ecdsa.numbertheory.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ecdsa.numbertheory module
=========================

.. automodule:: ecdsa.numbertheory
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/ecdsa.rfc6979.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ecdsa.rfc6979 module
====================

.. automodule:: ecdsa.rfc6979
:members:
:undoc-members:
:show-inheritance:
24 changes: 24 additions & 0 deletions docs/source/ecdsa.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ecdsa package
=============

.. automodule:: ecdsa
:members:
:undoc-members:
:show-inheritance:

Submodules
----------

.. toctree::
:maxdepth: 4

ecdsa.curves
ecdsa.der
ecdsa.ecdh
ecdsa.ecdsa
ecdsa.ellipticcurve
ecdsa.errors
ecdsa.keys
ecdsa.numbertheory
ecdsa.rfc6979
ecdsa.util
7 changes: 7 additions & 0 deletions docs/source/ecdsa.util.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ecdsa.util module
=================

.. automodule:: ecdsa.util
:members:
:undoc-members:
:show-inheritance:
20 changes: 20 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. python-ecdsa documentation master file, created by
sphinx-quickstart on Sat May 29 18:34:49 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to python-ecdsa's documentation!
========================================

.. toctree::
:maxdepth: 2
:caption: Contents:



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
7 changes: 7 additions & 0 deletions docs/source/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
src
===

.. toctree::
:maxdepth: 4

ecdsa
2 changes: 1 addition & 1 deletion src/ecdsa/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def a2b_hex(val):
raise ValueError("base16 error: %s" % e)

# pylint: disable=invalid-name
# pylint is stupid here and deson't notice it's a function, not
# pylint is stupid here and doesn't notice it's a function, not
# constant
bytes_to_int = int.from_bytes
# pylint: enable=invalid-name
Expand Down
20 changes: 10 additions & 10 deletions src/ecdsa/ecdh.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def generate_private_key(self):
:raises NoCurveError: Curve must be set before key generation.

:return: public (verifying) key from this private key.
:rtype: VerifyingKey object
:rtype: VerifyingKey
"""
if not self.curve:
raise NoCurveError("Curve must be set prior to key generation.")
Expand All @@ -135,7 +135,7 @@ def load_private_key(self, private_key):
:raises InvalidCurveError: private_key curve not the same as self.curve

:return: public (verifying) key from this private key.
:rtype: VerifyingKey object
:rtype: VerifyingKey
"""
if not self.curve:
self.curve = private_key.curve
Expand All @@ -158,7 +158,7 @@ def load_private_key_bytes(self, private_key):
:raises NoCurveError: Curve must be set before loading.

:return: public (verifying) key from this private key.
:rtype: VerifyingKey object
:rtype: VerifyingKey
"""
if not self.curve:
raise NoCurveError("Curve must be set prior to key load.")
Expand All @@ -183,7 +183,7 @@ def load_private_key_der(self, private_key_der):
:raises InvalidCurveError: private_key curve not the same as self.curve

:return: public (verifying) key from this private key.
:rtype: VerifyingKey object
:rtype: VerifyingKey
"""
return self.load_private_key(SigningKey.from_der(private_key_der))

Expand All @@ -204,7 +204,7 @@ def load_private_key_pem(self, private_key_pem):
:raises InvalidCurveError: private_key curve not the same as self.curve

:return: public (verifying) key from this private key.
:rtype: VerifyingKey object
:rtype: VerifyingKey
"""
return self.load_private_key(SigningKey.from_pem(private_key_pem))

Expand All @@ -215,7 +215,7 @@ def get_public_key(self):
Needs to be sent to the remote party.

:return: public (verifying) key from local private key.
:rtype: VerifyingKey object
:rtype: VerifyingKey
"""
return self.private_key.get_verifying_key()

Expand Down Expand Up @@ -310,7 +310,7 @@ def generate_sharedsecret_bytes(self):
:raises NoKeyError: public_key or private_key is not set

:return: shared secret
:rtype: byte string
:rtype: bytes
"""
return number_to_string(
self.generate_sharedsecret(), self.private_key.curve.curve.p()
Expand All @@ -323,9 +323,9 @@ def generate_sharedsecret(self):
The objects needs to have both private key and received public key
before generation is allowed.

It's the same for local and remote party.
shared secret(local private key, remote public key ) ==
shared secret (local public key, remote private key)
It's the same for local and remote party,
shared secret(local private key, remote public key) ==
shared secret(local public key, remote private key)

:raises InvalidCurveError: public_key curve not the same as self.curve
:raises NoKeyError: public_key or private_key is not set
Expand Down
Loading