Skip to content

Commit

Permalink
pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
programmingAthlete committed Dec 22, 2023
1 parent 341e2c0 commit 13073bb
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ src/crypto_pkg/ciphers/asymmetric/rsa/__pycache__/
tests/__pycache__/
**/__pycache__/

dist




Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include src/crypto_pkg/attacks/power_analysis/test_file.pickle
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,4 @@ Usage examples are provided in the attacks source code files

<code>crypto attacks AES-double-encryption --help</code>

<code>crypto attacks correlation-power-analysis --help</code>

## Usage
The <i>Textbook RSA</i> and the <i>DGVH</i> PKEs are used in the [BruteSniffing_Fisher](https://github.com/programmingAthlete/BruteSniffing_Fisher) repository.
<code>crypto attacks correlation-power-analysis --help</code>
Binary file added dist/crypto_pkg-1.4.4-py3-none-any.whl
Binary file not shown.
Binary file added dist/crypto_pkg-1.4.4.tar.gz
Binary file not shown.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[metadata]
name = crypto_pkg

[options]
include_package_data = True

[options.entry_points]
console_scripts =
crypto = crypto_pkg.entry_point:main
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

__version__ = "1.4.3"
__version__ = "1.4.4"

with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
Expand All @@ -17,10 +17,14 @@
version=__version__,
package_dir={"": "src"},
packages=find_packages(where="src", exclude=["*tests*"]),
package_data={
'crypto_pkg': ['attacks/power_analysis/test_file.pickle'],
},
install_requires=requirements,
author="programmingAthlete",
author_email="luca.bonamino@hotmail.com",
zip_safe=True,
console_scripts={
"crypto":"crypto.entry_point:main"
"crypto": "crypto.entry_point:main"
}
)
10 changes: 9 additions & 1 deletion src/crypto_pkg/clis/attacks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import multiprocessing
import os
import pickle
import time
from decimal import Decimal
import random
Expand All @@ -15,6 +16,8 @@
from crypto_pkg.attacks.power_analysis.correlation_power_analysis import Attack as PowerAnalysisAttack
from crypto_pkg.attacks.stream_ciphers.geffe_cipher import Attack as GeffeAttack, ThresholdsOperator
from crypto_pkg.contracts.cli_dto import ModifiedAESIn
from importlib import resources
import io

app = typer.Typer(pretty_exceptions_show_locals=False, no_args_is_help=True)

Expand Down Expand Up @@ -170,7 +173,7 @@ def attack_double_encryption(

@app.command("correlation-power-analysis")
def attack_correlation_power_analysis(
filename: str = typer.Argument('src/crypto_pkg/attacks/power_analysis/test_file_name.pickle',
filename: str = typer.Argument('test_file.pickle',
help="Filename of the pickle file with the measurements"),
max_datapoints: Optional[int] = typer.Option(400, help="Maximum number of data points to consider"),
byte_position: Optional[int] = typer.Option(None, help="Byte position to attack")
Expand All @@ -181,7 +184,11 @@ def attack_correlation_power_analysis(
datapoints\n
If a byte position is provided, only the provided key byte will be attacked, otherwise the whole key will be.
"""
with resources.open_binary('crypto_pkg.attacks.power_analysis', 'test_file.pickle') as file:
content = file.read()

with open(filename, 'wb') as f:
f.write(content)
if not os.path.exists(filename):
msg = f"File {filename} does not exist"
print(msg)
Expand All @@ -199,3 +206,4 @@ def attack_correlation_power_analysis(
show_plot_correlations=False)
print("Key Found")
print(key)
os.remove(filename)

0 comments on commit 13073bb

Please sign in to comment.