aboutsummaryrefslogtreecommitdiffhomepage
path: root/pyecsca/sca/attack
diff options
context:
space:
mode:
Diffstat (limited to 'pyecsca/sca/attack')
-rw-r--r--pyecsca/sca/attack/__init__.py2
-rw-r--r--pyecsca/sca/attack/leakage_model.py11
2 files changed, 13 insertions, 0 deletions
diff --git a/pyecsca/sca/attack/__init__.py b/pyecsca/sca/attack/__init__.py
index 23e27cb..0748486 100644
--- a/pyecsca/sca/attack/__init__.py
+++ b/pyecsca/sca/attack/__init__.py
@@ -1 +1,3 @@
+"""Package for attacks."""
+
from .leakage_model import *
diff --git a/pyecsca/sca/attack/leakage_model.py b/pyecsca/sca/attack/leakage_model.py
index f9adcff..87f32f0 100644
--- a/pyecsca/sca/attack/leakage_model.py
+++ b/pyecsca/sca/attack/leakage_model.py
@@ -1,3 +1,6 @@
+"""
+Provides leakage models to simulate leakage.
+"""
import abc
import sys
from typing import Literal, ClassVar
@@ -46,15 +49,18 @@ class NormalNoice(Noise):
@public
class LeakageModel(abc.ABC):
+ """An abstract leakage model."""
num_args: ClassVar[int]
@abc.abstractmethod
def __call__(self, *args, **kwargs) -> int:
+ """Get the leakage from the arg(s)."""
raise NotImplementedError
@public
class Identity(LeakageModel):
+ """Identity leakage model, leaks the thing itself."""
num_args = 1
def __call__(self, *args, **kwargs) -> int:
@@ -63,6 +69,7 @@ class Identity(LeakageModel):
@public
class Bit(LeakageModel):
+ """Bit leakage model, leaks a selected bit."""
num_args = 1
def __init__(self, which: int):
@@ -77,6 +84,7 @@ class Bit(LeakageModel):
@public
class Slice(LeakageModel):
+ """Slice leakage model, leaks a slice of bits."""
num_args = 1
def __init__(self, begin: int, end: int):
@@ -94,6 +102,7 @@ class Slice(LeakageModel):
@public
class HammingWeight(LeakageModel):
+ """Hamming-weight leakage model, leaks the Hamming-weight of the thing."""
num_args = 1
def __call__(self, *args, **kwargs) -> int:
@@ -102,6 +111,7 @@ class HammingWeight(LeakageModel):
@public
class HammingDistance(LeakageModel):
+ """Hamming-distance leakage model, leaks the Hamming-distance between the two things."""
num_args = 2
def __call__(self, *args, **kwargs) -> int:
@@ -110,6 +120,7 @@ class HammingDistance(LeakageModel):
@public
class BitLength(LeakageModel):
+ """Bit-length leakage model, leaks the bit-length of the thing."""
num_args = 1
def __call__(self, *args, **kwargs) -> int: