Skip to content

Commit 84293b6

Browse files
authored
Merge pull request #4 from lonkey/release-0.3.1
Release 0.3.1
2 parents 0b4075f + 8ef1ea6 commit 84293b6

11 files changed

Lines changed: 24 additions & 46 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ To use, simply uncomment the corresponding function in `main.py` and adjust the
1717
## To Do
1818

1919
- Include a brute force function for flexible cracking of all included algorithms in the lower prime range
20+
- Enhance the time complexity of the existing RSA `rsa_calculations.brute_force_by_key()` function from its current 2<sup>O(n)</sup>
2021
- Unify output of mathematical conditions
2122
- Add an English translation

cryptographic_functions/dh_calculations.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
__author__ = "Lukas Zorn"
88
__copyright__ = "Copyright 2021 Lukas Zorn"
99
__license__ = "GNU GPLv3"
10-
__version__ = "0.2.1"
11-
__maintainer__ = "Lukas Zorn"
12-
__status__ = "Development"
1310

1411

1512
# Diffie–Hellman key exchange

cryptographic_functions/elgamal_calculations.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
__author__ = "Lukas Zorn"
99
__copyright__ = "Copyright 2021 Lukas Zorn"
1010
__license__ = "GNU GPLv3"
11-
__version__ = "0.2.1"
12-
__maintainer__ = "Lukas Zorn"
13-
__status__ = "Development"
1411

1512

1613
# ElGamal keypair generation

cryptographic_functions/modulo_calculations.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
__author__ = "Lukas Zorn"
88
__copyright__ = "Copyright 2021 Lukas Zorn"
99
__license__ = "GNU GPLv3"
10-
__version__ = "0.2.1"
11-
__maintainer__ = "Lukas Zorn"
12-
__status__ = "Development"
1310

1411

1512
# Addition in finite sets

cryptographic_functions/modulo_cyclic_groups.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
__author__ = "Lukas Zorn"
66
__copyright__ = "Copyright 2021 Lukas Zorn"
77
__license__ = "GNU GPLv3"
8-
__version__ = "0.2.1"
9-
__maintainer__ = "Lukas Zorn"
10-
__status__ = "Development"
118

129

1310
# Cyclic groups

cryptographic_functions/modulo_inverse_additive.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
__author__ = "Lukas Zorn"
77
__copyright__ = "Copyright 2021 Lukas Zorn"
88
__license__ = "GNU GPLv3"
9-
__version__ = "0.2.1"
10-
__maintainer__ = "Lukas Zorn"
11-
__status__ = "Development"
129

1310

1411
# Additive inverse element in finite sets

cryptographic_functions/modulo_inverse_multiplicative.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
__author__ = "Lukas Zorn"
77
__copyright__ = "Copyright 2021 Lukas Zorn"
88
__license__ = "GNU GPLv3"
9-
__version__ = "0.2.1"
10-
__maintainer__ = "Lukas Zorn"
11-
__status__ = "Development"
129

1310

1411
# Multiplicative inverse element in finite sets

cryptographic_functions/rsa_calculations.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
__author__ = "Lukas Zorn"
99
__copyright__ = "Copyright 2021 Lukas Zorn"
1010
__license__ = "GNU GPLv3"
11-
__version__ = "0.2.1"
12-
__maintainer__ = "Lukas Zorn"
13-
__status__ = "Development"
1411

1512

1613
# RSA keypair generation
@@ -138,37 +135,43 @@ def decryption(private_key, c):
138135

139136

140137
# RSA Brute-force
141-
def brute_force_by_key(any_key):
138+
def brute_force_by_key(any_key, p_n=None):
142139
print(tabulate([['RSA Brute-Force Angriff (schlüsselbasiert)']], tablefmt='fancy_grid'))
143140

144141
# Unpack the key into its components
145142
a, n = any_key
146143

147-
# Choose multiple integers x such that 0 ≤ x < n
148-
x, y, z = random.sample(range(n), 3)
144+
# Test for half of all possible plaintexts or 5
145+
if p_n is None:
146+
p_n = n // 2 if n < 50 else 5
147+
148+
# Choose an integer p_n such that 1 ≤ p_n < n
149+
if p_n not in range(1, n):
150+
print(f'Für die Variable p_n = {p_n} muss gelten 1 ≤ {p_n} < {n}.')
151+
return -1
152+
153+
# Choose p_n plaintexts p such that 0 ≤ p < n
154+
p = random.sample(range(n), p_n)
149155

150156
# Encryption
151-
x_c = (x ** a) % n
152-
y_c = (y ** a) % n
153-
z_c = (z ** a) % n
157+
c = [(x ** a) % n for x in p]
154158

155159
# Brute-force
156160
b = []
157-
for v in range(n):
158-
if x != (x_c ** v) % n:
159-
continue
160-
if y != (y_c ** v) % n:
161-
continue
162-
if z != (z_c ** v) % n:
163-
continue
164-
b.append(v)
161+
for (p_x, c_x) in zip(p, c):
162+
b_x = []
163+
for n_x in range(n):
164+
if p_x == (c_x ** n_x) % n:
165+
b_x.append(n_x)
166+
b.append(b_x)
167+
b = sorted(set(b[0]).intersection(*b))
165168

166169
# Calculation path output
167170
if len(b) < 1:
168171
print(
169172
f'Das Gegenstück für den Schlüssel K = {{{a}, {n}}} konnte nicht ermittelt werden.', end='\n\n')
170173
return -1
171174
print(
172-
f'Mögliche Gegenstücke für den Schlüssel K = {{{a}, {n}}} mit den Testwerten x = {x}, y = {y} und z = {z} sind:')
175+
f'Mögliche Gegenstücke für den Schlüssel K = {{{a}, {n}}} sind:')
173176
print(tabulate(zip(*(b, [n] * len(b))), headers=['b', 'n'], tablefmt='pretty'), end='\n\n')
174177
return b[0], n

cryptographic_functions/shamir_calculations.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
__author__ = "Lukas Zorn"
99
__copyright__ = "Copyright 2021 Lukas Zorn"
1010
__license__ = "GNU GPLv3"
11-
__version__ = "0.2.1"
12-
__maintainer__ = "Lukas Zorn"
13-
__status__ = "Development"
1411

1512

1613
# Shamir three-pass keypair generation

cryptographic_functions/shared_functions.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
__author__ = "Lukas Zorn"
66
__copyright__ = "Copyright 2021 Lukas Zorn"
77
__license__ = "GNU GPLv3"
8-
__version__ = "0.2.1"
9-
__maintainer__ = "Lukas Zorn"
10-
__status__ = "Development"
118

129

1310
# Simple gcd calculation

0 commit comments

Comments
 (0)