Skip to content

Commit 895313b

Browse files
authored
Merge pull request #50 from Glindeb/dev
Dev
2 parents 8c3bc1f + cd4a148 commit 895313b

File tree

16 files changed

+187
-45
lines changed

16 files changed

+187
-45
lines changed

.github/workflows/core.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ jobs:
6565
uses: 'marvinpinto/action-automatic-releases@latest'
6666
with:
6767
repo_token: ${{ secrets.RELEASE_TOKEN }}
68-
automatic_release_tag: v1.1.6
68+
automatic_release_tag: v1.2.0
6969
prerelease: false
70-
title: v1.1.6
70+
title: v1.2.0
7171
files: |
7272
dist/*
7373
Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
\mychapter{Introduktion}
22

3-
\section{Inledning}
4-
abstract
3+
Kryptering, något vi möter varje dag i dagens samhälle men...
4+
5+
När de vi idag kallar internet uppkom och öppnades för allmänheten så var tankarna på hur
6+
våran data och information
7+
8+
Hela tiden runt om oss skickas information digitalt från enhet till enhet. Information från
9+
höger till väster bara flödar ...
10+
11+
Information, en grundsten i dagens samhälle ...
12+
513
\section{Syfte}
6-
abstract
7-
\section{Frågeställning}
8-
abstract
14+
Syftet med denna undersökning är att utveckla förståelsen för kryptering och krypterings
15+
algoritmer
16+
17+
18+
\section{Frågeställningar}
19+
Hur påverkas tiden de tar att kryptera en mängd data mellan de olika nyckel längderna 128-bit,
20+
192-bit och 256-bit nyckel?
21+
22+
Hur påverkas
23+
24+
Vad är skillnaden i tiden de tar för att kryptera något mellan att köra algoritmen i ECB, CBC
25+
[och något mer], Samt vilken betydelse ur ett användnings perspektiv får de?

Documentation/Rapport/Main.pdf

1.19 KB
Binary file not shown.
1.94 KB
Binary file not shown.

Documentation/Rapport/Main.tex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@
114114
\vspace{3.5cm}
115115
{\huge\bfseries The AES encryption algorithm\par}
116116
\vspace{0.1cm}
117-
~{\large En undersökning av The Advanced Encryption Standard (AES) \par
118-
~ur ett struktur och användnings perspektiv}
117+
~{\large En undersökning av The Advanced Encryption Standard (AES)}
119118

120119
% Bottom of the page
121120
\vfill

Documentation/Rapport/Ref.bib

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ @misc{wikipedia_2022
55
publisher = {Wikimedia Foundation},
66
year = {2022},
77
month = {Jun}
8-
}
8+
}
9+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Implemented running modes
2121
- [x] **CBC** - Cipher Block Chaining mode (For more information see ...)
2222
- [x] **PCBC** - Propagating Cipher Block Chaining mode (For more information see ...)
2323
- [ ] **CFB** - Cipher Feedback mode (For more information see ...)
24-
- [ ] **OFB** - Output FeedBack mode (For more information see ...)
24+
- [x] **OFB** - Output FeedBack mode (For more information see ...)
2525
- [ ] **CTR** - Counter mode (For more information see ...)
2626
- [ ] **GCM** - Galois/Counter mode (For more information see ...)
2727

src/PyAES/AES.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,3 +585,85 @@ def pcbc_dec(key, file_path, iv, terminal_width=80):
585585
progress = progress_bar(progress, file_size, terminal_width)
586586
progress = progress_bar(progress, file_size, terminal_width)
587587
remove(file_path)
588+
589+
590+
# OFB encryption function (Tested but no automated test implemented and no test with different file sizes)
591+
def ofb_enc(key, file_path, iv, terminal_width=80):
592+
file_size = getsize(file_path)
593+
progress = 0
594+
progress = progress_bar(progress, file_size, terminal_width)
595+
mix = [int(iv[i:i+2], 16) for i in range(0, len(iv), 2)]
596+
iv = mix
597+
598+
with open(f"{file_path}.enc", 'wb') as output, open(file_path, 'rb') as data:
599+
for i in range(int(file_size/16)):
600+
raw = [i for i in data.read(16)]
601+
mix = encryption_rounds(mix, key)
602+
result = xor(raw, mix)
603+
output.write(bytes(result))
604+
progress = progress_bar(progress, file_size, terminal_width)
605+
606+
if file_size % 16 != 0:
607+
raw = [i for i in data.read()]
608+
raw, length = add_padding(raw)
609+
610+
if file_size < 16:
611+
mix = encryption_rounds(iv, key)
612+
else:
613+
mix = encryption_rounds(mix, key)
614+
result = xor(mix, raw)
615+
616+
mix = encryption_rounds(mix, key)
617+
identifier = xor(([0 for i in range(15)] + [length]), mix)
618+
619+
output.write(bytes(result + identifier))
620+
progress = progress_bar(progress, file_size, terminal_width)
621+
else:
622+
mix = encryption_rounds(mix, key)
623+
identifier = xor([0 for i in range(16)], mix)
624+
output.write(bytes(identifier))
625+
progress = progress_bar(progress, file_size, terminal_width)
626+
progress = progress_bar(progress, file_size, terminal_width)
627+
remove(file_path)
628+
629+
630+
# OFB decryption function (Tested but no automated test implemented and no test with different file sizes)
631+
def ofb_dec(key, file_path, iv, terminal_width=80):
632+
iv = [int(iv[i:i+2], 16) for i in range(0, len(iv), 2)]
633+
file_size = getsize(file_path)
634+
progress = 0
635+
progress = progress_bar(progress, file_size, terminal_width)
636+
file_name = file_path[:-4]
637+
638+
with open(f"{file_name}", 'wb') as output, open(file_path, 'rb') as data:
639+
if int(file_size/16) - 3 >= 0:
640+
raw = [i for i in data.read(16)]
641+
mix = encryption_rounds(iv, key)
642+
result = xor(raw, mix)
643+
output.write(bytes(result))
644+
progress = progress_bar(progress, file_size, terminal_width)
645+
646+
for i in range(int(file_size/16) - 3):
647+
raw = [i for i in data.read(16)]
648+
mix = encryption_rounds(mix, key)
649+
result = xor(raw, mix)
650+
output.write(bytes(result))
651+
progress = progress_bar(progress, file_size, terminal_width)
652+
else:
653+
mix = iv
654+
655+
data_pice = [i for i in data.read(16)]
656+
identifier = [i for i in data.read()]
657+
658+
mix = encryption_rounds(mix, key)
659+
data_pice = xor(data_pice, mix)
660+
661+
mix = encryption_rounds(mix, key)
662+
identifier = xor(identifier, mix)
663+
664+
result = bytes(remove_padding(data_pice, identifier))
665+
666+
output.write(result)
667+
progress = progress_bar(progress, file_size, terminal_width)
668+
progress = progress_bar(progress, file_size, terminal_width)
669+
remove(file_path)

src/PyAES/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
__copyright__ = 'Copyright 2022, Gabriel Lindeblad'
2020
__credits__ = [""]
2121
__license__ = 'MIT'
22-
__version__ = '1.1.6'
22+
__version__ = '1.2.0'
2323
__maintainer__ = 'Gabriel Lindeblad'
2424
__email__ = 'Gabriel.lindeblad@icloud.com'
2525
__status__ = 'Development'

src/PyAES/decrypt.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ def decrypt(key, file_path, running_mode, iv=None, terminal_size=80):
2323
AES.cbc_dec(key, file_path, iv, terminal_size)
2424
elif running_mode == "PCBC" and iv is not None:
2525
AES.pcbc_dec(key, file_path, iv, terminal_size)
26+
elif running_mode == "OFB" and iv is not None:
27+
AES.ofb_dec(key, file_path, iv, terminal_size)
2628
else:
2729
raise Exception("Running mode not supported")
2830

0 commit comments

Comments
 (0)