aboutsummaryrefslogtreecommitdiff
path: root/pyecsca/misc
diff options
context:
space:
mode:
authorJ08nY2021-04-11 14:16:57 +0200
committerJ08nY2021-04-11 14:16:57 +0200
commit942c0fb9d6fcbff7c91c553211cc81c7e0939e4e (patch)
tree1df80da6030019ef2a7490d2b2050a7d4b9a83ec /pyecsca/misc
parenta2e01e037fcde3e63571633e94156e324a4f2299 (diff)
downloadpyecsca-942c0fb9d6fcbff7c91c553211cc81c7e0939e4e.tar.gz
pyecsca-942c0fb9d6fcbff7c91c553211cc81c7e0939e4e.tar.zst
pyecsca-942c0fb9d6fcbff7c91c553211cc81c7e0939e4e.zip
Diffstat (limited to 'pyecsca/misc')
-rw-r--r--pyecsca/misc/cfg.py63
1 files changed, 38 insertions, 25 deletions
diff --git a/pyecsca/misc/cfg.py b/pyecsca/misc/cfg.py
index 8a5a9ee..82cb387 100644
--- a/pyecsca/misc/cfg.py
+++ b/pyecsca/misc/cfg.py
@@ -1,6 +1,7 @@
"""
-This module provides functions for runtime configuration of the toolkit, such as how errors are handled, or which
-:py:class:`Mod` implementation is used.
+This module provides functions for runtime configuration of the toolkit.
+
+This includes how errors are handled, or which :py:class:`~pyecsca.ec.mod.Mod` implementation is used.
"""
from copy import deepcopy
from contextvars import ContextVar, Token
@@ -21,11 +22,14 @@ class ECConfig(object):
@property
def no_inverse_action(self) -> str:
"""
- The action to take when a non-invertible element is to be inverted. One of:
+ Return or set the action to take when a non-invertible element is to be inverted.
+
+ One of:
- - `"error"`: Raise :py:class:`pyecsca.ec.error.NonInvertibleError`.
- - `"warning"`: Raise :py:class:`pyecsca.ec.error.NonInvertibleWarning`.
- - `"ignore"`: Ignore the event and compute as if nothing happened."""
+ - ``"error"``: Raise :py:class:`pyecsca.ec.error.NonInvertibleError`.
+ - ``"warning"``: Raise :py:class:`pyecsca.ec.error.NonInvertibleWarning`.
+ - ``"ignore"``: Ignore the event and compute as if nothing happened.
+ """
return self._no_inverse_action
@no_inverse_action.setter
@@ -37,11 +41,14 @@ class ECConfig(object):
@property
def non_residue_action(self) -> str:
"""
- The action to take when a the square-root of a non-residue is to be computed. One of:
+ Return or set the action to take when a the square-root of a non-residue is to be computed.
+
+ One of:
- - `"error"`: Raise :py:class:`pyecsca.ec.error.NonResidueError`.
- - `"warning"`: Raise :py:class:`pyecsca.ec.error.NonResidueWarning`.
- - `"ignore"`: Ignore the event and compute as if nothing happened."""
+ - ``"error"``: Raise :py:class:`pyecsca.ec.error.NonResidueError`.
+ - ``"warning"``: Raise :py:class:`pyecsca.ec.error.NonResidueWarning`.
+ - ``"ignore"``: Ignore the event and compute as if nothing happened.
+ """
return self._non_residue_action
@non_residue_action.setter
@@ -53,15 +60,16 @@ class ECConfig(object):
@property
def unsatisfied_formula_assumption_action(self) -> str:
"""
- The action to take when a formula assumption is unsatisfied during execution.
+ Return or set the action to take when a formula assumption is unsatisfied during execution.
+
This works for assumption that can be ignored without a fatal error,
which are those that are not used to compute a value of an undefined parameter.
- For example, things of the form `Z1 = 1`.
+ For example, things of the form ``Z1 = 1``.
One of:
- - `"error"`: Raise :py:class:`pyecsca.ec.error.UnsatisfiedAssumptionError`.
- - `"warning"`: Raise :py:class:`pyecsca.ec.error.UnsatisfiedAssumptionWarning`.
- - `"ignore"`: Ignore the event and compute as if nothing happened.
+ - ``"error"``: Raise :py:class:`pyecsca.ec.error.UnsatisfiedAssumptionError`.
+ - ``"warning"``: Raise :py:class:`pyecsca.ec.error.UnsatisfiedAssumptionWarning`.
+ - ``"ignore"``: Ignore the event and compute as if nothing happened.
"""
return self._unsatisfied_formula_assumption_action
@@ -74,15 +82,16 @@ class ECConfig(object):
@property
def unsatisfied_coordinate_assumption_action(self) -> str:
"""
- The action to take when a coordinate assumption is unsatisfied during curve creation.
+ Return or set the action to take when a coordinate assumption is unsatisfied during curve creation.
+
This works for assumption that can be ignored without a fatal error,
which are those that are not used to compute a value of an undefined parameter.
- For example, things of the form `a = -1`.
+ For example, things of the form ``a = -1``.
One of:
- - `"error"`: Raise :py:class:`pyecsca.ec.error.UnsatisfiedAssumptionError`.
- - `"warning"`: Raise :py:class:`pyecsca.ec.error.UnsatisfiedAssumptionWarning`.
- - `"ignore"`: Ignore the event and compute as if nothing happened.
+ - ``"error"``: Raise :py:class:`pyecsca.ec.error.UnsatisfiedAssumptionError`.
+ - ``"warning"``: Raise :py:class:`pyecsca.ec.error.UnsatisfiedAssumptionWarning`.
+ - ``"ignore"``: Ignore the event and compute as if nothing happened.
"""
return self._unsatisfied_coordinate_assumption_action
@@ -95,10 +104,12 @@ class ECConfig(object):
@property
def mod_implementation(self) -> str:
"""
- The selected :py:class:`pyecsca.ec.mod.Mod` implementation. One of:
+ Return or set the selected :py:class:`pyecsca.ec.mod.Mod` implementation.
- - `"gmp"`: Requires the GMP library and `gmpy2` package.
- - `"python"`: Doesn't require anything.
+ One of:
+
+ - ``"gmp"``: Requires the GMP library and `gmpy2` package.
+ - ``"python"``: Doesn't require anything.
"""
return self._mod_implementation
@@ -111,7 +122,7 @@ class ECConfig(object):
@public
class Config(object):
- """A runtime configuration for the library."""
+ """Runtime configuration for the library."""
ec: ECConfig
"""Configuration for the :py:mod:`pyecsca.ec` package."""
@@ -157,7 +168,9 @@ def resetconfig(token: Token) -> None:
@public
class TemporaryConfig(object):
"""
- A temporary config context manager, can be entered as follows:
+ Temporary config context manager.
+
+ Can be entered as follows:
.. code-block:: python